Skip to content

Commit

Permalink
Merge pull request #141 from rsteube/tab
Browse files Browse the repository at this point in the history
support Tab / BackTab to cycle through items
  • Loading branch information
pksunkara committed Oct 17, 2021
2 parents d922429 + 0149499 commit 1b84eaf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/prompts/fuzzy_select.rs
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/prompts/multi_select.rs
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/prompts/select.rs
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/prompts/sort.rs
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 1b84eaf

Please sign in to comment.