diff --git a/src/commands/tui/ls.rs b/src/commands/tui/ls.rs index 0fb6f939d..612346149 100644 --- a/src/commands/tui/ls.rs +++ b/src/commands/tui/ls.rs @@ -13,7 +13,10 @@ use crate::commands::{ ls::{NodeLs, Summary}, tui::{ restore::Restore, - widgets::{popup_text, Draw, PopUpText, ProcessEvent, SelectTable, WithBlock}, + widgets::{ + popup_prompt, popup_text, Draw, PopUpPrompt, PopUpText, ProcessEvent, PromptResult, + SelectTable, WithBlock, + }, }, }; @@ -22,6 +25,7 @@ enum CurrentScreen<'a, P, S> { Snapshot, ShowHelp(PopUpText), Restore(Restore<'a, P, S>), + PromptExit(PopUpPrompt), } const INFO_TEXT: &str = @@ -190,7 +194,10 @@ impl<'a, P: ProgressBars, S: IndexedFull> Snapshot<'a, P, S> { } } Esc | Char('q') => { - return Ok(SnapshotResult::Exit); + self.current_screen = CurrentScreen::PromptExit(popup_prompt( + "exit rustic", + "do you want to exit? (y/n)".into(), + )); } Char('?') => { self.current_screen = @@ -237,6 +244,11 @@ impl<'a, P: ProgressBars, S: IndexedFull> Snapshot<'a, P, S> { self.current_screen = CurrentScreen::Snapshot; } } + CurrentScreen::PromptExit(prompt) => match prompt.input(event) { + PromptResult::Ok => return Ok(SnapshotResult::Exit), + PromptResult::Cancel => self.current_screen = CurrentScreen::Snapshot, + PromptResult::None => {} + }, } Ok(SnapshotResult::None) } @@ -263,6 +275,7 @@ impl<'a, P: ProgressBars, S: IndexedFull> Snapshot<'a, P, S> { match &mut self.current_screen { CurrentScreen::Snapshot | CurrentScreen::Restore(_) => {} CurrentScreen::ShowHelp(popup) => popup.draw(area, f), + CurrentScreen::PromptExit(popup) => popup.draw(area, f), } } } diff --git a/src/commands/tui/snapshots.rs b/src/commands/tui/snapshots.rs index d33de0948..45d2851dd 100644 --- a/src/commands/tui/snapshots.rs +++ b/src/commands/tui/snapshots.rs @@ -38,6 +38,7 @@ enum CurrentScreen<'a, P, S> { EnterSetTags(PopUpInput), EnterRemoveTags(PopUpInput), PromptWrite(PopUpPrompt), + PromptExit(PopUpPrompt), Dir(Snapshot<'a, P, S>), } @@ -715,7 +716,12 @@ impl<'a, P: ProgressBars, S: IndexedFull> Snapshots<'a, P, S> { } } else { match key.code { - Esc | Char('q') => return Ok(true), + Esc | Char('q') => { + self.current_screen = CurrentScreen::PromptExit(popup_prompt( + "exit rustic", + "do you want to exit? (y/n)".into(), + )); + } Char('f') => self.toggle_to_forget(), F(5) => self.reread()?, Enter => { @@ -842,6 +848,11 @@ impl<'a, P: ProgressBars, S: IndexedFull> Snapshots<'a, P, S> { PromptResult::Cancel => self.current_screen = CurrentScreen::Snapshots, PromptResult::None => {} }, + CurrentScreen::PromptExit(prompt) => match prompt.input(event) { + PromptResult::Ok => return Ok(true), + PromptResult::Cancel => self.current_screen = CurrentScreen::Snapshots, + PromptResult::None => {} + }, CurrentScreen::Dir(dir) => match dir.input(event)? { SnapshotResult::Exit => return Ok(true), SnapshotResult::Return => self.current_screen = CurrentScreen::Snapshots, @@ -879,7 +890,9 @@ impl<'a, P: ProgressBars, S: IndexedFull> Snapshots<'a, P, S> { | CurrentScreen::EnterAddTags(popup) | CurrentScreen::EnterSetTags(popup) | CurrentScreen::EnterRemoveTags(popup) => popup.draw(area, f), - CurrentScreen::PromptWrite(popup) => popup.draw(area, f), + CurrentScreen::PromptWrite(popup) | CurrentScreen::PromptExit(popup) => { + popup.draw(area, f); + } _ => {} } }