fix(keybindings): add support for binding Ctrl-Space (#3101)
* Add support for binding Ctrl-@ On most terminals, typing Ctrl-@ results in a null character with no modifier. Moreover, Ctrl-Space is commonly mapped as an alias for Ctrl-@, making it easier to bind it as well. * style(fmt): rustfmt --------- Co-authored-by: Aram Drevekenin <aram@poor.dev>
This commit is contained in:
parent
71ac381a21
commit
03e8a9398a
1 changed files with 4 additions and 0 deletions
|
|
@ -79,6 +79,9 @@ impl FromStr for Key {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match (modifier, main_key) {
|
match (modifier, main_key) {
|
||||||
|
(Some("Ctrl"), Some(main_key)) if main_key == "@" || main_key == "Space" => {
|
||||||
|
Ok(Key::Char('\x00'))
|
||||||
|
},
|
||||||
(Some("Ctrl"), Some(main_key)) => {
|
(Some("Ctrl"), Some(main_key)) => {
|
||||||
parse_main_key(main_key, key_str, Key::Ctrl, Key::CtrlF)
|
parse_main_key(main_key, key_str, Key::Ctrl, Key::CtrlF)
|
||||||
},
|
},
|
||||||
|
|
@ -171,6 +174,7 @@ impl fmt::Display for Key {
|
||||||
'\n' => write!(f, "ENTER"),
|
'\n' => write!(f, "ENTER"),
|
||||||
'\t' => write!(f, "TAB"),
|
'\t' => write!(f, "TAB"),
|
||||||
' ' => write!(f, "SPACE"),
|
' ' => write!(f, "SPACE"),
|
||||||
|
'\x00' => write!(f, "Ctrl+SPACE"),
|
||||||
_ => write!(f, "{}", c),
|
_ => write!(f, "{}", c),
|
||||||
},
|
},
|
||||||
Key::Alt(c) => write!(f, "Alt+{}", c),
|
Key::Alt(c) => write!(f, "Alt+{}", c),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue