diff options
Diffstat (limited to 'src/actioner.rs')
-rw-r--r-- | src/actioner.rs | 24 |
1 files changed, 22 insertions, 2 deletions
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(()), |