summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRupert Rutledge <eosis2 [at] gmail.com>2020-05-16 17:55:46 +0100
committerRupert Rutledge <eosis2 [at] gmail.com>2020-05-16 17:55:46 +0100
commit24934963d282e854b901c073228589eaf75bdde3 (patch)
treea976b3c5fb783f01553ea60a3885da20cc38980b
parentbc0db53b4e0bd01520ae7631874901168cc5530a (diff)
Fix issue of duration being shown on non -t invocations
-rw-r--r--src/display/components/total_bandwidth.rs35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/display/components/total_bandwidth.rs b/src/display/components/total_bandwidth.rs
index 5f3a3f7..e38d5e4 100644
--- a/src/display/components/total_bandwidth.rs
+++ b/src/display/components/total_bandwidth.rs
@@ -17,8 +17,13 @@ pub struct HeaderDetails<'a> {
impl<'a> HeaderDetails<'a> {
pub fn render(&self, frame: &mut Frame<impl Backend>, rect: Rect) {
let bandwidth = self.bandwidth_string();
- let elapsed_time = self.elapsed_time_string();
- let print_elapsed_time = bandwidth.len() + elapsed_time.len() + 1 <= rect.width as usize;
+ let mut elapsed_time = None;
+ let mut print_elapsed_time = false;
+ if self.state.cumulative_mode {
+ elapsed_time = Some(self.elapsed_time_string());
+ print_elapsed_time =
+ bandwidth.len() + elapsed_time.as_ref().unwrap().len() + 1 <= rect.width as usize;
+ }
let color = if self.paused {
Color::Yellow
@@ -27,15 +32,21 @@ impl<'a> HeaderDetails<'a> {
};
if print_elapsed_time {
- self.render_elapsed_time(frame, rect, &color);
+ self.render_elapsed_time(frame, rect, elapsed_time.as_ref().unwrap(), &color);
}
- self.render_bandwidth(frame, rect, &color);
+ self.render_bandwidth(frame, rect, &bandwidth, &color);
}
- fn render_bandwidth(&self, frame: &mut Frame<impl Backend>, rect: Rect, color: &Color) {
+ fn render_bandwidth(
+ &self,
+ frame: &mut Frame<impl Backend>,
+ rect: Rect,
+ bandwidth: &String,
+ color: &Color,
+ ) {
let bandwidth_text = {
[Text::styled(
- self.bandwidth_string(),
+ bandwidth,
Style::default().fg(*color).modifier(Modifier::BOLD),
)]
};
@@ -61,9 +72,15 @@ impl<'a> HeaderDetails<'a> {
)
}
- fn render_elapsed_time(&self, frame: &mut Frame<impl Backend>, rect: Rect, color: &Color) {
+ fn render_elapsed_time(
+ &self,
+ frame: &mut Frame<impl Backend>,
+ rect: Rect,
+ elapsed_time: &String,
+ color: &Color,
+ ) {
let elapsed_time_text = [Text::styled(
- self.elapsed_time_string(),
+ elapsed_time,
Style::default().fg(*color).modifier(Modifier::BOLD),
)];
Paragraph::new(elapsed_time_text.iter())
@@ -75,7 +92,7 @@ impl<'a> HeaderDetails<'a> {
match self.elapsed_time.as_secs() / SECONDS_IN_DAY {
0 => "".to_string(),
1 => "1 day, ".to_string(),
- n => format!("{} days, ", n)
+ n => format!("{} days, ", n),
}
}