aboutsummaryrefslogtreecommitdiff
path: root/src/app.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.rs')
-rw-r--r--src/app.rs73
1 files changed, 51 insertions, 22 deletions
diff --git a/src/app.rs b/src/app.rs
index e0c149c..23230ba 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -300,18 +300,24 @@ impl App {
.selected()
.unwrap();
let entry = self.bibiman.entry_table.entry_table_items[idx].clone();
- let mut items = vec!["Citekey".to_owned()];
+ let mut items = vec![("Citekey: ".to_string(), entry.citekey.clone())];
if entry.doi_url.is_some() {
- items.push("Weblink".to_owned())
+ items.push(("Weblink: ".into(), entry.doi_url.unwrap().clone()))
}
if entry.filepath.is_some() {
- items.push("Filepath".to_owned())
+ items.push((
+ "Filepath: ".into(),
+ entry.filepath.unwrap()[0].clone().into_string().unwrap(),
+ ))
}
- self.bibiman.popup_area.popup_kind = Some(PopupKind::YankItem);
- self.bibiman.popup_area.popup_selection(items);
- self.bibiman.former_area = Some(FormerArea::EntryArea);
- self.bibiman.current_area = CurrentArea::PopupArea;
- self.bibiman.popup_area.popup_state.select(Some(0));
+
+ // self.bibiman.popup_area.popup_kind = Some(PopupKind::YankItem);
+ // self.bibiman.popup_area.popup_selection(items);
+ // self.bibiman.former_area = Some(FormerArea::EntryArea);
+ // self.bibiman.current_area = CurrentArea::PopupArea;
+ // self.bibiman.popup_area.popup_state.select(Some(0));
+ self.bibiman
+ .open_popup(PopupKind::YankItem, None, None, Some(items));
}
}
CmdAction::EditFile => {
@@ -328,25 +334,40 @@ impl App {
.selected()
.unwrap();
let entry = self.bibiman.entry_table.entry_table_items[idx].clone();
+ let mut items: Vec<(String, String)> = vec![];
if entry.filepath.is_some() || entry.doi_url.is_some() {
- let mut items = vec![];
if entry.doi_url.is_some() {
- items.push("Weblink (DOI/URL)".to_owned())
+ items.push((
+ "Weblink (DOI/URL): ".into(),
+ entry.doi_url.unwrap().clone(),
+ ))
}
if entry.filepath.is_some() {
- items.push("File (PDF/EPUB)".to_owned())
+ items.push((
+ "File (PDF/EPUB): ".into(),
+ entry.filepath.unwrap()[0].clone().into_string().unwrap(),
+ ))
}
- self.bibiman.popup_area.popup_kind = Some(PopupKind::OpenRes);
- self.bibiman.popup_area.popup_selection(items);
- self.bibiman.former_area = Some(FormerArea::EntryArea);
- self.bibiman.current_area = CurrentArea::PopupArea;
- self.bibiman.popup_area.popup_state.select(Some(0))
+ // self.bibiman.popup_area.popup_kind = Some(PopupKind::OpenRes);
+ // self.bibiman.popup_area.popup_selection(items);
+ // self.bibiman.former_area = Some(FormerArea::EntryArea);
+ // self.bibiman.current_area = CurrentArea::PopupArea;
+ // self.bibiman.popup_area.popup_state.select(Some(0))
+
+ self.bibiman
+ .open_popup(PopupKind::OpenRes, None, None, Some(items));
} else {
- self.bibiman.popup_area.popup_message(
- "Selected entry has no connected ressources: ",
- &entry.citekey,
- false,
- )
+ self.bibiman.open_popup(
+ PopupKind::MessageError,
+ Some("Selected entry has no connected ressources: "),
+ Some(&entry.citekey),
+ None,
+ );
+ // self.bibiman.popup_area.popup_message(
+ // "Selected entry has no connected ressources: ",
+ // &entry.citekey,
+ // false,
+ // )
}
}
}
@@ -357,7 +378,7 @@ impl App {
}
}
CmdAction::ShowHelp => {
- self.bibiman.show_help();
+ self.bibiman.open_popup(PopupKind::Help, None, None, None);
}
CmdAction::Exit => {
self.quit();
@@ -430,6 +451,14 @@ pub fn expand_home(path: &PathBuf) -> PathBuf {
}
}
+/// Convert `Vec<(&str, &str)` to `Vec<(String, String)`
+pub fn convert_to_owned_vec(mut items: Vec<(&str, &str)>) -> Vec<(String, String)> {
+ items
+ .iter_mut()
+ .map(|(msg, obj)| (msg.to_string(), obj.to_string()))
+ .collect()
+}
+
#[cfg(test)]
mod test {
use super::*;