aboutsummaryrefslogtreecommitdiff
path: root/src/tui
diff options
context:
space:
mode:
authorlukeflo2025-06-01 14:54:38 +0200
committerlukeflo2025-06-01 14:54:38 +0200
commitd64596242ab185fffebc773ad2dcb5f1be2fccc2 (patch)
tree63c63e0d012b07ce66153ffba9dc7b13ebee0124 /src/tui
parent62580d8cc537808c34b0d9a0fe5554b4806a7aa6 (diff)
downloadbibiman-d64596242ab185fffebc773ad2dcb5f1be2fccc2.tar.gz
bibiman-d64596242ab185fffebc773ad2dcb5f1be2fccc2.zip
some fixes and test for `file_prefix` with new bool
Diffstat (limited to 'src/tui')
-rw-r--r--src/tui/popup.rs22
-rw-r--r--src/tui/ui.rs16
2 files changed, 12 insertions, 26 deletions
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<u16> = 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 {