From 558712ac6741c28777f69b93ccb6b4a5e0d4ff22 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Sun, 17 Nov 2024 22:21:18 +0100 Subject: implement warning message popup --- src/app.rs | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'src/app.rs') diff --git a/src/app.rs b/src/app.rs index 934a7b2..9ec1068 100644 --- a/src/app.rs +++ b/src/app.rs @@ -70,12 +70,13 @@ impl App { // Event::Key(key_event) => handle_key_events(key_event, self, &mut tui)?, // Event::Mouse(_) => {} Event::Key(key_event) => { - if let Some(PopupKind::Message) = self.bibiman.popup_area.popup_kind { + // Automatically close message popups on next keypress + if let Some(PopupKind::MessageConfirm) = self.bibiman.popup_area.popup_kind { + self.bibiman.close_popup() + } else if let Some(PopupKind::MessageError) = self.bibiman.popup_area.popup_kind + { self.bibiman.close_popup() } - // else if let Some(PopupKind::Help) = self.bibiman.popup_area.popup_kind { - // self.bibiman.go_back() - // } let command = if self.input_mode { CmdAction::Input(InputCmdAction::parse(key_event, &self.input)) } else { @@ -270,6 +271,7 @@ impl App { self.bibiman.popup_area.popup_message( "Yanked citekey to clipboard: ", citekey, // self.bibiman.get_selected_citekey(), + true, ); } } @@ -299,22 +301,15 @@ impl App { self.bibiman.former_area = Some(FormerArea::EntryArea); self.bibiman.current_area = CurrentArea::PopupArea; self.bibiman.popup_area.popup_state.select(Some(0)) + } else { + self.bibiman.popup_area.popup_message( + "Selected entry has no connected ressources: ", + &entry.citekey, + false, + ) } } } - // match ressource { - // OpenRessource::Pdf => { - // if let CurrentArea::EntryArea = self.bibiman.current_area { - // self.bibiman.open_connected_file()?; - // } - // } - // OpenRessource::WebLink => { - // if let CurrentArea::EntryArea = self.bibiman.current_area { - // self.bibiman.open_doi_url()?; - // } - // } - // OpenRessource::Note => {} - // }, CmdAction::ShowHelp => { self.bibiman.show_help(); } -- cgit v1.2.3