mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Update comment
This commit is contained in:
parent
07d9a4194d
commit
c7353343e2
1 changed files with 14 additions and 13 deletions
|
|
@ -32,16 +32,17 @@ impl Default for Key {
|
||||||
|
|
||||||
impl From<KeyEvent> for Key {
|
impl From<KeyEvent> for Key {
|
||||||
fn from(value: KeyEvent) -> Self {
|
fn from(value: KeyEvent) -> Self {
|
||||||
/*
|
// For alphabet:
|
||||||
On Linx and Mac:
|
// Unix : <S-a> => Char("A") + Shift
|
||||||
shift + alphabet => uppercase alphabet + SHIFT
|
// Windows : <S-a> => Char("A") + Shift
|
||||||
shift + non alphabet => shifted non alphabet + NULL
|
//
|
||||||
On Windows:
|
// For non-alphabet:
|
||||||
shift + alphabet => uppercase alphabet + SHIFT
|
// Unix : <S-`> => Char("~") + NULL
|
||||||
shift + non alphabet => shifted non alphabet + SHIFT
|
// Windows : <S-`> => Char("`") + Shift
|
||||||
So we detect (non alphabet + SHIFT) and change it to (non alphabet + NULL) for consistent
|
//
|
||||||
behavior between OSs.
|
// So we detect `Char("`") + Shift`, and change it to `Char("~") + NULL`
|
||||||
*/
|
// for consistent behavior between OSs.
|
||||||
|
|
||||||
let shift = match (value.code, value.modifiers) {
|
let shift = match (value.code, value.modifiers) {
|
||||||
(KeyCode::Char(c), _) if c.is_ascii_uppercase() => true,
|
(KeyCode::Char(c), _) if c.is_ascii_uppercase() => true,
|
||||||
(KeyCode::Char(_), m) if m.contains(KeyModifiers::SHIFT) => false,
|
(KeyCode::Char(_), m) if m.contains(KeyModifiers::SHIFT) => false,
|
||||||
|
|
@ -49,10 +50,10 @@ impl From<KeyEvent> for Key {
|
||||||
};
|
};
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
code: value.code,
|
code: value.code,
|
||||||
shift,
|
shift,
|
||||||
ctrl: value.modifiers.contains(KeyModifiers::CONTROL),
|
ctrl: value.modifiers.contains(KeyModifiers::CONTROL),
|
||||||
alt: value.modifiers.contains(KeyModifiers::ALT),
|
alt: value.modifiers.contains(KeyModifiers::ALT),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue