From 0149499fbdbc9518484197abe620e7350ecfcf97 Mon Sep 17 00:00:00 2001 From: rsteube Date: Sun, 17 Oct 2021 11:19:02 +0200 Subject: [PATCH] support Tab / BackTab to cycle through items --- src/prompts/fuzzy_select.rs | 4 ++-- src/prompts/multi_select.rs | 4 ++-- src/prompts/select.rs | 4 ++-- src/prompts/sort.rs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/prompts/fuzzy_select.rs b/src/prompts/fuzzy_select.rs index 62e7c944..d7cc67cc 100644 --- a/src/prompts/fuzzy_select.rs +++ b/src/prompts/fuzzy_select.rs @@ -174,7 +174,7 @@ impl FuzzySelect<'_> { term.show_cursor()?; return Ok(None); } - Key::ArrowUp if filtered_list.len() > 0 => { + Key::ArrowUp | Key::BackTab if filtered_list.len() > 0 => { if sel == !0 { sel = filtered_list.len() - 1; } else { @@ -183,7 +183,7 @@ impl FuzzySelect<'_> { } term.flush()?; } - Key::ArrowDown if filtered_list.len() > 0 => { + Key::ArrowDown | Key::Tab if filtered_list.len() > 0 => { if sel == !0 { sel = 0; } else { diff --git a/src/prompts/multi_select.rs b/src/prompts/multi_select.rs index 015e6716..e143c12a 100644 --- a/src/prompts/multi_select.rs +++ b/src/prompts/multi_select.rs @@ -221,14 +221,14 @@ impl MultiSelect<'_> { term.flush()?; match term.read_key()? { - Key::ArrowDown | Key::Char('j') => { + Key::ArrowDown | Key::Tab | Key::Char('j') => { if sel == !0 { sel = 0; } else { sel = (sel as u64 + 1).rem(self.items.len() as u64) as usize; } } - Key::ArrowUp | Key::Char('k') => { + Key::ArrowUp | Key::BackTab | Key::Char('k') => { if sel == !0 { sel = self.items.len() - 1; } else { diff --git a/src/prompts/select.rs b/src/prompts/select.rs index 2713ef80..0bb1c0b0 100644 --- a/src/prompts/select.rs +++ b/src/prompts/select.rs @@ -256,7 +256,7 @@ impl Select<'_> { term.flush()?; match term.read_key()? { - Key::ArrowDown | Key::Char('j') => { + Key::ArrowDown | Key::Tab | Key::Char('j') => { if sel == !0 { sel = 0; } else { @@ -275,7 +275,7 @@ impl Select<'_> { return Ok(None); } } - Key::ArrowUp | Key::Char('k') => { + Key::ArrowUp | Key::BackTab | Key::Char('k') => { if sel == !0 { sel = self.items.len() - 1; } else { diff --git a/src/prompts/sort.rs b/src/prompts/sort.rs index 4d0b50be..19fef5de 100644 --- a/src/prompts/sort.rs +++ b/src/prompts/sort.rs @@ -188,7 +188,7 @@ impl Sort<'_> { term.flush()?; match term.read_key()? { - Key::ArrowDown | Key::Char('j') => { + Key::ArrowDown | Key::Tab | Key::Char('j') => { let old_sel = sel; if sel == !0 { @@ -201,7 +201,7 @@ impl Sort<'_> { order.swap(old_sel, sel); } } - Key::ArrowUp | Key::Char('k') => { + Key::ArrowUp | Key::BackTab | Key::Char('k') => { let old_sel = sel; if sel == !0 {