Skip to content

Commit

Permalink
Add support for messages in the footer
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Thiel committed Jun 3, 2019
1 parent 6e21175 commit b255e63
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/interactive/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ impl TerminalApp {
root: traversal.root_index,
selected: None,
sorting: Default::default(),
message: Some("-> scanning <-".into()),
};
MainWindow {
traversal,
Expand All @@ -175,9 +176,10 @@ impl TerminalApp {
root,
selected,
sorting,
message: None,
},
display: display_options,
traversal: traversal,
traversal,
})
}
}
13 changes: 10 additions & 3 deletions src/interactive/widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub struct DisplayState {
pub root: TreeIndex,
pub selected: Option<TreeIndex>,
pub sorting: SortMode,
pub message: Option<String>,
}

pub struct MainWindow<'a, 'b> {
Expand All @@ -60,6 +61,7 @@ pub struct Footer {
pub total_bytes: Option<u64>,
pub entries_traversed: u64,
pub format: ByteFormat,
pub message: Option<String>,
}

impl Widget for Footer {
Expand All @@ -73,12 +75,16 @@ impl Widget for Footer {
area.x + margin,
area.y,
format!(
"Total disk usage: {} Entries: {}",
"Total disk usage: {} Entries: {} {}",
match self.total_bytes {
Some(b) => format!("{}", self.format.display(b)).trim().to_owned(),
None => "-".to_owned(),
},
self.entries_traversed
self.entries_traversed,
match self.message {
Some(ref m) => m.as_str(),
None => "",
}
),
(area.width - margin) as usize,
Style {
Expand All @@ -89,7 +95,7 @@ impl Widget for Footer {
)
}
}
impl<'a, 'b> Widget for MainWindow<'a, 'b> {
impl<'a, 'b, 'c> Widget for MainWindow<'a, 'b> {
fn draw(&mut self, area: Rect, buf: &mut Buffer) {
let Self {
traversal:
Expand Down Expand Up @@ -120,6 +126,7 @@ impl<'a, 'b> Widget for MainWindow<'a, 'b> {
total_bytes: *total_bytes,
entries_traversed: *entries_traversed,
format: display.byte_format,
message: state.message.clone(),
}
.draw(footer, buf);
}
Expand Down

0 comments on commit b255e63

Please sign in to comment.