summaryrefslogtreecommitdiffstats
path: root/src/actioner.rs
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2022-11-21 20:28:37 +0100
committerqkzk <qu3nt1n@gmail.com>2022-11-21 20:28:37 +0100
commitcf86e7d29109f8eb60a341011e034f4347d9e3f3 (patch)
treef655f1abefcf219e30c84538c973a1daf6396b1a /src/actioner.rs
parent95db27f292e7ee8ea0a63583987431df1ea79dd1 (diff)
improve tab navigation interfacetab-bar
Diffstat (limited to 'src/actioner.rs')
-rw-r--r--src/actioner.rs24
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(()),