summaryrefslogtreecommitdiffstats
path: root/src/display
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
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')
-rw-r--r--src/display/components/total_bandwidth.rs15
-rw-r--r--src/display/ui.rs3
2 files changed, 17 insertions, 1 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);
}
}
diff --git a/src/display/ui.rs b/src/display/ui.rs
index 68f133a..cd87786 100644
--- a/src/display/ui.rs
+++ b/src/display/ui.rs
@@ -79,7 +79,7 @@ where
));
}
}
- pub fn draw(&mut self, paused: bool, show_dns: bool) {
+ pub fn draw(&mut self, paused: bool, show_dns: bool, elapsed_time: std::time::Duration) {
let state = &self.state;
let children = self.get_tables_to_display();
self.terminal
@@ -87,6 +87,7 @@ where
let size = frame.size();
let total_bandwidth = TotalBandwidth {
state: &state,
+ elapsed_time,
paused,
};
let help_text = HelpText { paused, show_dns };