diff --git a/src/interactive/widgets/footer.rs b/src/interactive/widgets/footer.rs index f961412d..03b2d3a5 100644 --- a/src/interactive/widgets/footer.rs +++ b/src/interactive/widgets/footer.rs @@ -1,7 +1,4 @@ -use crate::{ - interactive::{widgets::COLOR_MARKED_DARK, EntryMarkMap}, - ByteFormat, -}; +use crate::ByteFormat; use std::borrow::Borrow; use tui::{ buffer::Buffer, @@ -13,28 +10,26 @@ use tui::{ }; pub struct Footer; -pub struct FooterProps<'a> { +pub struct FooterProps { pub total_bytes: Option, pub entries_traversed: u64, pub format: ByteFormat, - pub marked: Option<&'a EntryMarkMap>, pub message: Option, } impl Footer { - pub fn render<'a>(&self, props: impl Borrow>, area: Rect, buf: &mut Buffer) { + pub fn render(&self, props: impl Borrow, area: Rect, buf: &mut Buffer) { let FooterProps { total_bytes, entries_traversed, format, - marked, message, } = props.borrow(); let bg_color = Color::White; let text_color = Color::Black; let lines = [ - Some(Text::Raw( + Text::Raw( format!( " Total disk usage: {} Entries: {} ", match total_bytes { @@ -44,23 +39,8 @@ impl Footer { entries_traversed, ) .into(), - )), - marked.and_then(|marked| match marked.is_empty() { - true => None, - false => Some(Text::Styled( - format!( - "Marked {} items ({}) ", - marked.len(), - format.display(marked.iter().map(|(_k, v)| v.size).sum::()) - ) - .into(), - Style { - fg: COLOR_MARKED_DARK, - bg: bg_color, - modifier: Modifier::BOLD | Modifier::RAPID_BLINK, - }, - )), - }), + ) + .into(), message.as_ref().map(|m| { Text::Styled( m.into(), diff --git a/src/interactive/widgets/main.rs b/src/interactive/widgets/main.rs index 724968f5..04675f92 100644 --- a/src/interactive/widgets/main.rs +++ b/src/interactive/widgets/main.rs @@ -106,6 +106,7 @@ impl MainWindow { if let Some((mark_area, pane)) = mark_pane { let props = MarkPaneProps { border_style: mark_style, + format: display.byte_format, }; pane.render(props, mark_area, buf); } @@ -137,9 +138,8 @@ impl MainWindow { Footer.render( FooterProps { total_bytes: *total_bytes, - entries_traversed: *entries_traversed, - marked: self.mark_pane.as_ref().map(|p| p.marked()), format: display.byte_format, + entries_traversed: *entries_traversed, message: state.message.clone(), }, footer_area, diff --git a/src/interactive/widgets/mark.rs b/src/interactive/widgets/mark.rs index 7d50991b..9f945921 100644 --- a/src/interactive/widgets/mark.rs +++ b/src/interactive/widgets/mark.rs @@ -1,6 +1,6 @@ use crate::interactive::{widgets::COLOR_MARKED_LIGHT, CursorDirection, EntryMark, EntryMarkMap}; -use dua::path_of; use dua::traverse::{Tree, TreeIndex}; +use dua::{path_of, ByteFormat}; use itertools::Itertools; use std::borrow::Borrow; use termion::{event::Key, event::Key::*}; @@ -24,6 +24,7 @@ pub struct MarkPane { pub struct MarkPaneProps { pub border_style: Style, + pub format: ByteFormat, } impl MarkPane { @@ -90,10 +91,17 @@ impl MarkPane { } pub fn render(&mut self, props: impl Borrow, area: Rect, buf: &mut Buffer) { - let MarkPaneProps { border_style } = props.borrow(); + let MarkPaneProps { + border_style, + format, + } = props.borrow(); let marked: &_ = &self.marked; - let title = format!("Marked Entries: {}", marked.len()); + let title = format!( + "Marked {} items ({}) ", + marked.len(), + format.display(marked.iter().map(|(_k, v)| v.size).sum::()) + ); let block = Block::default() .title(&title) .border_style(*border_style)