feat(chrono): implement reset
This commit is contained in:
@@ -39,6 +39,11 @@ impl Chronometer {
|
|||||||
self.start_time = Some(Instant::now());
|
self.start_time = Some(Instant::now());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn reset(&mut self) {
|
||||||
|
self.start_time = None;
|
||||||
|
self.paused_duration = Duration::from_secs(0);
|
||||||
|
}
|
||||||
|
|
||||||
fn toggle_pause(&mut self) {
|
fn toggle_pause(&mut self) {
|
||||||
if let Some(start_time) = self.start_time {
|
if let Some(start_time) = self.start_time {
|
||||||
self.paused_duration += Instant::now().duration_since(start_time);
|
self.paused_duration += Instant::now().duration_since(start_time);
|
||||||
@@ -82,6 +87,12 @@ pub fn main_loop(config: &mut Config) -> io::Result<()> {
|
|||||||
KeyCode::Char(' ') => {
|
KeyCode::Char(' ') => {
|
||||||
chronometer.toggle_pause();
|
chronometer.toggle_pause();
|
||||||
}
|
}
|
||||||
|
// Handle reset
|
||||||
|
KeyCode::Char('r') => {
|
||||||
|
chronometer.reset();
|
||||||
|
lapses.clear();
|
||||||
|
scroll_offset = 0;
|
||||||
|
}
|
||||||
// Handle lapses
|
// Handle lapses
|
||||||
KeyCode::Char('l') => {
|
KeyCode::Char('l') => {
|
||||||
let time = chronometer.elapsed();
|
let time = chronometer.elapsed();
|
||||||
|
|||||||
Reference in New Issue
Block a user