diff options
| author | lukeflo | 2025-02-24 15:29:47 +0000 |
|---|---|---|
| committer | lukeflo | 2025-02-24 15:29:47 +0000 |
| commit | 5da77a2f812a0bb6e0057f7b2e2c642142fca125 (patch) | |
| tree | 6be886693445a54e4cbd7b98151555eec220e863 /src/tui/ui.rs | |
| parent | dd8dd9611771491e723a49b41cf27b1e9090664d (diff) | |
| parent | aff7c398da005029a293178e487cf5323e507fb4 (diff) | |
| download | bibiman-5da77a2f812a0bb6e0057f7b2e2c642142fca125.tar.gz bibiman-5da77a2f812a0bb6e0057f7b2e2c642142fca125.zip | |
Merge pull request 'Implement config file' (#15) from implement-config into main
Reviewed-on: https://codeberg.org/lukeflo/bibiman/pulls/15
Diffstat (limited to 'src/tui/ui.rs')
| -rw-r--r-- | src/tui/ui.rs | 321 |
1 files changed, 143 insertions, 178 deletions
diff --git a/src/tui/ui.rs b/src/tui/ui.rs index d85f318..2d58aec 100644 --- a/src/tui/ui.rs +++ b/src/tui/ui.rs @@ -17,11 +17,11 @@ use std::path::PathBuf; -use super::colors::AppColorScheme; use super::popup::PopupArea; use crate::bibiman::entries::EntryTableColumn; use crate::bibiman::{CurrentArea, FormerArea}; use crate::cliargs::CLIArgs; +use crate::config::BibiConfig; use crate::tui::popup::PopupKind; use crate::App; use ratatui::layout::{Direction, Position}; @@ -52,8 +52,8 @@ pub fn color_list( highlight: u8, max_diff: i32, ) -> Color { - match args.colors.color_scheme { - AppColorScheme::Dark => { + match args.light_theme { + false => { if list_item == sel_item { Color::Indexed(highlight) } else if (list_item - sel_item) > max_diff @@ -68,7 +68,7 @@ pub fn color_list( Color::Indexed(highlight - (list_item - sel_item) as u8) } } - AppColorScheme::Light => { + true => { if list_item == sel_item { Color::Indexed(highlight) } else if (list_item - sel_item) > max_diff @@ -103,7 +103,7 @@ fn count_files(files: &[PathBuf]) -> u16 { count } -pub fn render_ui(app: &mut App, args: &CLIArgs, frame: &mut Frame) { +pub fn render_ui(app: &mut App, cfg: &BibiConfig, frame: &mut Frame) { let [header_area, main_area, footer_area] = Layout::new( Direction::Vertical, [ @@ -128,20 +128,20 @@ pub fn render_ui(app: &mut App, args: &CLIArgs, frame: &mut Frame) { let [tag_area, info_area] = Layout::horizontal([Constraint::Max(25), Constraint::Min(35)]).areas(item_area); - render_header(args, frame, header_area); + render_header(cfg, frame, header_area); if let CurrentArea::SearchArea = app.bibiman.current_area { - render_footer(app, args, frame, footer_area); + render_footer(app, cfg, frame, footer_area); } - render_entrytable(app, args, frame, entry_area); - render_selected_item(app, args, frame, info_area); - render_taglist(app, args, frame, tag_area); - render_file_info(app, args, frame, entry_info_area); + render_entrytable(app, cfg, frame, entry_area); + render_selected_item(app, cfg, frame, info_area); + render_taglist(app, cfg, frame, tag_area); + render_file_info(app, cfg, frame, entry_info_area); if app.bibiman.popup_area.is_popup { - render_popup(app, args, frame); + render_popup(app, cfg, frame); } } -pub fn render_popup(app: &mut App, args: &CLIArgs, frame: &mut Frame) { +pub fn render_popup(app: &mut App, cfg: &BibiConfig, frame: &mut Frame) { match app.bibiman.popup_area.popup_kind { Some(PopupKind::Help) => { let block = Block::bordered() @@ -150,13 +150,13 @@ pub fn render_popup(app: &mut App, args: &CLIArgs, frame: &mut Frame) { .title_alignment(Alignment::Center) .style( Style::new() - .fg(Color::Indexed(args.colors.main_text_color)) - .bg(Color::Indexed(args.colors.popup_bg_color)), + .fg(cfg.colors.main_text_color) + .bg(cfg.colors.popup_bg_color), ) .border_set(symbols::border::THICK) - .border_style(Style::new().fg(Color::Indexed(args.colors.entry_color))); + .border_style(Style::new().fg(cfg.colors.entry_color)); - let text: Text = PopupArea::popup_help(args); + let text: Text = PopupArea::popup_help(cfg); // Calculate max scroll position depending on hight of terminal window // Needed length is number of text lines plus two for borders at bottom and top @@ -191,23 +191,20 @@ pub fn render_popup(app: &mut App, args: &CLIArgs, frame: &mut Frame) { .title_alignment(Alignment::Center) .style( Style::new() - .fg(Color::Indexed(args.colors.main_text_color)) - .bg(Color::Indexed(args.colors.popup_bg_color)), + .fg(cfg.colors.main_text_color) + .bg(cfg.colors.popup_bg_color), ) .border_set(symbols::border::THICK) - .border_style(Style::new().fg(Color::Indexed(args.colors.entry_color))); + .border_style(Style::new().fg(cfg.colors.entry_color)); // Prepare the input fields let content = vec![Line::from(vec![ - Span::styled( - "DOI: ", - Style::new().fg(Color::Indexed(args.colors.entry_color)), - ), + Span::styled("DOI: ", Style::new().fg(cfg.colors.entry_color)), Span::raw(app.input.value().to_string().clone()), ])]; let paragraph = Paragraph::new(content) .block(block.clone()) - .style(Style::new().fg(Color::Indexed(args.colors.main_text_color))) + .style(Style::new().fg(cfg.colors.main_text_color)) .wrap(Wrap { trim: false }); let doi_lines = paragraph.line_count(area.width / 2); @@ -225,21 +222,17 @@ pub fn render_popup(app: &mut App, args: &CLIArgs, frame: &mut Frame) { let area = frame.area(); let block = Block::bordered() - .title_top( - " Message " - .bold() - .fg(Color::Indexed(args.colors.confirm_color)), - ) - .border_style(Style::new().fg(Color::Indexed(args.colors.confirm_color))) + .title_top(" Message ".bold().fg(cfg.colors.confirm_color)) + .border_style(Style::new().fg(cfg.colors.confirm_color)) .style( Style::new() - .fg(Color::Indexed(args.colors.main_text_color)) - .bg(Color::Indexed(args.colors.popup_bg_color)), + .fg(cfg.colors.main_text_color) + .bg(cfg.colors.popup_bg_color), ); let content = Paragraph::new(app.bibiman.popup_area.popup_message.clone()) .block(block) - .style(Style::new().fg(Color::Indexed(args.colors.confirm_color))); + .style(Style::new().fg(cfg.colors.confirm_color)); // Calculate popup size. Width is number of string chars plus 2 for border let popup_area = popup_area( @@ -256,21 +249,17 @@ pub fn render_popup(app: &mut App, args: &CLIArgs, frame: &mut Frame) { let area = frame.area(); let block = Block::bordered() - .title_top( - " Warning " - .bold() - .fg(Color::Indexed(args.colors.warn_color)), - ) + .title_top(" Warning ".bold().fg(cfg.colors.warn_color)) .border_style(Style::new().fg(Color::Red)) .style( Style::new() - .fg(Color::Indexed(args.colors.main_text_color)) - .bg(Color::Indexed(args.colors.popup_bg_color)), + .fg(cfg.colors.main_text_color) + .bg(cfg.colors.popup_bg_color), ); let content = Paragraph::new(app.bibiman.popup_area.popup_message.clone()) .block(block) - .style(Style::new().fg(Color::Indexed(args.colors.warn_color))); + .style(Style::new().fg(cfg.colors.warn_color)); // Calculate popup size. Width is number of string chars plus 2 for border let popup_area = popup_area( @@ -306,15 +295,15 @@ pub fn render_popup(app: &mut App, args: &CLIArgs, frame: &mut Frame) { .title_alignment(Alignment::Center) .style( Style::new() - .fg(Color::Indexed(args.colors.main_text_color)) - .bg(Color::Indexed(args.colors.popup_bg_color)), + .fg(cfg.colors.main_text_color) + .bg(cfg.colors.popup_bg_color), ) .border_set(symbols::border::THICK) - .border_style(Style::new().fg(Color::Indexed(args.colors.keyword_color))); + .border_style(Style::new().fg(cfg.colors.keyword_color)); let list = List::new(list_items).block(block).highlight_style( Style::new() - // .fg(Color::Indexed(args.colors.entry_color)) + // .fg(cfg.colors.entry_color) .add_modifier(Modifier::BOLD) .add_modifier(Modifier::REVERSED), ); @@ -330,15 +319,15 @@ pub fn render_popup(app: &mut App, args: &CLIArgs, frame: &mut Frame) { } } -pub fn render_header(args: &CLIArgs, frame: &mut Frame, rect: Rect) { +pub fn render_header(cfg: &BibiConfig, frame: &mut Frame, rect: Rect) { let main_header = Paragraph::new("BIBIMAN – BibLaTeX manager TUI") .bold() - .fg(Color::Indexed(args.colors.entry_color)) + .fg(cfg.colors.entry_color) .centered(); frame.render_widget(main_header, rect) } -pub fn render_footer(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: Rect) { +pub fn render_footer(app: &mut App, cfg: &BibiConfig, frame: &mut Frame, rect: Rect) { let search_title = { match app.bibiman.former_area { Some(FormerArea::EntryArea) => "Search Entries: ".to_string(), @@ -351,27 +340,27 @@ pub fn render_footer(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: Rec let block = Block::new() .padding(Padding::horizontal(1)) - .bg(Color::Indexed(args.colors.bar_bg_color)); + .bg(cfg.colors.bar_bg_color); let search_string = Paragraph::new(Line::from(vec![ Span::styled( search_title, if let Some(FormerArea::EntryArea) = app.bibiman.former_area { Style::new() - .fg(Color::Indexed(args.colors.entry_color)) + .fg(cfg.colors.entry_color) .add_modifier(Modifier::BOLD) } else if let Some(FormerArea::TagArea) = app.bibiman.former_area { Style::new() - .fg(Color::Indexed(args.colors.keyword_color)) + .fg(cfg.colors.keyword_color) .add_modifier(Modifier::BOLD) } else { Style::new() - .fg(Color::Indexed(args.colors.highlight_text_color)) + .fg(cfg.colors.highlight_text_color) .add_modifier(Modifier::BOLD) }, ), Span::raw(app.bibiman.search_struct.search_string.clone()) - .fg(Color::Indexed(args.colors.highlight_text_color)), + .fg(cfg.colors.highlight_text_color), ])) .block(block); @@ -383,7 +372,7 @@ pub fn render_footer(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: Rec // 1. Basename of the currently loaded file // 2. Keyword by which the entries are filtered at the moment // 3. Currently selected entry and total count of entries -pub fn render_file_info(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: Rect) { +pub fn render_file_info(app: &mut App, cfg: &BibiConfig, frame: &mut Frame, rect: Rect) { let block = Block::new() // can also be Block::new // Leave Top empty to simulate one large box with borders of entry list .borders(Borders::LEFT | Borders::RIGHT | Borders::BOTTOM) @@ -393,10 +382,10 @@ pub fn render_file_info(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: symbols::border::PLAIN }) .border_style(if let CurrentArea::EntryArea = app.bibiman.current_area { - Style::new().fg(Color::Indexed(args.colors.highlight_text_color)) + Style::new().fg(cfg.colors.highlight_text_color) } else { Style::new() - .fg(Color::Indexed(args.colors.entry_color)) + .fg(cfg.colors.entry_color) .add_modifier(Modifier::BOLD) }); @@ -410,47 +399,37 @@ pub fn render_file_info(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: .horizontal_margin(1) .areas(rect); - let file_info = if args.pos_args.len() == 1 && args.pos_args.first().unwrap().is_file() { + let file_info = if app.bibiman.main_bibfiles.len() == 1 + && app.bibiman.main_bibfiles.first().unwrap().is_file() + { Line::from(vec![ - Span::raw("File: ") - .fg(Color::Indexed(args.colors.main_text_color)) - .bold(), - Span::raw(args.pos_args[0].file_name().unwrap().to_string_lossy()) - .fg(Color::Indexed(args.colors.main_text_color)) - .bold(), - ]) - .bg(Color::Indexed(args.colors.bar_bg_color)) - } else if args.pos_args.len() == 1 && args.pos_args.first().unwrap().is_dir() { - Line::from(vec![ - Span::raw("Directory: ") - .bold() - .fg(Color::Indexed(args.colors.main_text_color)), - Span::raw(args.pos_args[0].file_name().unwrap().to_string_lossy()) - .fg(Color::Indexed(args.colors.main_text_color)) - .bold(), - Span::raw("/*.bib") - .fg(Color::Indexed(args.colors.main_text_color)) - .bold(), + Span::raw("File: ").fg(cfg.colors.main_text_color).bold(), + Span::raw( + app.bibiman.main_bibfiles[0] + .file_name() + .unwrap() + .to_string_lossy(), + ) + .fg(cfg.colors.main_text_color) + .bold(), ]) - .bg(Color::Indexed(args.colors.bar_bg_color)) + .bg(cfg.colors.bar_bg_color) } else { Line::from(vec![ Span::raw("Multiple files (") - .fg(Color::Indexed(args.colors.main_text_color)) - .bold(), - Span::raw(count_files(&args.files).to_string()) - .fg(Color::Indexed(args.colors.main_text_color)) + .fg(cfg.colors.main_text_color) .bold(), - Span::raw(")") - .fg(Color::Indexed(args.colors.main_text_color)) + Span::raw(count_files(&app.bibiman.main_bibfiles).to_string()) + .fg(cfg.colors.main_text_color) .bold(), + Span::raw(")").fg(cfg.colors.main_text_color).bold(), ]) - .bg(Color::Indexed(args.colors.bar_bg_color)) + .bg(cfg.colors.bar_bg_color) }; let cur_keywords = Line::from(if !app.bibiman.tag_list.selected_keywords.is_empty() { vec![ - Span::raw("Selected keywords: ").fg(Color::Indexed(args.colors.main_text_color)), + Span::raw("Selected keywords: ").fg(cfg.colors.main_text_color), // Show all keywords in correct order if list is filtered // successively by multiple keywords Span::raw(app.bibiman.tag_list.selected_keywords.join(" → ")) @@ -460,7 +439,7 @@ pub fn render_file_info(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: } else { vec![Span::raw(" ")] }) - .bg(Color::Indexed(args.colors.bar_bg_color)); + .bg(cfg.colors.bar_bg_color); // .render(keyword_area, buf); let item_count = Line::from( @@ -496,38 +475,36 @@ pub fn render_file_info(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: .to_string() }, ) - .fg(Color::Indexed(args.colors.main_text_color)) + .fg(cfg.colors.main_text_color) .bold(), - Span::raw("/").fg(Color::Indexed(args.colors.main_text_color)), + Span::raw("/").fg(cfg.colors.main_text_color), Span::raw(app.bibiman.entry_table.entry_table_items.len().to_string()) - .fg(Color::Indexed(args.colors.main_text_color)), + .fg(cfg.colors.main_text_color), ] } else { vec![Span::raw("No entries")] }, ) .right_aligned() - .bg(Color::Indexed(args.colors.bar_bg_color)); + .bg(cfg.colors.bar_bg_color); frame.render_widget(file_info, file_area); frame.render_widget(cur_keywords, keyword_area); frame.render_widget(item_count, count_area); } -pub fn render_entrytable(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: Rect) { - let entry_box_selected_border_style: Style = - Style::new().fg(Color::Indexed(args.colors.highlight_text_color)); +pub fn render_entrytable(app: &mut App, cfg: &BibiConfig, frame: &mut Frame, rect: Rect) { + let entry_box_selected_border_style: Style = Style::new().fg(cfg.colors.highlight_text_color); let entry_box_selected_title_style: Style = Style::new() - .fg(Color::Indexed(args.colors.entry_color)) + .fg(cfg.colors.entry_color) .add_modifier(Modifier::BOLD); - let entry_box_unselected_border_style: Style = - Style::new().fg(Color::Indexed(args.colors.main_text_color)); + let entry_box_unselected_border_style: Style = Style::new().fg(cfg.colors.main_text_color); let entry_box_unselected_title_style: Style = Style::new() - .fg(Color::Indexed(args.colors.entry_color)) + .fg(cfg.colors.entry_color) .add_modifier(Modifier::BOLD); let selected_table_col_style: Style = Style::new().add_modifier(Modifier::BOLD); let selectec_table_cell_style: Style = Style::new().add_modifier(Modifier::REVERSED); let entry_selected_row_style: Style = Style::new() - .fg(Color::Indexed(args.colors.entry_color)) + .fg(cfg.colors.entry_color) .add_modifier(Modifier::BOLD) .add_modifier(Modifier::REVERSED); @@ -557,8 +534,8 @@ pub fn render_entrytable(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: let header_style = Style::default() .bold() - .fg(Color::Indexed(args.colors.main_text_color)) - .bg(Color::Indexed(args.colors.bar_bg_color)); + .fg(cfg.colors.main_text_color) + .bg(cfg.colors.bar_bg_color); let header = Row::new(vec![ Cell::from( @@ -582,9 +559,9 @@ pub fn render_entrytable(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: if let EntryTableColumn::Authors = app.bibiman.entry_table.entry_table_selected_column { - Color::Indexed(args.colors.selected_row_bg_color) + cfg.colors.selected_row_bg_color } else { - Color::Indexed(args.colors.bar_bg_color) + cfg.colors.bar_bg_color }, ), ), @@ -608,9 +585,9 @@ pub fn render_entrytable(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: .bg( if let EntryTableColumn::Title = app.bibiman.entry_table.entry_table_selected_column { - Color::Indexed(args.colors.selected_row_bg_color) + cfg.colors.selected_row_bg_color } else { - Color::Indexed(args.colors.bar_bg_color) + cfg.colors.bar_bg_color }, ), ), @@ -634,9 +611,9 @@ pub fn render_entrytable(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: .bg( if let EntryTableColumn::Year = app.bibiman.entry_table.entry_table_selected_column { - Color::Indexed(args.colors.selected_row_bg_color) + cfg.colors.selected_row_bg_color } else { - Color::Indexed(args.colors.bar_bg_color) + cfg.colors.bar_bg_color }, ), ), @@ -661,9 +638,9 @@ pub fn render_entrytable(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: if let EntryTableColumn::Pubtype = app.bibiman.entry_table.entry_table_selected_column { - Color::Indexed(args.colors.selected_row_bg_color) + cfg.colors.selected_row_bg_color } else { - Color::Indexed(args.colors.bar_bg_color) + cfg.colors.bar_bg_color }, ), ), @@ -678,23 +655,24 @@ pub fn render_entrytable(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: .entry_table_items .iter_mut() .enumerate() - .map(|(i, data)| { + .map(|(_i, data)| { let item = data.ref_vec(); item.into_iter() .map(|content| Cell::from(Text::from(content.to_string()))) .collect::<Row>() .style( - Style::new().fg(color_list( - args, - i as i32, - app.bibiman - .entry_table - .entry_table_state - .selected() - .unwrap_or(0) as i32, - args.colors.highlight_text_color, - 20, - )), + // Style::new().fg(color_list( + // args, + // i as i32, + // app.bibiman + // .entry_table + // .entry_table_state + // .selected() + // .unwrap_or(0) as i32, + // args.colors.highlight_text_color, + // 20, + // )), + Style::new().fg(cfg.colors.highlight_text_color), ) .height(1) }); @@ -747,11 +725,9 @@ pub fn render_entrytable(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: } } -pub fn render_selected_item(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: Rect) { +pub fn render_selected_item(app: &mut App, cfg: &BibiConfig, frame: &mut Frame, rect: Rect) { // We get the info depending on the item's state. - let style_value = Style::new() - .bold() - .fg(Color::Indexed(args.colors.main_text_color)); + let style_value = Style::new().bold().fg(cfg.colors.main_text_color); let lines = { if app .bibiman @@ -771,10 +747,7 @@ pub fn render_selected_item(app: &mut App, args: &CLIArgs, frame: &mut Frame, re 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(Color::Indexed(args.colors.info_color)), - ), + Span::styled(cur_entry.authors(), Style::new().fg(cfg.colors.info_color)), ])); if cur_entry.subtitle.is_some() { lines.push(Line::from(vec![ @@ -782,19 +755,19 @@ pub fn render_selected_item(app: &mut App, args: &CLIArgs, frame: &mut Frame, re Span::styled( cur_entry.title(), Style::new() - .fg(Color::Indexed(args.colors.entry_color)) + .fg(cfg.colors.entry_color) .add_modifier(Modifier::ITALIC), ), Span::styled( ": ", Style::new() - .fg(Color::Indexed(args.colors.entry_color)) + .fg(cfg.colors.entry_color) .add_modifier(Modifier::ITALIC), ), Span::styled( cur_entry.subtitle(), Style::new() - .fg(Color::Indexed(args.colors.entry_color)) + .fg(cfg.colors.entry_color) .add_modifier(Modifier::ITALIC), ), ])); @@ -804,17 +777,14 @@ pub fn render_selected_item(app: &mut App, args: &CLIArgs, frame: &mut Frame, re Span::styled( cur_entry.title(), Style::new() - .fg(Color::Indexed(args.colors.entry_color)) + .fg(cfg.colors.entry_color) .add_modifier(Modifier::ITALIC), ), ])); } lines.push(Line::from(vec![ Span::styled("Year: ", style_value), - Span::styled( - cur_entry.year(), - Style::new().fg(Color::Indexed(args.colors.keyword_color)), - ), + Span::styled(cur_entry.year(), Style::new().fg(cfg.colors.keyword_color)), ])); // Render keywords in info box in Markdown code style if !cur_entry.keywords.is_empty() { @@ -827,27 +797,25 @@ pub fn render_selected_item(app: &mut App, args: &CLIArgs, frame: &mut Frame, re let mut content = vec![Span::styled("Keywords: ", style_value)]; for k in kw { // Add half block highlighted in bg color to enlarge block - content.push(Span::raw("▐").fg(Color::Indexed(args.colors.bar_bg_color))); + content.push(Span::raw("▐").fg(cfg.colors.bar_bg_color)); content.push(Span::styled( k, - Style::default() - .bg(Color::Indexed(args.colors.bar_bg_color)) - .fg( - // Highlight selected keyword green - if app - .bibiman - .tag_list - .selected_keywords - .iter() - .any(|e| e == k) - { - Color::Green - } else { - Color::Indexed(args.colors.main_text_color) - }, - ), + Style::default().bg(cfg.colors.bar_bg_color).fg( + // Highlight selected keyword green + if app + .bibiman + .tag_list + .selected_keywords + .iter() + .any(|e| e == k) + { + Color::Green + } else { + cfg.colors.main_text_color + }, + ), )); - content.push(Span::raw("▌").fg(Color::Indexed(args.colors.bar_bg_color))); + content.push(Span::raw("▌").fg(cfg.colors.bar_bg_color)); } lines.push(Line::from(content)) } @@ -859,9 +827,7 @@ pub fn render_selected_item(app: &mut App, args: &CLIArgs, frame: &mut Frame, re Span::styled("DOI/URL: ", style_value), Span::styled( cur_entry.doi_url(), - Style::new() - .fg(Color::Indexed(args.colors.main_text_color)) - .underlined(), + Style::new().fg(cfg.colors.main_text_color).underlined(), ), ])); } @@ -870,14 +836,14 @@ pub fn render_selected_item(app: &mut App, args: &CLIArgs, frame: &mut Frame, re Span::styled("File: ", style_value), Span::styled( cur_entry.filepath().to_string_lossy(), - Style::new().fg(Color::Indexed(args.colors.main_text_color)), + Style::new().fg(cfg.colors.main_text_color), ), ])); } lines.push(Line::from("")); lines.push(Line::from(vec![Span::styled( cur_entry.abstract_text.clone(), - Style::new().fg(Color::Indexed(args.colors.main_text_color)), + Style::new().fg(cfg.colors.main_text_color), )])); lines } else { @@ -894,7 +860,7 @@ pub fn render_selected_item(app: &mut App, args: &CLIArgs, frame: &mut Frame, re let block = Block::bordered() .title(Line::raw(" Entry Information ").centered().bold()) .border_set(symbols::border::PLAIN) - .border_style(Style::new().fg(Color::Indexed(args.colors.main_text_color))) + .border_style(Style::new().fg(cfg.colors.main_text_color)) .padding(Padding::horizontal(1)); // INFO: '.line_count' method only possible with unstable-rendered-line-info feature -> API might change: https://github.com/ratatui/ratatui/issues/293#ref-pullrequest-2027056434 @@ -947,19 +913,17 @@ pub fn render_selected_item(app: &mut App, args: &CLIArgs, frame: &mut Frame, re frame.render_widget(item_info, rect); } -pub fn render_taglist(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: Rect) { - let keyword_box_selected_border_style: Style = - Style::new().fg(Color::Indexed(args.colors.highlight_text_color)); +pub fn render_taglist(app: &mut App, cfg: &BibiConfig, frame: &mut Frame, rect: Rect) { + let keyword_box_selected_border_style: Style = Style::new().fg(cfg.colors.highlight_text_color); let keyword_box_selected_title_style: Style = Style::new() - .fg(Color::Indexed(args.colors.keyword_color)) + .fg(cfg.colors.keyword_color) .add_modifier(Modifier::BOLD); - let keyword_box_unselected_border_style: Style = - Style::new().fg(Color::Indexed(args.colors.main_text_color)); + let keyword_box_unselected_border_style: Style = Style::new().fg(cfg.colors.main_text_color); let keyword_box_unselected_title_style: Style = Style::new() - .fg(Color::Indexed(args.colors.keyword_color)) + .fg(cfg.colors.keyword_color) .add_modifier(Modifier::BOLD); let keyword_selected_row_style: Style = Style::new() - .fg(Color::Indexed(args.colors.keyword_color)) + .fg(cfg.colors.keyword_color) .add_modifier(Modifier::BOLD) .add_modifier(Modifier::REVERSED); @@ -993,18 +957,19 @@ pub fn render_taglist(app: &mut App, args: &CLIArgs, frame: &mut Frame, rect: Re .tag_list_items .iter() .enumerate() - .map(|(i, keyword)| { + .map(|(_i, keyword)| { ListItem::from(keyword.to_owned()).style(Style::new().fg( if app.bibiman.tag_list.tag_list_state.selected().is_some() { - color_list( - args, - i as i32, - app.bibiman.tag_list.tag_list_state.selected().unwrap() as i32, - args.colors.highlight_text_color, - 20, - ) + // color_list( + // args, + // i as i32, + // app.bibiman.tag_list.tag_list_state.selected().unwrap() as i32, + // args.colors.highlight_text_color, + // 20, + // ) + cfg.colors.highlight_text_color } else { - Color::Indexed(args.colors.main_text_color) + cfg.colors.main_text_color }, )) //.bg(color) }) |
