diff options
-rw-r--r-- | src/commands/set_mode.rs | 2 | ||||
-rw-r--r-- | src/fs/dirlist.rs | 4 | ||||
-rw-r--r-- | src/ui/widgets/tui_footer.rs | 22 |
3 files changed, 23 insertions, 5 deletions
diff --git a/src/commands/set_mode.rs b/src/commands/set_mode.rs index d62d8a4..82d43e4 100644 --- a/src/commands/set_mode.rs +++ b/src/commands/set_mode.rs @@ -65,7 +65,7 @@ pub fn set_mode(context: &mut AppContext, backend: &mut AppBackend) -> JoshutoRe if let Some(stripped) = s.strip_prefix(PREFIX) { let mode = str_to_mode(stripped); if let Some(curr_list) = context.tab_context_mut().curr_tab_mut().curr_list_mut() { - if curr_list.any_selected() { + if curr_list.selected_count() > 0 { for entry in curr_list.iter_selected_mut() { let mut permissions = entry.metadata.permissions_ref().clone(); let file_mode = (permissions.mode() >> 12) << 12 | mode; diff --git a/src/fs/dirlist.rs b/src/fs/dirlist.rs index 567b8eb..1d035fa 100644 --- a/src/fs/dirlist.rs +++ b/src/fs/dirlist.rs @@ -206,8 +206,8 @@ impl JoshutoDirList { self.path.as_path() } - pub fn any_selected(&self) -> bool { - self.contents.iter().any(|e| e.is_selected()) + pub fn selected_count(&self) -> usize { + self.contents.iter().filter(|e| e.is_selected()).count() } pub fn iter_selected(&self) -> impl Iterator<Item = &JoshutoDirEntry> { 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() { |