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 | |
parent | 372213fa483f1b6e92b65575882d40f48480b5e4 (diff) |
add support for backtab key
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | src/keys.rs | 9 | ||||
-rw-r--r-- | src/verb/builtin.rs | 3 |
3 files changed, 12 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 7478be7..1b5d668 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### next +- add support for backtab key (by default it's bound to :previous_match) + <a name="v1.4.0"></a> ### v1.4.0 - 2021-05-11 - the default (non prefixed) search is now "path fuzzy" instead of "name fuzzy". You can still change the default mode and mode bindings in the config. This was done after a survey in chat. 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" => { diff --git a/src/verb/builtin.rs b/src/verb/builtin.rs index a2b0128..1b7da90 100644 --- a/src/verb/builtin.rs +++ b/src/verb/builtin.rs @@ -77,7 +77,6 @@ pub fn builtin_verbs() -> Vec<Verb> { internal(preview_binary), internal(close_panel_ok), internal(close_panel_cancel) - .with_key(BACK_TAB) .with_control_key('w'), external( "copy {newpath:path-from-parent}", @@ -142,6 +141,8 @@ pub fn builtin_verbs() -> Vec<Verb> { .with_char_key(' ') .with_char_key(':') .with_char_key('/'), + internal(previous_match) + .with_key(BACK_TAB), internal(next_match) .with_key(TAB), internal(no_sort) |