perch/src/keys/quit.rs

24 lines
689 B
Rust

use crate::*;
impl Taggart {
pub fn quit_begin (&mut self, input: &TuiIn) {
if self.tasks.len() == 0 {
input.done()
} else {
self.mode = Some(Mode::Quit { value: 1 })
}
}
pub fn mode_quit (&mut self, event: &Event, value: u8) {
match event {
press!(Esc) => { self.mode = None },
press!(Left) => { self.mode = Some(Mode::Quit {
value: value.overflowing_sub(1).0.min(2)
}) },
press!(Right) => { self.mode = Some(Mode::Quit {
value: (value + 1) % 3
}) },
press!(Enter) => todo!(),
_ => {}
}
}
}