From 73c103b6e7cb0223e21a8c7f464f95c791cca63c Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Sun, 13 Dec 2020 22:20:26 -0600 Subject: [PATCH] feat: bind r to restart current countdown --- src/pomodoro.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pomodoro.rs b/src/pomodoro.rs index 0194a02..cf065bf 100644 --- a/src/pomodoro.rs +++ b/src/pomodoro.rs @@ -52,6 +52,7 @@ impl Pomodoro { self.paused = Default::default(); } } + KeyCode::Char('r') | KeyCode::Char('R') => self.restart(), KeyCode::Char('q') | KeyCode::Char('Q') => break, KeyCode::Char('c') if key_event.modifiers == KeyModifiers::CONTROL => break, _ => {} @@ -64,6 +65,11 @@ impl Pomodoro { Ok(()) } + fn restart(&mut self) { + self.wait_start = Some(Instant::now()); + self.paused = Default::default(); + } + fn notify_complete(&self) -> Result<(), Box> { let mut toast = notify_rust::Notification::new(); toast.summary("Pomodoro cycle complete!");