From c0dcbcd18a3fba111885fd0eaf8ef18f71cf693a Mon Sep 17 00:00:00 2001 From: lukeflo Date: Mon, 26 May 2025 14:55:21 +0200 Subject: some more doc strings --- src/tui/popup.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/tui/popup.rs') diff --git a/src/tui/popup.rs b/src/tui/popup.rs index 2a6f18a..a0a61a4 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, } @@ -108,6 +114,14 @@ impl PopupArea { Text::from(helptext) } + /// Creates a popup message. The needed arguments are: + /// + /// - `message` as `str`: The message displayed in the popup. + /// - `object` as `str`: A possible object added to the message. E.g. the content + /// which gets copied to the clipboard. + /// - `msg_confirm` as `bool`: if `true` its a confirmation message displayed in + /// in the set `confirm_color` (default: green), if `false` its a warning + /// message displayed in the set `warn_color` (default: red). pub fn popup_message(&mut self, message: &str, object: &str, msg_confirm: bool) { if object.is_empty() { self.popup_message = message.to_owned(); @@ -122,6 +136,9 @@ impl PopupArea { self.is_popup = true; } + /// Opens a popup with a selectable list + /// + /// The list items are passed as argument of the kind `Vec`. pub fn popup_selection(&mut self, items: Vec) { self.popup_list = items; // self.popup_kind = Some(PopupKind::SelectRes); -- cgit v1.2.3 From 5ab55a263a5ae9cc5cbadf52f6000621e2552f85 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Mon, 26 May 2025 17:11:55 +0200 Subject: first steps in rewriting popups --- src/app.rs | 73 ++++++++++++++++++-------- src/bibiman.rs | 155 ++++++++++++++++++++++++++++++++++++++++++++++--------- src/tui/popup.rs | 6 +-- src/tui/ui.rs | 2 +- 4 files changed, 186 insertions(+), 50 deletions(-) (limited to 'src/tui/popup.rs') 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::*; diff --git a/src/bibiman.rs b/src/bibiman.rs index 646a078..9606c19 100644 --- a/src/bibiman.rs +++ b/src/bibiman.rs @@ -118,6 +118,7 @@ impl Bibiman { self.popup_area.popup_kind = Some(PopupKind::Help); } + /// Close all current popups and select former tab of main app pub fn close_popup(&mut self) { // Reset all popup fields to default values self.popup_area = PopupArea::default(); @@ -133,6 +134,80 @@ impl Bibiman { self.former_area = None; } + /// Open a popup + /// + /// Necessary arguments are: + /// + /// - `popup_kind`: a valid value of the `PopupKind` `enum`. This determines the + /// further behaviour of the popup. + /// - `message`: A message shown in the popup. This is needed for the `PopupKind` + /// values `MessageConfirm` and `MessageError`. If not needed, set it to `None`. + /// - `object`: An object passed as `&str` which might explain the current popup + /// action. Its not needed, but very useful. Can be used with the `PopupKind` + /// values `MessageConfirm`, `MessageError` and `YankItem`. If not needed, set it + /// to `None`. + /// - `items`: A vector of items which are needed if a selectable list is rendered. + /// The vector consists of tuples including a pair of `&str`. The second item of + /// the tuple is considered kind of an object which can be used e.g. to open + /// the given filepath etc. If not needed, set it to `None`. + pub fn open_popup( + &mut self, + popup_kind: PopupKind, + message: Option<&str>, + object: Option<&str>, + items: Option>, + ) { + if let CurrentArea::EntryArea = self.current_area { + self.former_area = Some(FormerArea::EntryArea); + } else if let CurrentArea::TagArea = self.current_area { + self.former_area = Some(FormerArea::TagArea); + } + self.popup_area.is_popup = true; + self.current_area = CurrentArea::PopupArea; + + match popup_kind { + PopupKind::Help => { + self.popup_area.popup_kind = Some(PopupKind::Help); + } + PopupKind::MessageConfirm => { + self.popup_area.popup_kind = Some(PopupKind::MessageConfirm); + if object.is_some() && message.is_some() { + self.popup_area.popup_message = message.unwrap().to_owned() + object.unwrap() + } else if object.is_none() && message.is_some() { + self.popup_area.popup_message = message.unwrap().to_owned() + } else { + return; + } + } + PopupKind::MessageError => { + self.popup_area.popup_kind = Some(PopupKind::MessageError); + if object.is_some() && message.is_some() { + self.popup_area.popup_message = message.unwrap().to_owned() + object.unwrap() + } else if object.is_none() && message.is_some() { + self.popup_area.popup_message = message.unwrap().to_owned() + } else { + return; + } + } + PopupKind::OpenRes => { + self.popup_area.popup_kind = Some(PopupKind::OpenRes); + self.popup_area.popup_selection(items.unwrap()); + self.popup_area.popup_state.select(Some(0)); + } + PopupKind::AppendToFile => { + self.popup_area.popup_kind = Some(PopupKind::AppendToFile); + } + PopupKind::AddEntry => { + self.popup_area.popup_kind = Some(PopupKind::AddEntry); + } + PopupKind::YankItem => { + self.popup_area.popup_kind = Some(PopupKind::YankItem); + self.popup_area.popup_selection(items.unwrap()); + self.popup_area.popup_state.select(Some(0)); + } + } + } + pub fn update_lists(&mut self, cfg: &BibiConfig) { self.main_biblio = BibiSetup::new(&self.main_bibfiles, cfg); self.tag_list = TagList::new(self.main_biblio.keyword_list.clone()); @@ -442,26 +517,33 @@ impl Bibiman { self.current_area = CurrentArea::PopupArea; self.popup_area.popup_state.select(Some(0)) } else { - self.popup_area - .popup_message("Can't find DOI: ", &doi_string, false); + self.open_popup( + PopupKind::MessageError, + Some("Can't find DOI: "), + Some(&doi_string), + None, + ); + // self.popup_area + // .popup_message("Can't find DOI: ", &doi_string, false); } } pub fn append_to_file(&mut self) { - let mut items = vec!["Create new file".to_owned()]; + let mut items = vec![("Create new file".to_owned(), "".to_string())]; if self.main_bibfiles.len() > 1 { for f in self.main_bibfiles.clone() { - items.push(f.to_str().unwrap().to_owned()); + items.push(("File: ".into(), f.to_str().unwrap().to_owned())); } } else { - items.push( + items.push(( + "File: ".into(), self.main_bibfiles .first() .unwrap() .to_str() .unwrap() .to_owned(), - ); + )); } self.popup_area.popup_selection(items); } @@ -482,7 +564,10 @@ impl Bibiman { .to_string(); // Check if new file or existing file was choosen - let mut file = if self.popup_area.popup_list[popup_idx].contains("Create new file") { + let mut file = if self.popup_area.popup_list[popup_idx] + .0 + .contains("Create new file") + { let citekey = PathBuf::from(&citekey); // Get path of current files let path: PathBuf = if self.main_bibfiles[0].is_file() { @@ -552,11 +637,11 @@ impl Bibiman { let popup_idx = self.popup_area.popup_state.selected().unwrap(); // Choose ressource depending an selected popup field - if self.popup_area.popup_list[popup_idx].contains("Weblink") { + if self.popup_area.popup_list[popup_idx].0.contains("Weblink") { let object = self.entry_table.entry_table_items[entry_idx].doi_url(); let url = app::prepare_weblink(object); app::open_connected_link(cfg, &url)?; - } else if self.popup_area.popup_list[popup_idx].contains("File") { + } else if self.popup_area.popup_list[popup_idx].0.contains("File") { // TODO: Selection for multiple files let object = self.entry_table.entry_table_items[entry_idx].filepath()[0]; app::open_connected_file(cfg, object)?; @@ -570,6 +655,7 @@ impl Bibiman { } pub fn yank_entry_field(&mut self) -> Result<()> { + // self.close_popup(); // Index of selected entry let entry_idx = self.entry_table.entry_table_state.selected().unwrap(); @@ -577,30 +663,45 @@ impl Bibiman { let popup_idx = self.popup_area.popup_state.selected().unwrap(); match self.popup_area.popup_list[popup_idx] + .0 .to_lowercase() .as_str() + .split_whitespace() + .next() { - "citekey" => { + Some("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, + self.open_popup( + PopupKind::MessageConfirm, + Some("Yanked citekey to clipboard: "), + Some(citekey.clone().as_str()), + None, ); + // self.popup_area.popup_message( + // "Yanked citekey to clipboard: ", + // citekey, // self.bibiman.get_selected_citekey(), + // true, + // ); } - "weblink" => { + Some("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, + self.open_popup( + PopupKind::MessageConfirm, + Some("Yanked weblink to clipboard: "), + Some(l.clone().as_str()), + None, ); + // self.popup_area.popup_message( + // "Yanked weblink to clipboard: ", + // l, // self.bibiman.get_selected_link(), + // true, + // ); } } - "filepath" => { + Some("filepath:") => { let path = self.entry_table.entry_table_items[entry_idx] .filepath .clone(); @@ -608,11 +709,17 @@ impl Bibiman { let p = p[0].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, + self.open_popup( + PopupKind::MessageConfirm, + Some("Yanked filepath to clipboard: "), + Some(p), + None, ); + // self.popup_area.popup_message( + // "Yanked filepath to clipboard: ", + // p, // self.bibiman.get_selected_link(), + // true, + // ); } } } diff --git a/src/tui/popup.rs b/src/tui/popup.rs index a0a61a4..f3f6d58 100644 --- a/src/tui/popup.rs +++ b/src/tui/popup.rs @@ -46,7 +46,7 @@ pub struct PopupArea { pub popup_kind: Option, pub popup_message: String, pub popup_scroll_pos: u16, - pub popup_list: Vec, + pub popup_list: Vec<(String, String)>, pub popup_state: ListState, pub popup_sel_item: String, // pub add_entry_input: String, @@ -138,8 +138,8 @@ impl PopupArea { /// Opens a popup with a selectable list /// - /// The list items are passed as argument of the kind `Vec`. - pub fn popup_selection(&mut self, items: Vec) { + /// 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; diff --git a/src/tui/ui.rs b/src/tui/ui.rs index 883e4df..9cbd075 100644 --- a/src/tui/ui.rs +++ b/src/tui/ui.rs @@ -279,7 +279,7 @@ pub fn render_popup(app: &mut App, cfg: &BibiConfig, frame: &mut Frame) { .popup_area .popup_list .iter() - .map(|item| ListItem::from(item.to_owned())) + .map(|(mes, obj)| ListItem::from(mes.to_owned() + obj)) .collect(); let title = if let Some(PopupKind::OpenRes) = app.bibiman.popup_area.popup_kind { -- cgit v1.2.3 From d64596242ab185fffebc773ad2dcb5f1be2fccc2 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Sun, 1 Jun 2025 14:54:38 +0200 Subject: some fixes and test for `file_prefix` with new bool --- src/app.rs | 27 +++++++++++++++------ src/bibiman/bibisetup.rs | 63 +++++++++++++++++++++++++++--------------------- src/bibiman/entries.rs | 2 ++ src/bibiman/search.rs | 5 +++- src/tui/popup.rs | 22 ----------------- src/tui/ui.rs | 16 +++++++++--- tests/test-config.toml | 2 +- 7 files changed, 75 insertions(+), 62 deletions(-) (limited to 'src/tui/popup.rs') diff --git a/src/app.rs b/src/app.rs index f751716..15cdfe3 100644 --- a/src/app.rs +++ b/src/app.rs @@ -350,7 +350,19 @@ impl App { entry.filepath.unwrap().iter().for_each(|p| { items.push(( "File (PDF/EPUB): ".into(), - p.clone().into_string().unwrap(), + // p.clone().into_string().unwrap(), + if entry.file_field && cfg.general.file_prefix.is_some() { + cfg.general + .file_prefix + .clone() + .unwrap() + .join(p) + .into_os_string() + .into_string() + .unwrap() + } else { + p.clone().into_string().unwrap() + }, )) }); } @@ -360,7 +372,7 @@ impl App { } else { self.bibiman.open_popup( PopupKind::MessageError, - Some("Selected entry has no connected ressources: "), + Some("Selected entry has no connected resources: "), Some(&entry.citekey), None, )?; @@ -389,11 +401,12 @@ pub fn open_connected_file(cfg: &BibiConfig, file: &OsStr) -> Result<()> { // Build command to execute pdf-reader. 'xdg-open' is Linux standard let cmd = &cfg.general.pdf_opener; // If necessary, replace ~ with /home dir - let file = if cfg.general.file_prefix.is_some() { - cfg.general.file_prefix.clone().unwrap().join(file) - } else { - PathBuf::from(file) - }; + // let file = if cfg.general.file_prefix.is_some() { + // cfg.general.file_prefix.clone().unwrap().join(file) + // } else { + // PathBuf::from(file) + // }; + let file = PathBuf::from(file); let file = expand_home(&file).into_os_string(); diff --git a/src/bibiman/bibisetup.rs b/src/bibiman/bibisetup.rs index 92e02fc..bf5baf5 100644 --- a/src/bibiman/bibisetup.rs +++ b/src/bibiman/bibisetup.rs @@ -53,6 +53,7 @@ pub struct BibiData { pub abstract_text: String, pub doi_url: Option, pub filepath: Option>, + pub file_field: bool, pub subtitle: Option, } @@ -115,10 +116,9 @@ impl BibiData { self.doi_url.as_ref().unwrap() } - // pub fn filepath(&self) -> &OsStr { - // self.filepath.as_ref().unwrap() - // } - + // Gets the path of the associated file for a bib entry. If one is set explicitly + // as a field, use that. If not, try to match it to one of the files found in the + // pdf_files dir. pub fn filepath(&mut self) -> Vec<&OsStr> { self.filepath .as_mut() @@ -207,19 +207,25 @@ impl BibiSetup { citekeys .iter() .enumerate() - .map(|(i, k)| BibiData { - id: i as u32, - authors: Self::get_authors(k, bibliography), - short_author: String::new(), - title: Self::get_title(k, bibliography), - year: Self::get_year(k, bibliography), - pubtype: Self::get_pubtype(k, bibliography), - keywords: Self::get_keywords(k, bibliography), - citekey: k.to_owned(), - abstract_text: Self::get_abstract(k, bibliography), - doi_url: Self::get_weblink(k, bibliography), - filepath: Self::get_filepath(k, bibliography, &mut pdf_files), - subtitle: Self::get_subtitle(k, bibliography), + .map(|(i, k)| { + let filepaths: (Option>, bool) = + { Self::get_filepath(k, bibliography, &mut pdf_files) }; + + BibiData { + id: i as u32, + authors: Self::get_authors(k, bibliography), + short_author: String::new(), + title: Self::get_title(k, bibliography), + year: Self::get_year(k, bibliography), + pubtype: Self::get_pubtype(k, bibliography), + keywords: Self::get_keywords(k, bibliography), + citekey: k.to_owned(), + abstract_text: Self::get_abstract(k, bibliography), + doi_url: Self::get_weblink(k, bibliography), + filepath: filepaths.0, + file_field: filepaths.1, + subtitle: Self::get_subtitle(k, bibliography), + } }) .collect() } @@ -354,19 +360,22 @@ impl BibiSetup { citekey: &str, biblio: &Bibliography, pdf_files: &mut Option>>, - ) -> Option> { + ) -> (Option>, bool) { if biblio.get(citekey).unwrap().file().is_ok() { - Some(vec![biblio - .get(citekey) - .unwrap() - .file() - .unwrap() - .trim() - .into()]) + ( + Some(vec![biblio + .get(citekey) + .unwrap() + .file() + .unwrap() + .trim() + .into()]), + true, + ) } else if pdf_files.is_some() { - Self::merge_filepath_or_none(&citekey, pdf_files) + (Self::merge_filepath_or_none(&citekey, pdf_files), false) } else { - None + (None, false) } } diff --git a/src/bibiman/entries.rs b/src/bibiman/entries.rs index b7c7c9b..88a1583 100644 --- a/src/bibiman/entries.rs +++ b/src/bibiman/entries.rs @@ -157,6 +157,7 @@ mod tests { abstract_text: "An abstract".to_string(), doi_url: None, filepath: None, + file_field: false, subtitle: None, }; @@ -174,6 +175,7 @@ mod tests { abstract_text: "An abstract".to_string(), doi_url: None, filepath: None, + file_field: false, subtitle: None, }; diff --git a/src/bibiman/search.rs b/src/bibiman/search.rs index 1855092..f391aed 100644 --- a/src/bibiman/search.rs +++ b/src/bibiman/search.rs @@ -117,6 +117,8 @@ pub fn search_pattern_in_file<'a>(pattern: &str, file: &'a PathBuf) -> Option<&' #[cfg(test)] mod tests { + use std::ffi::OsString; + use super::*; #[test] @@ -132,7 +134,8 @@ mod tests { citekey: "author_1999".to_string(), abstract_text: "An abstract with multiple sentences. Here is the second".to_string(), doi_url: Some("https://www.bibiman.org".to_string()), - filepath: Some("/home/file/path.pdf".to_string().into()), + filepath: Some(vec![OsString::from("/home/file/path.pdf")]), + file_field: true, subtitle: None, }; diff --git a/src/tui/popup.rs b/src/tui/popup.rs index f3f6d58..93b01c3 100644 --- a/src/tui/popup.rs +++ b/src/tui/popup.rs @@ -114,28 +114,6 @@ impl PopupArea { Text::from(helptext) } - /// Creates a popup message. The needed arguments are: - /// - /// - `message` as `str`: The message displayed in the popup. - /// - `object` as `str`: A possible object added to the message. E.g. the content - /// which gets copied to the clipboard. - /// - `msg_confirm` as `bool`: if `true` its a confirmation message displayed in - /// in the set `confirm_color` (default: green), if `false` its a warning - /// message displayed in the set `warn_color` (default: red). - 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; - } - /// Opens a popup with a selectable list /// /// The list items are passed as argument of the kind `Vec<(String, String)>`. diff --git a/src/tui/ui.rs b/src/tui/ui.rs index a998bc7..2126135 100644 --- a/src/tui/ui.rs +++ b/src/tui/ui.rs @@ -320,16 +320,24 @@ pub fn render_popup(app: &mut App, cfg: &BibiConfig, frame: &mut Frame) { // To find the longest line, we need to collect the chars of every item // and add. - let list_widths: Vec = app + let list_widths = app .bibiman .popup_area .popup_list .iter() - .map(|(m, o)| m.chars().count() as u16 + o.chars().count() as u16) - .collect(); + .max_by(|(mes, obj), (m, o)| { + let x = mes.chars().count() + obj.chars().count(); + let y = m.chars().count() + o.chars().count(); + x.cmp(&y) + }) + .unwrap(); + // .map(|(m, o)| m.chars().count() as u16 + o.chars().count() as u16) + // .collect(); // Now take the max number for the width of the popup - let max_item = list_widths.iter().max().unwrap().to_owned(); + // let max_item = list_widths.iter().max().unwrap().to_owned(); + let max_item = + list_widths.0.chars().count() as u16 + list_widths.1.chars().count() as u16; // Check if the popup would exceed the terminal frame width let popup_width = if max_item + 2 > frame.area().width - 2 { diff --git a/tests/test-config.toml b/tests/test-config.toml index 1b60acd..4e4f8c5 100644 --- a/tests/test-config.toml +++ b/tests/test-config.toml @@ -14,7 +14,7 @@ bibfiles = [ "tests/biblatex-test.bib" ] ## Prefix which is prepended to the filepath from the `file` field ## Use absolute paths (~ for HOME works). Otherwise, loading might not work. -# file_prefix = "/some/path/prefix" +file_prefix = "/some/path/prefix" ## Path to folder (with subfolders) containing PDF files with the basename ## of the format "citekey.pdf". Other PDF basenames are not accepted. -- cgit v1.2.3