From 4ca8417812db530cd157fe5b1de70f6e74e9c400 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Mon, 30 Jun 2025 12:54:01 +0200 Subject: UI implementation of notes --- src/bibiman/bibisetup.rs | 1 + src/config.rs | 18 ++++++++++++++++++ src/tui/ui.rs | 28 +++++++++++++++++++--------- 3 files changed, 38 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/bibiman/bibisetup.rs b/src/bibiman/bibisetup.rs index e79960c..61144a1 100644 --- a/src/bibiman/bibisetup.rs +++ b/src/bibiman/bibisetup.rs @@ -76,6 +76,7 @@ impl BibiData { }; vec![ + "", { if self.short_author.is_empty() { self.authors() diff --git a/src/config.rs b/src/config.rs index 6abcfd1..c30d8d1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -113,6 +113,12 @@ pub struct Colors { pub bar_bg_color: Color, pub popup_bg_color: Color, pub selected_row_bg_color: Color, + pub note_color: Color, + pub file_color: Color, + pub link_color: Color, + pub author_color: Color, + pub title_color: Color, + pub year_color: Color, } impl Default for BibiConfig { @@ -187,6 +193,12 @@ impl BibiConfig { bar_bg_color: Color::Indexed(235), popup_bg_color: Color::Indexed(234), selected_row_bg_color: Color::Indexed(237), + note_color: Color::Indexed(123), + file_color: Color::Indexed(209), + link_color: Color::Indexed(33), + author_color: Color::Indexed(38), + title_color: Color::Indexed(37), + year_color: Color::Indexed(135), } } @@ -203,6 +215,12 @@ impl BibiConfig { confirm_color: Color::Indexed(22), warn_color: Color::Indexed(124), selected_row_bg_color: Color::Indexed(107), + note_color: Color::Indexed(123), + file_color: Color::Indexed(209), + link_color: Color::Indexed(27), + author_color: Color::Indexed(38), + title_color: Color::Indexed(37), + year_color: Color::Indexed(135), } } diff --git a/src/tui/ui.rs b/src/tui/ui.rs index ebebe4c..95b9f2c 100644 --- a/src/tui/ui.rs +++ b/src/tui/ui.rs @@ -580,6 +580,7 @@ pub fn render_entrytable(app: &mut App, cfg: &BibiConfig, frame: &mut Frame, rec .bg(cfg.colors.bar_bg_color); let header = Row::new(vec![ + Cell::from(Line::from("")).bg(cfg.colors.bar_bg_color), Cell::from( Line::from(vec![{ Span::raw("Author") }, { if let Some(EntryTableColumn::Authors) = @@ -725,6 +726,7 @@ pub fn render_entrytable(app: &mut App, cfg: &BibiConfig, frame: &mut Frame, rec let entry_table = Table::new( rows, [ + Constraint::Length(4), Constraint::Percentage(20), Constraint::Fill(1), Constraint::Length( @@ -793,7 +795,10 @@ pub fn render_selected_item(app: &mut App, cfg: &BibiConfig, frame: &mut Frame, lines.push(Line::from(vec![ Span::styled("Authors: ", style_value), // Span::styled(cur_entry.authors.clone(), Style::new().green()), - Span::styled(cur_entry.authors(), Style::new().fg(cfg.colors.info_color)), + Span::styled( + cur_entry.authors(), + Style::new().fg(cfg.colors.author_color), + ), ])); if cur_entry.subtitle.is_some() { lines.push(Line::from(vec![ @@ -801,19 +806,19 @@ pub fn render_selected_item(app: &mut App, cfg: &BibiConfig, frame: &mut Frame, Span::styled( cur_entry.title(), Style::new() - .fg(cfg.colors.entry_color) + .fg(cfg.colors.title_color) .add_modifier(Modifier::ITALIC), ), Span::styled( ": ", Style::new() - .fg(cfg.colors.entry_color) + .fg(cfg.colors.title_color) .add_modifier(Modifier::ITALIC), ), Span::styled( cur_entry.subtitle(), Style::new() - .fg(cfg.colors.entry_color) + .fg(cfg.colors.title_color) .add_modifier(Modifier::ITALIC), ), ])); @@ -823,14 +828,14 @@ pub fn render_selected_item(app: &mut App, cfg: &BibiConfig, frame: &mut Frame, Span::styled( cur_entry.title(), Style::new() - .fg(cfg.colors.entry_color) + .fg(cfg.colors.title_color) .add_modifier(Modifier::ITALIC), ), ])); } lines.push(Line::from(vec![ Span::styled("Year: ", style_value), - Span::styled(cur_entry.year(), Style::new().fg(cfg.colors.keyword_color)), + Span::styled(cur_entry.year(), Style::new().fg(cfg.colors.year_color)), ])); // Render keywords in info box in Markdown code style if !cur_entry.keywords.is_empty() { @@ -873,7 +878,7 @@ pub fn render_selected_item(app: &mut App, cfg: &BibiConfig, frame: &mut Frame, Span::styled("DOI/URL: ", style_value), Span::styled( cur_entry.doi_url(), - Style::new().fg(cfg.colors.main_text_color).underlined(), + Style::new().fg(cfg.colors.link_color).underlined(), ), ])); } @@ -882,7 +887,7 @@ pub fn render_selected_item(app: &mut App, cfg: &BibiConfig, frame: &mut Frame, Span::styled("File: ", style_value), Span::styled( p.iter().map(|f| f.to_str().unwrap()).join("; "), - Style::new().fg(cfg.colors.main_text_color), + Style::new().fg(cfg.colors.file_color), ), ])); } @@ -913,7 +918,12 @@ pub fn render_selected_item(app: &mut App, cfg: &BibiConfig, frame: &mut Frame, // We show the list item's info under the list in this paragraph let block = Block::bordered() - .title(Line::raw(" Entry Information ").centered().bold()) + .title( + Line::raw(" Entry Information ") + .centered() + .bold() + .fg(cfg.colors.info_color), + ) .border_set(symbols::border::PLAIN) .border_style(Style::new().fg(cfg.colors.main_text_color)) .padding(Padding::horizontal(1)); -- cgit v1.2.3