diff options
author | Jeff Zhao <jeff.no.zhao@gmail.com> | 2021-04-25 12:57:43 -0400 |
---|---|---|
committer | Jeff Zhao <jeff.no.zhao@gmail.com> | 2021-04-25 12:58:27 -0400 |
commit | ea0ea2f394f27ab7eb92d62bf54c64fd8ab32752 (patch) | |
tree | 97210eb14ef02cb4d9cb1db1d1678ef8ab50e632 /src/ui | |
parent | 18a5b367246f04955ee64e938033437295f045ad (diff) |
add support for glob file selection
- rename some command configurations
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/widgets/tui_dirlist.rs | 13 | ||||
-rw-r--r-- | src/ui/widgets/tui_dirlist_detailed.rs | 14 | ||||
-rw-r--r-- | src/ui/widgets/tui_footer.rs | 14 |
3 files changed, 22 insertions, 19 deletions
diff --git a/src/ui/widgets/tui_dirlist.rs b/src/ui/widgets/tui_dirlist.rs index 0d88354..2618d97 100644 --- a/src/ui/widgets/tui_dirlist.rs +++ b/src/ui/widgets/tui_dirlist.rs @@ -39,16 +39,17 @@ impl<'a> Widget for TuiDirList<'a> { let skip_dist = curr_index / area.height as usize * area.height as usize; let drawing_width = area.width as usize; - for (i, entry) in self - .dirlist + + self.dirlist .iter() .skip(skip_dist) .enumerate() .take(area.height as usize) - { - let style = entry.get_style(); - print_entry(buf, entry, style, (x + 1, y + i as u16), drawing_width - 1); - } + .for_each(|(i, entry)| { + let style = entry.get_style(); + print_entry(buf, entry, style, (x + 1, y + i as u16), drawing_width - 1); + }); + { let screen_index = curr_index % area.height as usize; diff --git a/src/ui/widgets/tui_dirlist_detailed.rs b/src/ui/widgets/tui_dirlist_detailed.rs index 33f6c5f..242b992 100644 --- a/src/ui/widgets/tui_dirlist_detailed.rs +++ b/src/ui/widgets/tui_dirlist_detailed.rs @@ -40,16 +40,18 @@ impl<'a> Widget for TuiDirListDetailed<'a> { let drawing_width = area.width as usize; let skip_dist = curr_index / area.height as usize * area.height as usize; - for (i, entry) in self - .dirlist + + // draw every entry + self.dirlist .iter() .skip(skip_dist) .enumerate() .take(area.height as usize) - { - let style = entry.get_style(); - print_entry(buf, entry, style, (x + 1, y + i as u16), drawing_width - 1); - } + .for_each(|(i, entry)| { + let style = entry.get_style(); + print_entry(buf, entry, style, (x + 1, y + i as u16), drawing_width - 1); + }); + { let screen_index = curr_index % area.height as usize; diff --git a/src/ui/widgets/tui_footer.rs b/src/ui/widgets/tui_footer.rs index 1597553..aa7a821 100644 --- a/src/ui/widgets/tui_footer.rs +++ b/src/ui/widgets/tui_footer.rs @@ -8,21 +8,21 @@ use crate::fs::{FileType, JoshutoDirList}; use crate::util::format; pub struct TuiFooter<'a> { - list: &'a JoshutoDirList, + dirlist: &'a JoshutoDirList, } impl<'a> TuiFooter<'a> { - pub fn new(list: &'a JoshutoDirList) -> Self { - Self { list } + pub fn new(dirlist: &'a JoshutoDirList) -> Self { + Self { dirlist } } } impl<'a> Widget for TuiFooter<'a> { fn render(self, area: Rect, buf: &mut Buffer) { use std::os::unix::fs::PermissionsExt; - match self.list.index { - Some(i) if i < self.list.contents.len() => { - let entry = &self.list.contents[i]; + match self.dirlist.index { + Some(i) if i < self.dirlist.len() => { + let entry = &self.dirlist.contents[i]; let mode_style = Style::default().fg(Color::Cyan); let mode_str = format::mode_to_string(entry.metadata.permissions_ref().mode()); @@ -39,7 +39,7 @@ impl<'a> Widget for TuiFooter<'a> { let mut text = vec![ Span::styled(mode_str, mode_style), Span::raw(" "), - Span::raw(format!("{}/{}", i + 1, self.list.contents.len())), + Span::raw(format!("{}/{}", i + 1, self.dirlist.len())), Span::raw(" "), Span::raw(mtime_str), Span::raw(" "), |