diff options
author | Jeff Zhao <jeff.no.zhao@gmail.com> | 2022-09-04 16:56:38 -0400 |
---|---|---|
committer | Jeff Zhao <jeff.no.zhao@gmail.com> | 2022-09-04 16:56:38 -0400 |
commit | e76b9fb310ae9f2d5c0e8be8794aab5b1d9edd42 (patch) | |
tree | adbff6e5a3ecfcb5a9e3e3c4721e917130f62a9f /src/ui | |
parent | 2e8e1ccdd52d5cdc4b461b4e576c5afc9bffd2c3 (diff) |
show how many files are selected in the footer
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/widgets/tui_footer.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/ui/widgets/tui_footer.rs b/src/ui/widgets/tui_footer.rs index d4fbef7..458e146 100644 --- a/src/ui/widgets/tui_footer.rs +++ b/src/ui/widgets/tui_footer.rs @@ -21,13 +21,22 @@ impl<'a> TuiFooter<'a> { impl<'a> Widget for TuiFooter<'a> { fn render(self, area: Rect, buf: &mut Buffer) { + #[cfg(unix)] use std::os::unix::fs::PermissionsExt; + + let visual_mode_style = Style::default().fg(Color::Black).bg(Color::LightRed); + let mode_style = Style::default().fg(Color::Cyan); + + let selection_style = Style::default() + .fg(THEME_T.selection.fg) + .bg(THEME_T.selection.bg) + .add_modifier(THEME_T.selection.modifier); + let selected_count = self.dirlist.selected_count(); + match self.dirlist.get_index() { Some(i) if i < self.dirlist.len() => { let entry = &self.dirlist.contents[i]; - let visual_mode_style = Style::default().fg(Color::Black).bg(Color::LightRed); - let mode_style = Style::default().fg(Color::Cyan); let mode_str = unix::mode_to_string(entry.metadata.permissions_ref().mode()); let mtime_str = format::mtime_to_string(entry.metadata.modified()); @@ -54,6 +63,15 @@ impl<'a> Widget for TuiFooter<'a> { Span::raw(mtime_str), Span::raw(" UTC "), Span::raw(size_str), + Span::raw(" "), + Span::styled( + if selected_count > 0 { + format!("{} selected", selected_count) + } else { + " ".to_string() + }, + selection_style, + ), ]; if let LinkType::Symlink(target, valid) = entry.metadata.link_type() { |