diff options
author | quentin konieczko <konieczko@gmail.com> | 2023-01-20 12:36:05 +0100 |
---|---|---|
committer | quentin konieczko <konieczko@gmail.com> | 2023-01-20 12:36:05 +0100 |
commit | 14d7988623d51d9a639a0a8c766a2b3cd279f7a0 (patch) | |
tree | 3a95b12ab9edee19af1961552838355e9feee310 /src | |
parent | 5d29c5bb58fb2639c5299dce4d87ec14ae0d500b (diff) |
tree: change dir with up down
Diffstat (limited to 'src')
-rw-r--r-- | src/preview.rs | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/preview.rs b/src/preview.rs index fab6ff6..da56708 100644 --- a/src/preview.rs +++ b/src/preview.rs @@ -10,6 +10,7 @@ use std::slice::Iter; use content_inspector::{inspect, ContentType}; use image::imageops::FilterType; use image::{ImageBuffer, Rgb}; +use log::info; use pdf_extract; use syntect::easy::HighlightLines; use syntect::highlighting::{Style, ThemeSet}; @@ -576,15 +577,40 @@ impl Directory { /// Select the next sibling if any. pub fn select_next_sibling(&mut self, colors: &Colors) -> FmResult<()> { - self.tree.select_next_sibling()?; - (self.selected_index, self.content) = self.tree.into_navigable_content(colors); + if self.selected_index < self.content.len() { + self.selected_index += 1; + } + // self.tree.select_next_sibling()?; + self.tree.position = self.tree.position_from_index(self.selected_index); + info!( + "index: {} position {:?}", + self.selected_index, self.tree.position + ); + self.tree.unselect_children(); + let (_, _, node) = self.tree.select_from_position()?; + self.tree.current_node = node; + let res: usize; + (res, self.content) = self.tree.into_navigable_content(colors); + info!("res {}, index {}", res, self.selected_index); Ok(()) } /// Select the previous sibling if any. pub fn select_prev_sibling(&mut self, colors: &Colors) -> FmResult<()> { - self.tree.select_prev_sibling()?; - (self.selected_index, self.content) = self.tree.into_navigable_content(colors); + if self.selected_index > 0 { + self.selected_index -= 1; + } + self.tree.position = self.tree.position_from_index(self.selected_index); + info!( + "index: {} position {:?}", + self.selected_index, self.tree.position + ); + self.tree.unselect_children(); + self.tree.select_from_position()?; + // self.tree.select_prev_sibling()?; + let res: usize; + (res, self.content) = self.tree.into_navigable_content(colors); + info!("res {}, index {}", res, self.selected_index); Ok(()) } |