aboutsummaryrefslogtreecommitdiff
path: root/src/tui/popup.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tui/popup.rs')
-rw-r--r--src/tui/popup.rs27
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;