diff options
| author | lukeflo | 2025-06-03 17:38:49 +0200 |
|---|---|---|
| committer | lukeflo | 2025-06-03 17:38:49 +0200 |
| commit | d7236320fde1994fa38c5d8b85c9f81f1559fff4 (patch) | |
| tree | a3ff2fe49886d6bd33f0c6627d07669b377cbd22 /src/tui/popup.rs | |
| parent | 1dcb24c381990bdead5fa3df2fb95d74b176a8c1 (diff) | |
| parent | 201aecebcd7c85127df9c43da01fdafc3465e53e (diff) | |
| download | bibiman-d7236320fde1994fa38c5d8b85c9f81f1559fff4.tar.gz bibiman-d7236320fde1994fa38c5d8b85c9f81f1559fff4.zip | |
Merge pull request 'pdf-by-filename' (#28) from pdf-by-filename-#27 into main
Implemented PDF dir:
+ now you can set a `pdf_path` variable in the config and throuch the CLI flag `--pdf-dir`
+ this dir will be searched recursivley for PDF files which mathc a citekey from the used `.bib` files and connects with them
+ every entry can have multiple PDFs with the citekey-basename in different subdirs
+ the bibfile itself will not be altered
+ additionally, i rewrote the internal popup code for easier contribution
Diffstat (limited to 'src/tui/popup.rs')
| -rw-r--r-- | src/tui/popup.rs | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/tui/popup.rs b/src/tui/popup.rs index 2a6f18a..93b01c3 100644 --- a/src/tui/popup.rs +++ b/src/tui/popup.rs @@ -26,11 +26,17 @@ use crate::config::BibiConfig; #[derive(Debug)] pub enum PopupKind { Help, + /// use for a confirmation message MessageConfirm, + /// use for a warning message MessageError, + /// open a resource connected to the entry OpenRes, + /// select file to append entry to AppendToFile, + /// append entry to a bibfile (selected in `AppendToFile` popup) AddEntry, + /// select an item of the current entry to yank to clipboard YankItem, } @@ -40,7 +46,7 @@ pub struct PopupArea { pub popup_kind: Option<PopupKind>, pub popup_message: String, pub popup_scroll_pos: u16, - pub popup_list: Vec<String>, + pub popup_list: Vec<(String, String)>, pub popup_state: ListState, pub popup_sel_item: String, // pub add_entry_input: String, @@ -108,21 +114,10 @@ impl PopupArea { Text::from(helptext) } - pub fn popup_message(&mut self, message: &str, object: &str, msg_confirm: bool) { - if object.is_empty() { - self.popup_message = message.to_owned(); - } else { - self.popup_message = message.to_owned() + object; //format!("{} \"{}\"", message, object); - } - if msg_confirm { - self.popup_kind = Some(PopupKind::MessageConfirm); - } else { - self.popup_kind = Some(PopupKind::MessageError) - } - self.is_popup = true; - } - - pub fn popup_selection(&mut self, items: Vec<String>) { + /// Opens a popup with a selectable list + /// + /// The list items are passed as argument of the kind `Vec<(String, String)>`. + pub fn popup_selection(&mut self, items: Vec<(String, String)>) { self.popup_list = items; // self.popup_kind = Some(PopupKind::SelectRes); self.is_popup = true; |
