feat: bind r to restart current countdown

This commit is contained in:
Rekai Nyangadzayi Musuka 2020-12-13 22:20:26 -06:00
parent ce566c20ce
commit 73c103b6e7
1 changed files with 6 additions and 0 deletions

View File

@ -52,6 +52,7 @@ impl Pomodoro {
self.paused = Default::default(); self.paused = Default::default();
} }
} }
KeyCode::Char('r') | KeyCode::Char('R') => self.restart(),
KeyCode::Char('q') | KeyCode::Char('Q') => break, KeyCode::Char('q') | KeyCode::Char('Q') => break,
KeyCode::Char('c') if key_event.modifiers == KeyModifiers::CONTROL => break, KeyCode::Char('c') if key_event.modifiers == KeyModifiers::CONTROL => break,
_ => {} _ => {}
@ -64,6 +65,11 @@ impl Pomodoro {
Ok(()) Ok(())
} }
fn restart(&mut self) {
self.wait_start = Some(Instant::now());
self.paused = Default::default();
}
fn notify_complete(&self) -> Result<(), Box<dyn Error>> { fn notify_complete(&self) -> Result<(), Box<dyn Error>> {
let mut toast = notify_rust::Notification::new(); let mut toast = notify_rust::Notification::new();
toast.summary("Pomodoro cycle complete!"); toast.summary("Pomodoro cycle complete!");