diff options
author | qkzk <qu3nt1n@gmail.com> | 2022-11-27 14:42:13 +0100 |
---|---|---|
committer | qkzk <qu3nt1n@gmail.com> | 2022-11-27 14:42:13 +0100 |
commit | 348a19ab2377fdfb9a9ecbb1e8af508dcbdc7c0b (patch) | |
tree | 28c7292b3d95f990c833742c6b74b198d60c644b | |
parent | 7298ab3359bfece3db537034bc2ed2fbc8c6971b (diff) |
move back with -
-rw-r--r-- | src/actioner.rs | 2 | ||||
-rw-r--r-- | src/config.rs | 5 | ||||
-rw-r--r-- | src/event_char.rs | 2 | ||||
-rw-r--r-- | src/help.rs | 1 | ||||
-rw-r--r-- | src/tab.rs | 13 |
5 files changed, 23 insertions, 0 deletions
diff --git a/src/actioner.rs b/src/actioner.rs index cea4510f..8dfb73dc 100644 --- a/src/actioner.rs +++ b/src/actioner.rs @@ -51,6 +51,7 @@ impl Actioner { (keybindings.marks_new, EventChar::MarksNew), (keybindings.marks_jump, EventChar::MarksJump), (keybindings.filter, EventChar::Filter), + (keybindings.back, EventChar::Back), ]); Self { binds } } @@ -368,6 +369,7 @@ impl Actioner { Some(event_char) => event_char.match_char(status), None => { if c.is_ascii_digit() { + eprintln!("char {} is a digit", c); status.go_tab(c) } Ok(()) diff --git a/src/config.rs b/src/config.rs index 38cd8e1e..9fadf85f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -205,6 +205,7 @@ pub struct Keybindings { pub marks_new: char, pub marks_jump: char, pub filter: char, + pub back: char, } impl Keybindings { @@ -304,6 +305,9 @@ impl Keybindings { if let Some(filter) = yaml["filter"].as_str().map(|s| s.to_string()) { self.filter = filter.chars().next().unwrap_or('f'); } + if let Some(back) = yaml["back"].as_str().map(|s| s.to_string()) { + self.back = back.chars().next().unwrap_or('-'); + } } /// Returns a new `Keybindings` instance with hardcoded values. @@ -340,6 +344,7 @@ impl Keybindings { marks_new: 'M', marks_jump: '\'', filter: 'f', + back: '-', } } } diff --git a/src/event_char.rs b/src/event_char.rs index 821b83fb..4fa665e6 100644 --- a/src/event_char.rs +++ b/src/event_char.rs @@ -33,6 +33,7 @@ pub enum EventChar { MarksNew, MarksJump, Filter, + Back, } impl EventChar { @@ -127,6 +128,7 @@ impl EventChar { Ok(()) } EventChar::Filter => status.selected().event_filter(), + EventChar::Back => status.selected().event_back(), } } } diff --git a/src/help.rs b/src/help.rs index dd2cea94..6cdda151 100644 --- a/src/help.rs +++ b/src/help.rs @@ -29,6 +29,7 @@ Ctrl+x: decompress selected file Alt+d: dragon-drop selected file M: Mark current path ': Jump to a mark +-: Move back to previous dir - Tabs - Tab: Next tab @@ -508,6 +508,19 @@ impl Tab { } } + pub fn event_back(&mut self) -> FmResult<()> { + eprintln!("event back"); + if self.history.visited.len() <= 1 { + return Ok(()); + } + self.history.visited.pop(); + let last = self.history.visited[self.history.len() - 1].clone(); + eprintln!("moving back to {:?}", last); + self.set_pathcontent(last)?; + + Ok(()) + } + fn nvim_listen_address(&self) -> Result<String, std::env::VarError> { if !self.nvim_server.is_empty() { Ok(self.nvim_server.clone()) |