W45: Marked-file total size in panel footer

Append a 'Σ <size>' indicator to the panel footer when files
are marked, using the info colour. Sums the stat.size of every
entry whose name is in the marked set (directories included).
Helps users see the combined size before bulk operations like
copy/move/delete.

Tests: 1405 pass, zero warnings.
This commit is contained in:
2026-07-07 08:11:36 +03:00
parent 78ff5b5c4c
commit ba05902883
@@ -559,6 +559,24 @@ impl FileManager {
Style::default().fg(self.theme.accent).bg(panel_bg),
));
}
// Marked-file total size: sum of stat.size for every
// entry whose name is in the marked set. Shown only when
// at least one file is marked. Directories are counted.
if panel.marked_count() > 0 {
let marked_set: std::collections::HashSet<String> =
panel.marked_names().into_iter().collect();
let total: u64 = panel
.entries()
.iter()
.filter(|e| marked_set.contains(&e.name))
.map(|e| e.stat.size)
.sum();
footer_spans.push(Span::raw(" "));
footer_spans.push(Span::styled(
format!("Σ {}", format_utils::format_size(total)),
Style::default().fg(self.theme.info).bg(panel_bg),
));
}
let total_w = footer_spans.iter().map(|s| s.width() as u16).sum::<u16>();
if total_w < inner.width {
let pad = inner.width - total_w;