macos: improve support for dvorak

Remove a normalizing function that made assumptions based on the
keycaps that did not hold up when selecting Dvorak as an input
source.  For example "CTRL-C" where `C` is the key with the C keycap
would send `CTRL-C` even when Dvorak was selected; it should send CTRL-J
in that layout.

I think with the other normalization that happens in the termwindow
layer we don't need this function any more.
This commit is contained in:
Wez Furlong committed 2020-01-26 18:13:16 -08:00
1 parent 38b19cb7ea
commit 85c70aebb7
1 file changed
+1 -60
+1 -60
View File
@@ -1069,70 +1069,11 @@ impl WindowView {
}
}
fn normalize_shifted_unmodified_key(kc: KeyCode, virtual_key: u16) -> KeyCode {
use super::keycodes;
match virtual_key {
keycodes::kVK_ANSI_A => KeyCode::Char('a'),
keycodes::kVK_ANSI_B => KeyCode::Char('b'),
keycodes::kVK_ANSI_C => KeyCode::Char('c'),
keycodes::kVK_ANSI_D => KeyCode::Char('d'),
keycodes::kVK_ANSI_E => KeyCode::Char('e'),
keycodes::kVK_ANSI_F => KeyCode::Char('f'),
keycodes::kVK_ANSI_G => KeyCode::Char('g'),
keycodes::kVK_ANSI_H => KeyCode::Char('h'),
keycodes::kVK_ANSI_I => KeyCode::Char('i'),
keycodes::kVK_ANSI_J => KeyCode::Char('j'),
keycodes::kVK_ANSI_K => KeyCode::Char('k'),
keycodes::kVK_ANSI_L => KeyCode::Char('l'),
keycodes::kVK_ANSI_M => KeyCode::Char('m'),
keycodes::kVK_ANSI_N => KeyCode::Char('n'),
keycodes::kVK_ANSI_O => KeyCode::Char('o'),
keycodes::kVK_ANSI_P => KeyCode::Char('p'),
keycodes::kVK_ANSI_Q => KeyCode::Char('q'),
keycodes::kVK_ANSI_R => KeyCode::Char('r'),
keycodes::kVK_ANSI_S => KeyCode::Char('s'),
keycodes::kVK_ANSI_T => KeyCode::Char('t'),
keycodes::kVK_ANSI_U => KeyCode::Char('u'),
keycodes::kVK_ANSI_V => KeyCode::Char('v'),
keycodes::kVK_ANSI_W => KeyCode::Char('w'),
keycodes::kVK_ANSI_X => KeyCode::Char('x'),
keycodes::kVK_ANSI_Y => KeyCode::Char('y'),
keycodes::kVK_ANSI_Z => KeyCode::Char('z'),
keycodes::kVK_ANSI_0 => KeyCode::Char('0'),
keycodes::kVK_ANSI_1 => KeyCode::Char('1'),
keycodes::kVK_ANSI_2 => KeyCode::Char('2'),
keycodes::kVK_ANSI_3 => KeyCode::Char('3'),
keycodes::kVK_ANSI_4 => KeyCode::Char('4'),
keycodes::kVK_ANSI_5 => KeyCode::Char('5'),
keycodes::kVK_ANSI_6 => KeyCode::Char('6'),
keycodes::kVK_ANSI_7 => KeyCode::Char('7'),
keycodes::kVK_ANSI_8 => KeyCode::Char('8'),
keycodes::kVK_ANSI_9 => KeyCode::Char('9'),
keycodes::kVK_ANSI_Equal => KeyCode::Char('='),
keycodes::kVK_ANSI_Minus => KeyCode::Char('-'),
keycodes::kVK_ANSI_LeftBracket => KeyCode::Char('['),
keycodes::kVK_ANSI_RightBracket => KeyCode::Char(']'),
keycodes::kVK_ANSI_Quote => KeyCode::Char('\''),
keycodes::kVK_ANSI_Semicolon => KeyCode::Char(';'),
keycodes::kVK_ANSI_Backslash => KeyCode::Char('\\'),
keycodes::kVK_ANSI_Comma => KeyCode::Char(','),
keycodes::kVK_ANSI_Slash => KeyCode::Char('/'),
keycodes::kVK_ANSI_Period => KeyCode::Char('.'),
keycodes::kVK_ANSI_Grave => KeyCode::Char('`'),
keycodes::kVK_Delete => KeyCode::Char('\x08'),
keycodes::kVK_ForwardDelete => KeyCode::Char('\x7f'),
_ => kc,
}
}
if let Some(key) = key_string_to_key_code(chars) {
let (key, raw_key) = if chars == unmod {
(key, None)
} else {
let raw = key_string_to_key_code(unmod)
.map(|kc| normalize_shifted_unmodified_key(kc, virtual_key));
let raw = key_string_to_key_code(unmod);
match (&key, &raw) {
// Avoid eg: \x01 when we can use CTRL-A
(KeyCode::Char(c), Some(raw)) if c.is_ascii_control() => (raw.clone(), None),