mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-06 17:46:42 +01:00
allow selecting button in modal
This commit is contained in:
parent
2e072cb51c
commit
1d1fc483ba
4 changed files with 37 additions and 15 deletions
24
src/view.rs
24
src/view.rs
|
|
@ -24,10 +24,14 @@ impl Content<TuiOut> for Taggart {
|
|||
Color::Rgb(48,48,48),
|
||||
Modifier::DIM
|
||||
);
|
||||
let message = Bsp::s(format!("Save {} change(s)?", self.tasks.len()),
|
||||
Bsp::s("",
|
||||
Bsp::e(" Clear changes ", Bsp::e(" Continue editing ", " Save "))));
|
||||
let modal = Self::modal(message);
|
||||
let options = [
|
||||
if value == 0 { "[ Clear changes ]" } else { " Clear changes " },
|
||||
if value == 1 { "[ Continue editing ]" } else { " Continue editing " },
|
||||
if value == 2 { "[ Write and continue ]" } else { " Write and continue " },
|
||||
];
|
||||
let modal = Self::modal(Bsp::s(
|
||||
format!("Save {} change(s)?", self.tasks.len()),
|
||||
Bsp::s("", Bsp::e(options[0], Bsp::e(options[1], options[2])))));
|
||||
Content::render(&modal, to)
|
||||
},
|
||||
Some(Mode::Quit { value }) => {
|
||||
|
|
@ -36,10 +40,14 @@ impl Content<TuiOut> for Taggart {
|
|||
Color::Rgb(48,48,48),
|
||||
Modifier::DIM
|
||||
);
|
||||
let message = Bsp::s(format!("Save {} change(s) before exiting?", self.tasks.len()),
|
||||
Bsp::s("",
|
||||
Bsp::e(" Exit without saving ", Bsp::e(" Cancel ", " Save and exit "))));
|
||||
let modal = Self::modal(message);
|
||||
let options = [
|
||||
if value == 0 { "[ Exit without saving ]" } else { " Exit without saving " },
|
||||
if value == 1 { "[ Cancel ]" } else { " Cancel " },
|
||||
if value == 2 { "[ Write and exit ]" } else { " Write and exit " },
|
||||
];
|
||||
let modal = Self::modal(Bsp::s(
|
||||
format!("Save {} change(s) before exiting?", self.tasks.len()),
|
||||
Bsp::s("", Bsp::e(options[0], Bsp::e(options[1], options[2])))));
|
||||
Content::render(&modal, to)
|
||||
},
|
||||
_ => {},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue