diff options
author | qkzk <qu3nt1n@gmail.com> | 2024-03-03 16:39:14 +0100 |
---|---|---|
committer | qkzk <qu3nt1n@gmail.com> | 2024-03-03 16:39:14 +0100 |
commit | a81a293dbe942edc0cdd3a0258681922882a493d (patch) | |
tree | 3c4b2f0b15f0db748bd3e87bc1c273cc6abdac07 | |
parent | da996764d9b4cb220c5564f403359cfaed93e1ac (diff) |
preview mark, shortcut & history content in second pane while navigating
-rw-r--r-- | development.md | 4 | ||||
-rw-r--r-- | src/app/status.rs | 43 | ||||
-rw-r--r-- | src/modes/edit/history.rs | 1 |
3 files changed, 36 insertions, 12 deletions
diff --git a/development.md b/development.md index 9e0707c..36dc272 100644 --- a/development.md +++ b/development.md @@ -875,6 +875,7 @@ New view: Tree ! Toggle with 't', fold with 'z'. Navigate normally. - Search as you type: do / then type a pattern and you will jump to the match. - replace `tar tvf` by `bsdtar -v --list --file`. Which can preview .deb and .rpm files - preview torrent files with `transmission-show` +- preview mark, shortcut & history content in second pane while navigating #### Changelog @@ -946,13 +947,14 @@ New view: Tree ! Toggle with 't', fold with 'z'. Navigate normally. - [x] search as you type - [x] replace `tar tvf` by `bsdtar -v --list --file`. Which can preview .deb and .rpm files - [x] torrent with `transmission-show` +- [x] preview mark, shortcut & history content in second pane while navigating +- [ ] FIX: `q` while second window should exit the menu ## TODO - [ ] rclone - [ ] FIX: leaving flagged file should reset the window correctly. Can't reproduce... - [ ] move as you type in Alt+g -- [ ] preview mark & shortcut content in second pane while navigating - [ ] use the new mpsc event parser to read commands from stdin or RPC - [ ] [opener file kind](./src/io/opener.rs): move associations to a config file - [ ] open a shell while hiding fm, restore after leaving diff --git a/src/app/status.rs b/src/app/status.rs index b6b92b5..5554145 100644 --- a/src/app/status.rs +++ b/src/app/status.rs @@ -466,22 +466,45 @@ impl Status { fn set_second_pane_for_preview(&mut self) -> Result<()> { self.tabs[1].set_display_mode(Display::Preview); self.tabs[1].edit_mode = Edit::Nothing; - let users = &self.tabs[0].users; - let fileinfo = match self.tabs[0].display_mode { - Display::Flagged => { - let Some(path) = self.menu.flagged.selected() else { - self.tabs[1].preview = Preview::empty(); - return Ok(()); - }; - FileInfo::new(path, users)? - } - _ => self.tabs[0].current_file()?, + let Ok(fileinfo) = self.get_correct_fileinfo_for_preview() else { + return Ok(()); }; + let left_tab = &self.tabs[0]; + let users = &left_tab.users; self.tabs[1].preview = Preview::new(&fileinfo, users).unwrap_or_default(); self.tabs[1].window.reset(self.tabs[1].preview.len()); Ok(()) } + fn get_correct_fileinfo_for_preview(&mut self) -> Result<FileInfo> { + let left_tab = &self.tabs[0]; + let users = &left_tab.users; + match self.focus { + Focus::LeftMenu if matches!(left_tab.edit_mode, Edit::Navigate(Navigate::Marks(_))) => { + let (_, mark_path) = &self.menu.marks.content()[self.menu.marks.index()]; + FileInfo::new(mark_path, users) + } + Focus::LeftMenu if matches!(left_tab.edit_mode, Edit::Navigate(Navigate::Shortcut)) => { + let shortcut_path = &self.menu.shortcut.content()[self.menu.shortcut.index()]; + FileInfo::new(shortcut_path, users) + } + Focus::LeftMenu if matches!(left_tab.edit_mode, Edit::Navigate(Navigate::History)) => { + let (history_path, _) = &left_tab.history.content()[left_tab.history.index()]; + FileInfo::new(history_path, users) + } + _ => match left_tab.display_mode { + Display::Flagged => { + let Some(path) = self.menu.flagged.selected() else { + self.tabs[1].preview = Preview::empty(); + return Err(anyhow!("No fileinfo to preview")); + }; + FileInfo::new(path, users) + } + _ => left_tab.current_file(), + }, + } + } + /// Set an edit mode for the tab at `index`. Refresh the view. pub fn set_edit_mode(&mut self, index: usize, edit_mode: Edit) -> Result<()> { if index > 1 { diff --git a/src/modes/edit/history.rs b/src/modes/edit/history.rs index 99aafe5..48be359 100644 --- a/src/modes/edit/history.rs +++ b/src/modes/edit/history.rs @@ -55,4 +55,3 @@ impl History { impl_selectable!(History); impl_content!(DoublePB, History); -// impl_selectable_content!(DoublePB, History); |