diff options
author | Jeff Zhao <jeff.no.zhao@gmail.com> | 2021-05-01 12:57:19 -0400 |
---|---|---|
committer | Jeff Zhao <jeff.no.zhao@gmail.com> | 2021-05-01 12:57:19 -0400 |
commit | 171bcbc8565f29696b7a62e96430bf46abfe7217 (patch) | |
tree | fa073d179e5c6a1ca64a89109960eac24a0bfdb2 /src/ui/widgets/tui_dirlist.rs | |
parent | 4409199315c5cc22bfba6cc63052a49dbdddfeb1 (diff) |
move theming out of entry and into utils
Diffstat (limited to 'src/ui/widgets/tui_dirlist.rs')
-rw-r--r-- | src/ui/widgets/tui_dirlist.rs | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/ui/widgets/tui_dirlist.rs b/src/ui/widgets/tui_dirlist.rs index 2618d97..77e9d82 100644 --- a/src/ui/widgets/tui_dirlist.rs +++ b/src/ui/widgets/tui_dirlist.rs @@ -5,6 +5,7 @@ use tui::widgets::Widget; use unicode_width::UnicodeWidthStr; use crate::fs::{FileType, JoshutoDirEntry, JoshutoDirList}; +use crate::util::style; const ELLIPSIS: &str = "…"; @@ -46,28 +47,26 @@ impl<'a> Widget for TuiDirList<'a> { .enumerate() .take(area.height as usize) .for_each(|(i, entry)| { - let style = entry.get_style(); + let style = style::entry_style(entry); print_entry(buf, entry, style, (x + 1, y + i as u16), drawing_width - 1); }); - { - let screen_index = curr_index % area.height as usize; + // draw selected entry in a different style + let screen_index = curr_index % area.height as usize; - let entry = self.dirlist.curr_entry_ref().unwrap(); - let style = { - let s = entry.get_style().add_modifier(Modifier::REVERSED); - let space_fill = " ".repeat(drawing_width); - buf.set_string(x, y + screen_index as u16, space_fill.as_str(), s); - s - }; - print_entry( - buf, - entry, - style, - (x + 1, y + screen_index as u16), - drawing_width - 1, - ); - } + let entry = self.dirlist.curr_entry_ref().unwrap(); + let style = style::entry_style(entry).add_modifier(Modifier::REVERSED); + + let space_fill = " ".repeat(drawing_width); + buf.set_string(x, y + screen_index as u16, space_fill.as_str(), style); + + print_entry( + buf, + entry, + style, + (x + 1, y + screen_index as u16), + drawing_width - 1, + ); } } |