diff options
| author | lukeflo | 2025-07-04 13:56:55 +0200 |
|---|---|---|
| committer | lukeflo | 2025-07-04 13:56:55 +0200 |
| commit | 2594cf34dcf2f04f398dab7b6ecae364eb4c7d17 (patch) | |
| tree | 71ec0170052805eeaa9682541f372a2de892defc /src/tui | |
| parent | 61b22382e0979f756538215047bafd30866ccf1e (diff) | |
| download | bibiman-2594cf34dcf2f04f398dab7b6ecae364eb4c7d17.tar.gz bibiman-2594cf34dcf2f04f398dab7b6ecae364eb4c7d17.zip | |
impl `PopupItem` enum, adapt ui: include colors
Diffstat (limited to 'src/tui')
| -rw-r--r-- | src/tui/popup.rs | 16 | ||||
| -rw-r--r-- | src/tui/ui.rs | 16 |
2 files changed, 25 insertions, 7 deletions
diff --git a/src/tui/popup.rs b/src/tui/popup.rs index 93b01c3..da44744 100644 --- a/src/tui/popup.rs +++ b/src/tui/popup.rs @@ -40,13 +40,23 @@ pub enum PopupKind { YankItem, } +#[derive(Debug)] +pub enum PopupItem { + Bibfile, + Entryfile, + Notefile, + Link, + Default, + None, +} + #[derive(Debug, Default)] pub struct PopupArea { pub is_popup: bool, pub popup_kind: Option<PopupKind>, pub popup_message: String, pub popup_scroll_pos: u16, - pub popup_list: Vec<(String, String)>, + pub popup_list: Vec<(String, String, PopupItem)>, pub popup_state: ListState, pub popup_sel_item: String, // pub add_entry_input: String, @@ -116,8 +126,8 @@ impl PopupArea { /// Opens a popup with a selectable list /// - /// The list items are passed as argument of the kind `Vec<(String, String)>`. - pub fn popup_selection(&mut self, items: Vec<(String, String)>) { + /// The list items are passed as argument of the kind `Vec<(String, String, PopupItem)>`. + pub fn popup_selection(&mut self, items: Vec<(String, String, PopupItem)>) { 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 be53f61..2c30154 100644 --- a/src/tui/ui.rs +++ b/src/tui/ui.rs @@ -17,7 +17,7 @@ use std::path::PathBuf; -use super::popup::PopupArea; +use super::popup::{PopupArea, PopupItem}; use crate::bibiman::entries::EntryTableColumn; use crate::bibiman::{CurrentArea, FormerArea}; use crate::cliargs::CLIArgs; @@ -280,9 +280,17 @@ pub fn render_popup(app: &mut App, cfg: &BibiConfig, frame: &mut Frame) { .popup_list .iter() .map( - |(mes, obj)| { + |(mes, obj, i)| { + let style = match i { + PopupItem::Bibfile => Style::new().fg(cfg.colors.entry_color), + PopupItem::Entryfile => Style::new().fg(cfg.colors.file_color), + PopupItem::Notefile => Style::new().fg(cfg.colors.note_color), + PopupItem::Link => Style::new().fg(cfg.colors.link_color), + PopupItem::Default => Style::new(), + PopupItem::None => Style::new(), + }; ListItem::from(Line::from(vec![ - Span::styled(mes, Style::new().bold()), + Span::styled(mes, style.bold()), Span::raw(obj), ])) }, // ListItem::from(mes.to_owned() + obj) @@ -333,7 +341,7 @@ pub fn render_popup(app: &mut App, cfg: &BibiConfig, frame: &mut Frame) { .popup_area .popup_list .iter() - .max_by(|(mes, obj), (m, o)| { + .max_by(|(mes, obj, _ik), (m, o, _i)| { let x = mes.chars().count() + obj.chars().count(); let y = m.chars().count() + o.chars().count(); x.cmp(&y) |
