mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-08 10:36:42 +01:00
stub help modal; cleanup
This commit is contained in:
parent
b157a87647
commit
4619d0ea76
9 changed files with 78 additions and 68 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use crate::*;
|
||||
|
||||
impl Taggart {
|
||||
pub fn mode_edit (&mut self, event: &Event) {
|
||||
pub fn handle_edit (&mut self, event: &Event) {
|
||||
match event {
|
||||
press!(Char(c)) => self.edit_insert(*c),
|
||||
press!(Shift-Char(c)) => self.edit_insert(c.to_uppercase().next().unwrap()),
|
||||
|
|
|
|||
13
src/keys/help.rs
Normal file
13
src/keys/help.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
use crate::*;
|
||||
|
||||
impl Taggart {
|
||||
pub fn handle_help (&mut self, event: &Event, _page: u8) {
|
||||
match event {
|
||||
press!(Esc) => { self.mode = None },
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
pub fn help_begin (&mut self) {
|
||||
self.mode = Some(Mode::Help { page: 0 })
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +1,16 @@
|
|||
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, input: &TuiIn, event: &Event, value: u8) {
|
||||
match event {
|
||||
pub fn handle_quit (&mut self, input: &TuiIn, choice: u8) {
|
||||
match &*input.event() {
|
||||
press!(Esc) => { self.mode = None },
|
||||
press!(Left) => { self.mode = Some(Mode::Quit {
|
||||
value: value.overflowing_sub(1).0.min(2)
|
||||
choice: choice.overflowing_sub(1).0.min(2)
|
||||
}) },
|
||||
press!(Right) => { self.mode = Some(Mode::Quit {
|
||||
value: (value + 1) % 3
|
||||
choice: (choice + 1) % 3
|
||||
}) },
|
||||
press!(Enter) => match value {
|
||||
press!(Enter) => match choice {
|
||||
0 => { input.done() },
|
||||
1 => { self.mode = None },
|
||||
2 => todo!(),
|
||||
|
|
@ -26,4 +19,11 @@ impl Taggart {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
pub fn quit_begin (&mut self, input: &TuiIn) {
|
||||
if self.tasks.len() == 0 {
|
||||
input.done()
|
||||
} else {
|
||||
self.mode = Some(Mode::Quit { choice: 1 })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,16 @@
|
|||
use crate::*;
|
||||
|
||||
impl Taggart {
|
||||
pub fn save_begin (&mut self) {
|
||||
if self.tasks.len() > 0 {
|
||||
self.mode = Some(Mode::Save { value: 1 })
|
||||
}
|
||||
}
|
||||
pub fn mode_save (&mut self, event: &Event, value: u8) {
|
||||
pub fn handle_save (&mut self, event: &Event, choice: u8) {
|
||||
match event {
|
||||
press!(Esc) => { self.mode = None }
|
||||
press!(Left) => { self.mode = Some(Mode::Save {
|
||||
value: value.overflowing_sub(1).0.min(2)
|
||||
choice: choice.overflowing_sub(1).0.min(2)
|
||||
}) },
|
||||
press!(Right) => { self.mode = Some(Mode::Save {
|
||||
value: (value + 1) % 3
|
||||
choice: (choice + 1) % 3
|
||||
}) },
|
||||
press!(Enter) => match value {
|
||||
press!(Enter) => match choice {
|
||||
0 => { self.tasks = vec![]; self.mode = None; },
|
||||
1 => { self.mode = None },
|
||||
2 => todo!(),
|
||||
|
|
@ -24,4 +19,9 @@ impl Taggart {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
pub fn save_begin (&mut self) {
|
||||
if self.tasks.len() > 0 {
|
||||
self.mode = Some(Mode::Save { choice: 1 })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue