aboutsummaryrefslogtreecommitdiff
path: root/src/bibiman.rs
diff options
context:
space:
mode:
authorlukeflo2025-03-30 20:33:59 +0200
committerlukeflo2025-03-30 20:33:59 +0200
commit5de5793e74193d5c96b75d4cd13703ace1d0104f (patch)
tree11b7ff7b4b5073ede3de65433eabb6d9079f2818 /src/bibiman.rs
parentda8690dc3bad0d479d5961a609450c175b530d4f (diff)
downloadbibiman-5de5793e74193d5c96b75d4cd13703ace1d0104f.tar.gz
bibiman-5de5793e74193d5c96b75d4cd13703ace1d0104f.zip
yank multiple fields
+ open a selection menu when pressing `y` + select a field: citekey, weblink, filepath + copy value of selected field to clipboard
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();