diff options
| author | lukeflo | 2025-03-30 20:33:59 +0200 |
|---|---|---|
| committer | lukeflo | 2025-03-30 20:33:59 +0200 |
| commit | 5de5793e74193d5c96b75d4cd13703ace1d0104f (patch) | |
| tree | 11b7ff7b4b5073ede3de65433eabb6d9079f2818 /src/app.rs | |
| parent | da8690dc3bad0d479d5961a609450c175b530d4f (diff) | |
| download | bibiman-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/app.rs')
| -rw-r--r-- | src/app.rs | 37 |
1 files changed, 25 insertions, 12 deletions
@@ -179,7 +179,9 @@ impl App { Some(PopupKind::Help) => { self.bibiman.popup_area.popup_scroll_down(); } - Some(PopupKind::OpenRes) | Some(PopupKind::AppendToFile) => { + Some(PopupKind::OpenRes) + | Some(PopupKind::AppendToFile) + | Some(PopupKind::YankItem) => { self.bibiman.popup_area.popup_state.scroll_down_by(1) } _ => {} @@ -198,7 +200,9 @@ impl App { Some(PopupKind::Help) => { self.bibiman.popup_area.popup_scroll_up(); } - Some(PopupKind::OpenRes) | Some(PopupKind::AppendToFile) => { + Some(PopupKind::OpenRes) + | Some(PopupKind::AppendToFile) + | Some(PopupKind::YankItem) => { self.bibiman.popup_area.popup_state.scroll_up_by(1) } _ => {} @@ -256,6 +260,8 @@ impl App { } else if let Some(PopupKind::AppendToFile) = self.bibiman.popup_area.popup_kind { self.bibiman.close_popup(); + } else if let Some(PopupKind::YankItem) = self.bibiman.popup_area.popup_kind { + self.bibiman.close_popup(); } } else { self.bibiman.reset_current_list(); @@ -272,6 +278,8 @@ impl App { } else if let Some(PopupKind::AppendToFile) = self.bibiman.popup_area.popup_kind { self.bibiman.append_entry_to_file()? + } else if let Some(PopupKind::YankItem) = self.bibiman.popup_area.popup_kind { + self.bibiman.yank_entry_field()? } } } @@ -285,20 +293,25 @@ impl App { } CmdAction::YankItem => { if let CurrentArea::EntryArea = self.bibiman.current_area { - let citekey: &str = &self.bibiman.entry_table.entry_table_items[self + let idx = self .bibiman .entry_table .entry_table_state .selected() - .unwrap()] - .citekey; - - Bibiman::yank_text(citekey); - self.bibiman.popup_area.popup_message( - "Yanked citekey to clipboard: ", - citekey, // self.bibiman.get_selected_citekey(), - true, - ); + .unwrap(); + let entry = self.bibiman.entry_table.entry_table_items[idx].clone(); + let mut items = vec!["Citekey".to_owned()]; + if entry.doi_url.is_some() { + items.push("Weblink".to_owned()) + } + if entry.filepath.is_some() { + items.push("Filepath".to_owned()) + } + 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)); } } CmdAction::EditFile => { |
