diff options
| author | lukeflo | 2024-11-11 22:13:32 +0100 |
|---|---|---|
| committer | lukeflo | 2024-11-14 09:35:45 +0100 |
| commit | 761ce14125f0e4ecffbfaf3bf82b4b406f5aa769 (patch) | |
| tree | f78f106d93bfb2466f1d7785b3080eb4b0e333d9 /src/bibiman.rs | |
| parent | 45d85162e455db37f9263088a7703d614969b373 (diff) | |
| download | bibiman-761ce14125f0e4ecffbfaf3bf82b4b406f5aa769.tar.gz bibiman-761ce14125f0e4ecffbfaf3bf82b4b406f5aa769.zip | |
impl popup for keybindings/messages
Diffstat (limited to 'src/bibiman.rs')
| -rw-r--r-- | src/bibiman.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/bibiman.rs b/src/bibiman.rs index a573ee7..f3d9272 100644 --- a/src/bibiman.rs +++ b/src/bibiman.rs @@ -18,6 +18,7 @@ use crate::bibiman::entries::EntryTableColumn; use crate::bibiman::{bibisetup::*, search::BibiSearch}; use crate::cliargs::CLIArgs; +use crate::tui::popup::{PopupArea, PopupKind}; use crate::tui::Tui; use crate::{bibiman::entries::EntryTable, bibiman::keywords::TagList}; use arboard::Clipboard; @@ -40,6 +41,7 @@ pub enum CurrentArea { EntryArea, TagArea, SearchArea, + PopupArea, } // Check which area was active when popup set active @@ -69,6 +71,8 @@ pub struct Bibiman { pub current_area: CurrentArea, // mode for popup window pub former_area: Option<FormerArea>, + // active popup + pub popup_area: PopupArea, } impl Bibiman { @@ -89,9 +93,33 @@ impl Bibiman { scroll_info: 0, current_area, former_area: None, + popup_area: PopupArea::default(), }) } + pub fn show_help(&mut self) { + if let CurrentArea::EntryArea = self.current_area { + self.former_area = Some(FormerArea::EntryArea); + } else if let CurrentArea::TagArea = self.current_area { + self.former_area = Some(FormerArea::TagArea); + } + self.popup_area.is_popup = true; + self.current_area = CurrentArea::PopupArea; + self.popup_area.popup_kind = Some(PopupKind::Help); + } + + pub fn go_back(&mut self) { + if let CurrentArea::PopupArea = self.current_area { + self.popup_area.is_popup = false; + self.popup_area.popup_kind = None; + if let Some(FormerArea::EntryArea) = self.former_area { + self.current_area = CurrentArea::EntryArea + } else if let Some(FormerArea::TagArea) = self.former_area { + self.current_area = CurrentArea::TagArea + } + }; + } + pub fn update_lists(&mut self) { self.main_biblio = BibiSetup::new(&self.main_bibfile); self.tag_list = TagList::new(self.main_biblio.keyword_list.clone()); |
