From cf86e7d29109f8eb60a341011e034f4347d9e3f3 Mon Sep 17 00:00:00 2001 From: qkzk Date: Mon, 21 Nov 2022 20:28:37 +0100 Subject: improve tab navigation interface --- src/actioner.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/actioner.rs') diff --git a/src/actioner.rs b/src/actioner.rs index 7e49a33..0c0a33c 100644 --- a/src/actioner.rs +++ b/src/actioner.rs @@ -78,6 +78,7 @@ impl Actioner { Event::Key(Key::PageUp) => self.page_up(status), Event::Key(Key::Enter) => self.enter(status), Event::Key(Key::Tab) => self.tab(status), + Event::Key(Key::BackTab) => self.backtab(status), Event::Key(Key::WheelUp(_, _, _)) => self.up(status), Event::Key(Key::WheelDown(_, _, _)) => self.down(status), Event::Key(Key::SingleClick(MouseButton::Left, row, _)) => { @@ -299,17 +300,31 @@ impl Actioner { } /// Select next completion and insert it + /// Select next tab fn tab(&self, status: &mut Status) -> FmResult<()> { match status.selected().mode { Mode::Goto | Mode::Exec | Mode::Search => { status.selected().event_replace_input_with_completion() } - Mode::Normal => status.next(), + Mode::Normal => { + if status.len_index_of_tabs().0 == 1 { + status.new_tab() + } + status.next() + } _ => (), }; Ok(()) } + /// Select previous tab + fn backtab(&self, status: &mut Status) -> FmResult<()> { + if let Mode::Normal = status.selected().mode { + status.prev() + } + Ok(()) + } + fn ctrl_f(&self, status: &mut Status) -> FmResult<()> { let output = Skimer::new(self.term.clone()).no_source( status @@ -362,7 +377,12 @@ impl Actioner { } Mode::Normal => match self.binds.get(&c) { Some(event_char) => event_char.match_char(status), - None => Ok(()), + None => { + if c.is_ascii_digit() { + status.go_tab(c) + } + Ok(()) + } }, Mode::Help | Mode::Preview | Mode::Shortcut => status.selected().event_normal(), Mode::Jump => Ok(()), -- cgit v1.2.3