Update comment

This commit is contained in:
sxyazi 2023-09-20 23:47:46 +08:00
parent 07d9a4194d
commit c7353343e2
No known key found for this signature in database

View file

@ -32,16 +32,17 @@ impl Default for Key {
impl From<KeyEvent> for Key {
fn from(value: KeyEvent) -> Self {
/*
On Linx and Mac:
shift + alphabet => uppercase alphabet + SHIFT
shift + non alphabet => shifted non alphabet + NULL
On Windows:
shift + alphabet => uppercase alphabet + SHIFT
shift + non alphabet => shifted non alphabet + SHIFT
So we detect (non alphabet + SHIFT) and change it to (non alphabet + NULL) for consistent
behavior between OSs.
*/
// For alphabet:
// Unix : <S-a> => Char("A") + Shift
// Windows : <S-a> => Char("A") + Shift
//
// For non-alphabet:
// Unix : <S-`> => Char("~") + NULL
// Windows : <S-`> => Char("`") + Shift
//
// So we detect `Char("`") + Shift`, and change it to `Char("~") + NULL`
// for consistent behavior between OSs.
let shift = match (value.code, value.modifiers) {
(KeyCode::Char(c), _) if c.is_ascii_uppercase() => true,
(KeyCode::Char(_), m) if m.contains(KeyModifiers::SHIFT) => false,