aboutsummaryrefslogtreecommitdiff
path: root/src/bibiman.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bibiman.rs')
-rw-r--r--src/bibiman.rs53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/bibiman.rs b/src/bibiman.rs
index e36d268..c90905f 100644
--- a/src/bibiman.rs
+++ b/src/bibiman.rs
@@ -568,6 +568,59 @@ impl Bibiman {
Ok(())
}
+ pub fn yank_entry_field(&mut self) -> Result<()> {
+ // Index of selected entry
+ let entry_idx = self.entry_table.entry_table_state.selected().unwrap();
+
+ // Index of selected popup field
+ let popup_idx = self.popup_area.popup_state.selected().unwrap();
+
+ match self.popup_area.popup_list[popup_idx]
+ .to_lowercase()
+ .as_str()
+ {
+ "citekey" => {
+ let citekey = &self.entry_table.entry_table_items[entry_idx].citekey;
+ Bibiman::yank_text(citekey);
+ self.popup_area.popup_message(
+ "Yanked citekey to clipboard: ",
+ citekey, // self.bibiman.get_selected_citekey(),
+ true,
+ );
+ }
+ "weblink" => {
+ let link = &self.entry_table.entry_table_items[entry_idx].doi_url;
+ if let Some(l) = link {
+ Bibiman::yank_text(l);
+ self.popup_area.popup_message(
+ "Yanked weblink to clipboard: ",
+ l, // self.bibiman.get_selected_link(),
+ true,
+ );
+ }
+ }
+ "filepath" => {
+ let path = self.entry_table.entry_table_items[entry_idx]
+ .filepath
+ .clone();
+ if let Some(p) = path {
+ let p = p.as_os_str().to_str();
+ if let Some(p) = p {
+ Bibiman::yank_text(p);
+ self.popup_area.popup_message(
+ "Yanked filepath to clipboard: ",
+ p, // self.bibiman.get_selected_link(),
+ true,
+ );
+ }
+ }
+ }
+ _ => {}
+ };
+
+ Ok(())
+ }
+
/// Formats a raw BibTeX entry string for better readability.
pub fn format_bibtex_entry(entry: &str, file_path: &str) -> String {
let mut formatted = String::new();