diff options
author | Canop <cano.petrole@gmail.com> | 2021-05-18 16:34:24 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2021-05-18 16:34:24 +0200 |
commit | 92395cbef4d9cf5b28cb60cebd1fc7e019aa2a5e (patch) | |
tree | a367a7edd9282b64f6a24a365403711ed8a25137 /src/keys.rs | |
parent | 372213fa483f1b6e92b65575882d40f48480b5e4 (diff) |
add support for backtab key
Diffstat (limited to 'src/keys.rs')
-rw-r--r-- | src/keys.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/keys.rs b/src/keys.rs index bf6c467..048adc8 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -31,7 +31,7 @@ macro_rules! const_key { const_key!(ALT_ENTER, Enter, KeyModifiers::ALT); const_key!(ENTER, Enter); const_key!(BACKSPACE, Backspace); -const_key!(BACK_TAB, BackTab); +const_key!(BACK_TAB, BackTab, KeyModifiers::SHIFT); // backtab needs shift const_key!(DELETE, Delete); const_key!(DOWN, Down); const_key!(PAGE_DOWN, PageDown); @@ -123,7 +123,7 @@ pub fn as_letter(key: KeyEvent) -> Option<char> { /// About the case: /// The char we receive as code from crossterm is usually lowercase /// but uppercase when it was typed with shift (i.e. we receive -/// "g" for a lowercase, ang "shift-G" for an uppercase) +/// "g" for a lowercase, and "shift-G" for an uppercase) pub fn parse_key(raw: &str) -> Result<KeyEvent, ConfError> { fn bad_key(raw: &str) -> Result<KeyEvent, ConfError> { Err(ConfError::InvalidKey { @@ -169,6 +169,11 @@ pub fn parse_key(raw: &str) -> Result<KeyEvent, ConfError> { } }; let mut modifiers = KeyModifiers::empty(); + if code == BackTab { + // Crossterm always sends the shift key with + // backtab + modifiers.insert(KeyModifiers::SHIFT); + } for token in tokens.iter().take(tokens.len() - 1) { match token.to_ascii_lowercase().as_ref() { "ctrl" => { |