From 1f2ecd79df31c82ce1279515bc9dde1a919c8424 Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Wed, 21 Jan 2026 13:51:53 +0100 Subject: [PATCH] lib: Fix and improve theming --- src/ui.rs | 1 + src/ui/theme.rs | 14 +++++++------- src/ui/widget.rs | 17 +++++++++++------ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index f9371a51..8402a5e1 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -472,6 +472,7 @@ where .with_area(area) .with_layout(layout.into()) .with_ctx(self.ctx.clone()) + .with_theme(self.theme.clone()) } pub fn layout( diff --git a/src/ui/theme.rs b/src/ui/theme.rs index b6a57757..54034d84 100644 --- a/src/ui/theme.rs +++ b/src/ui/theme.rs @@ -6,11 +6,11 @@ use ratatui::style::{Color, Style, Stylize}; pub struct Theme { pub border_style: Style, pub focus_border_style: Style, + pub scroll_style: Style, + pub focus_scroll_style: Style, pub shortcuts_keys_style: Style, pub shortcuts_action_style: Style, pub textview_style: Style, - pub textview_scroll_style: Style, - pub textview_focus_scroll_style: Style, pub bar_on_black_style: Style, pub dim_no_focus: bool, } @@ -26,11 +26,11 @@ impl Theme { Self { border_style: Style::default().fg(Color::Rgb(170, 170, 170)), focus_border_style: Style::default(), + scroll_style: Style::default().fg(Color::Rgb(170, 170, 170)), + focus_scroll_style: Style::default(), shortcuts_keys_style: style::yellow(), shortcuts_action_style: style::reset(), textview_style: style::reset(), - textview_scroll_style: style::cyan().dim(), - textview_focus_scroll_style: style::cyan(), bar_on_black_style: Style::default().on_gray(), dim_no_focus: false, } @@ -39,12 +39,12 @@ impl Theme { pub fn default_dark() -> Self { Self { border_style: Style::default().fg(Color::Indexed(240)), - focus_border_style: Style::default().fg(Color::Indexed(246)), + focus_border_style: Style::default().cyan(), + scroll_style: Style::default().fg(Color::Indexed(240)), + focus_scroll_style: style::cyan(), shortcuts_keys_style: style::yellow().dim(), shortcuts_action_style: style::gray().dim(), textview_style: style::reset(), - textview_scroll_style: style::cyan().dim(), - textview_focus_scroll_style: style::cyan(), bar_on_black_style: Style::default().on_black(), dim_no_focus: false, } diff --git a/src/ui/widget.rs b/src/ui/widget.rs index cdb72d48..01f9d8f7 100644 --- a/src/ui/widget.rs +++ b/src/ui/widget.rs @@ -572,10 +572,10 @@ where .track_symbol(None) .end_symbol(None) .thumb_symbol("┃") - .style(if area_focus { - Style::default() + .style(if ui.has_focus { + ui.theme.focus_scroll_style } else { - Style::default().dim() + ui.theme.scroll_style }); let mut state = ScrollbarState::default() @@ -739,7 +739,12 @@ where .begin_symbol(None) .track_symbol(None) .end_symbol(None) - .thumb_symbol("┃"), + .thumb_symbol("┃") + .style(if area_focus { + ui.theme.focus_scroll_style + } else { + ui.theme.scroll_style + }), )) .highlight_style(style::highlight(ui.has_focus)) .style(tree_style) @@ -1016,9 +1021,9 @@ impl Widget for TextView<'_> { .end_symbol(None) .thumb_symbol("┃") .style(if area_focus { - Style::default() + ui.theme.focus_scroll_style } else { - Style::default().dim() + ui.theme.scroll_style }); let mut scroller_state = ScrollbarState::default()