mirror of
https://github.com/wez/wezterm.git
synced 2024-12-24 13:52:55 +03:00
try to normalize the shift state in the keymap handling code
We weren't recognizing ctrl+shift+c for example on linux.
This commit is contained in:
parent
5370e88520
commit
7323e30be7
@ -65,16 +65,16 @@ impl KeyMap {
|
||||
[KeyModifiers::SHIFT, KeyCode::Insert, Paste],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('c'), Copy],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('v'), Paste],
|
||||
[ctrl_shift, KeyCode::Char('c'), Copy],
|
||||
[ctrl_shift, KeyCode::Char('v'), Paste],
|
||||
[ctrl_shift, KeyCode::Char('C'), Copy],
|
||||
[ctrl_shift, KeyCode::Char('V'), Paste],
|
||||
// Window management
|
||||
[KeyModifiers::ALT, KeyCode::Char('\n'), ToggleFullScreen],
|
||||
[KeyModifiers::ALT, KeyCode::Char('\r'), ToggleFullScreen],
|
||||
[KeyModifiers::ALT, KeyCode::Enter, ToggleFullScreen],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('m'), Hide],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('n'), SpawnWindow],
|
||||
[ctrl_shift, KeyCode::Char('m'), Hide],
|
||||
[ctrl_shift, KeyCode::Char('n'), SpawnWindow],
|
||||
[ctrl_shift, KeyCode::Char('M'), Hide],
|
||||
[ctrl_shift, KeyCode::Char('N'), SpawnWindow],
|
||||
// Font size manipulation
|
||||
[KeyModifiers::CTRL, KeyCode::Char('-'), DecreaseFontSize],
|
||||
[KeyModifiers::CTRL, KeyCode::Char('0'), ResetFontSize],
|
||||
@ -90,7 +90,7 @@ impl KeyMap {
|
||||
],
|
||||
[
|
||||
ctrl_shift,
|
||||
KeyCode::Char('t'),
|
||||
KeyCode::Char('T'),
|
||||
SpawnTab(SpawnTabDomain::DefaultDomain)
|
||||
],
|
||||
[
|
||||
@ -117,7 +117,7 @@ impl KeyMap {
|
||||
[ctrl_shift, KeyCode::Char('7'), ActivateTab(6)],
|
||||
[ctrl_shift, KeyCode::Char('8'), ActivateTab(7)],
|
||||
[ctrl_shift, KeyCode::Char('9'), ActivateTab(8)],
|
||||
[ctrl_shift, KeyCode::Char('w'), CloseCurrentTab],
|
||||
[ctrl_shift, KeyCode::Char('W'), CloseCurrentTab],
|
||||
[
|
||||
KeyModifiers::SUPER | KeyModifiers::SHIFT,
|
||||
KeyCode::Char('['),
|
||||
@ -144,6 +144,8 @@ impl KeyMap {
|
||||
}
|
||||
|
||||
pub fn lookup(&self, key: KeyCode, mods: KeyModifiers) -> Option<KeyAssignment> {
|
||||
self.0.get(&(key, mods)).cloned()
|
||||
self.0
|
||||
.get(&(key.normalize_shift_to_upper_case(mods), mods))
|
||||
.cloned()
|
||||
}
|
||||
}
|
||||
|
@ -170,6 +170,25 @@ pub enum KeyCode {
|
||||
InternalPasteEnd,
|
||||
}
|
||||
|
||||
impl KeyCode {
|
||||
/// if SHIFT is held and we have KeyCode::Char('c') we want to normalize
|
||||
/// that keycode to KeyCode::Char('C'); that is what this function does.
|
||||
/// In theory we should give the same treatment to keys like `[` -> `{`
|
||||
/// but that assumes something about the keyboard layout and is probably
|
||||
/// better done in the gui frontend rather than this layer.
|
||||
/// In fact, this function might be better off if it lived elsewhere.
|
||||
pub fn normalize_shift_to_upper_case(self, modifiers: Modifiers) -> KeyCode {
|
||||
if modifiers.contains(Modifiers::SHIFT) {
|
||||
match self {
|
||||
KeyCode::Char(c) if c.is_ascii_lowercase() => KeyCode::Char(c.to_ascii_uppercase()),
|
||||
_ => self,
|
||||
}
|
||||
} else {
|
||||
self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
enum InputState {
|
||||
Normal,
|
||||
|
Loading…
Reference in New Issue
Block a user