diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/context/context.rs | 3 | ||||
-rw-r--r-- | src/fs/dirlist.rs | 12 | ||||
-rw-r--r-- | src/ui/widgets/tui_dirlist.rs | 6 | ||||
-rw-r--r-- | src/ui/widgets/tui_dirlist_detailed.rs | 5 |
4 files changed, 14 insertions, 12 deletions
diff --git a/src/context/context.rs b/src/context/context.rs index 00fe233..520f77c 100644 --- a/src/context/context.rs +++ b/src/context/context.rs @@ -67,9 +67,6 @@ impl JoshutoContext { pub fn set_local_state(&mut self, state: LocalStateContext) { self.local_state = Some(state); } - pub fn get_local_state(&self) -> Option<&LocalStateContext> { - self.local_state.as_ref() - } pub fn take_local_state(&mut self) -> Option<LocalStateContext> { self.local_state.take() } diff --git a/src/fs/dirlist.rs b/src/fs/dirlist.rs index df40c9d..0733f0f 100644 --- a/src/fs/dirlist.rs +++ b/src/fs/dirlist.rs @@ -1,4 +1,4 @@ -use std::slice::{Iter, IterMut}; +use std::slice::Iter; use std::{fs, path}; use crate::fs::{JoshutoDirEntry, JoshutoMetadata}; @@ -36,12 +36,8 @@ impl JoshutoDirList { self.contents.iter() } - pub fn iter_mut(&mut self) -> IterMut<JoshutoDirEntry> { - self.contents.iter_mut() - } - pub fn modified(&self) -> bool { - let metadata = std::fs::symlink_metadata(self.path.as_path()); + let metadata = std::fs::symlink_metadata(self.file_path()); match metadata { Ok(m) => match m.modified() { Ok(s) => s > self.metadata.modified, @@ -65,7 +61,7 @@ impl JoshutoDirList { pub fn reload_contents(&mut self, sort_option: &SortOption) -> std::io::Result<()> { let filter_func = sort_option.filter_func(); - let mut contents = read_dir_list(&self.path, filter_func, sort_option.show_icons)?; + let mut contents = read_dir_list(self.file_path(), filter_func, sort_option.show_icons)?; contents.sort_by(|f1, f2| sort_option.compare(f1, f2)); let contents_len = contents.len(); @@ -87,7 +83,7 @@ impl JoshutoDirList { } }; - let metadata = JoshutoMetadata::from(&self.path)?; + let metadata = JoshutoMetadata::from(self.file_path())?; self.metadata = metadata; self.contents = contents; self.index = index; diff --git a/src/ui/widgets/tui_dirlist.rs b/src/ui/widgets/tui_dirlist.rs index 60b7374..afa3258 100644 --- a/src/ui/widgets/tui_dirlist.rs +++ b/src/ui/widgets/tui_dirlist.rs @@ -40,6 +40,8 @@ impl<'a> Widget for TuiDirList<'a> { let screen_index = curr_index % area.height as usize; let area_width = area.width as usize - 1; + let space_fill = " ".repeat(area_width); + for (i, entry) in self .dirlist .iter() @@ -51,7 +53,9 @@ impl<'a> Widget for TuiDirList<'a> { let name_width = name.width(); let style = if i == screen_index { - entry.get_style().add_modifier(Modifier::REVERSED) + let s = entry.get_style().add_modifier(Modifier::REVERSED); + buf.set_string(x, y + i as u16, space_fill.as_str(), s); + s } else { entry.get_style() }; diff --git a/src/ui/widgets/tui_dirlist_detailed.rs b/src/ui/widgets/tui_dirlist_detailed.rs index 4bb63ce..b63ebdb 100644 --- a/src/ui/widgets/tui_dirlist_detailed.rs +++ b/src/ui/widgets/tui_dirlist_detailed.rs @@ -1,6 +1,7 @@ use tui::buffer::Buffer; use tui::layout::Rect; use tui::style::{Color, Modifier, Style}; +use tui::symbols::block; use tui::widgets::Widget; use unicode_width::UnicodeWidthStr; @@ -42,6 +43,8 @@ impl<'a> Widget for TuiDirListDetailed<'a> { let screen_index = curr_index % area.height as usize; let area_width = area.width as usize; + let space_fill = " ".repeat(area_width); + for (i, entry) in self .dirlist .iter() @@ -58,6 +61,8 @@ impl<'a> Widget for TuiDirListDetailed<'a> { entry.get_style() }; + buf.set_string(x, y + i as u16, space_fill.as_str(), style); + let file_type = &entry.metadata.file_type; match file_type { FileType::Directory => { |