summaryrefslogtreecommitdiffstats
path: root/src/display/components/total_bandwidth.rs
diff options
context:
space:
mode:
authorRupert Rutledge <eosis2 [at] gmail.com>2020-04-26 14:12:06 +0100
committerRupert Rutledge <eosis2 [at] gmail.com>2020-04-26 14:12:06 +0100
commit1953c8bb8b7ec3a84e1b238421c0320f9e0b3391 (patch)
tree0fe8ea191ca7175a3346e5cbeb72a35980d91211 /src/display/components/total_bandwidth.rs
parent648eb0a66906035858794977cfaa2a03a75f0210 (diff)
Working implementation of the elapsed time of the capture
This elapsed time pauses during pause sections and restarts on resumption. Ongoing: - Consider a RwLock instead of a Mutex for the elapsed time and cumulative time values, as these are only written by the UI thread and read elsewhere. - Combine the cumulative time and start times into a struct for clarity. - Separate out the elapsed time from the Bandwidth, as they are separate considerations, leading to altering the rendering of the header to write bandwidth and elapsed time separately.
Diffstat (limited to 'src/display/components/total_bandwidth.rs')
-rw-r--r--src/display/components/total_bandwidth.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/display/components/total_bandwidth.rs b/src/display/components/total_bandwidth.rs
index 80d892f..311ce67 100644
--- a/src/display/components/total_bandwidth.rs
+++ b/src/display/components/total_bandwidth.rs
@@ -8,6 +8,7 @@ use crate::display::{DisplayBandwidth, UIState};
pub struct TotalBandwidth<'a> {
pub state: &'a UIState,
+ pub elapsed_time: std::time::Duration,
pub paused: bool,
}
@@ -38,8 +39,22 @@ impl<'a> TotalBandwidth<'a> {
Style::default().fg(color).modifier(Modifier::BOLD),
)]
};
+
Paragraph::new(title_text.iter())
.alignment(Alignment::Left)
.render(frame, rect);
+
+ let elapsed_time_text = [Text::styled(
+ format!(
+ "Total Elapsed Time: {:02}:{:02}:{:02}",
+ self.elapsed_time.as_secs() / 3600,
+ (self.elapsed_time.as_secs() % 3600) / 60,
+ self.elapsed_time.as_secs() % 60
+ ),
+ Style::default().fg(Color::LightBlue).modifier(Modifier::BOLD),
+ )];
+ Paragraph::new(elapsed_time_text.iter())
+ .alignment(Alignment::Right)
+ .render(frame, rect);
}
}