diff options
author | Ido Yariv <yarivido@gmail.com> | 2024-03-26 07:12:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-26 12:12:58 +0100 |
commit | 03e8a9398a84ff1c17557bbddb8a4deca0d51871 (patch) | |
tree | 17cd9b13df720a2bd2c6d0c318f538b63db726a8 | |
parent | 71ac381a210effeb11cd7ec0a26803ea720d8a5f (diff) |
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>
-rw-r--r-- | zellij-utils/src/data.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/zellij-utils/src/data.rs b/zellij-utils/src/data.rs index 204c57e43..379fb126f 100644 --- a/zellij-utils/src/data.rs +++ b/zellij-utils/src/data.rs @@ -79,6 +79,9 @@ impl FromStr for 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)) => { parse_main_key(main_key, key_str, Key::Ctrl, Key::CtrlF) }, @@ -171,6 +174,7 @@ impl fmt::Display for Key { '\n' => write!(f, "ENTER"), '\t' => write!(f, "TAB"), ' ' => write!(f, "SPACE"), + '\x00' => write!(f, "Ctrl+SPACE"), _ => write!(f, "{}", c), }, Key::Alt(c) => write!(f, "Alt+{}", c), |