From db6f301f1301d85ca7a4271363760836f53ac0d0 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 22 Aug 2026 17:18:56 -0400 Subject: feat: add per-mode theme overrides (#2324) * feat: add per-mode theme overrides allow [theme.custom.light] and [theme.custom.dark] blocks so custom overrides can differ per resolved appearance when auto_switch flips. precedence: theme defaults, then [theme.custom], then the block for the active mode. configs without the new blocks resolve unchanged. refs #837 * docs: complete per-mode theme documentation --------- Co-authored-by: Ogulcan Celik --- src/app/state.rs | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'src/app/state.rs') diff --git a/src/app/state.rs b/src/app/state.rs index d9dcfc9d..21ee8899 100644 --- a/src/app/state.rs +++ b/src/app/state.rs @@ -645,6 +645,68 @@ impl Palette { } self } + + pub fn with_mode_overrides(mut self, custom: &crate::config::ModeThemeColors) -> Self { + use crate::config::parse_color; + if let Some(c) = &custom.accent { + self.accent = parse_color(c); + } + if let Some(c) = &custom.panel_bg { + self.panel_bg = parse_color(c); + } + if let Some(c) = &custom.sidebar_bg { + self.sidebar_bg = parse_color(c); + } + if let Some(c) = &custom.active_row_bg { + self.active_row_bg = parse_color(c); + } + if let Some(c) = &custom.selection_bg { + self.selection_bg = parse_color(c); + } + if let Some(c) = &custom.surface0 { + self.surface0 = parse_color(c); + } + if let Some(c) = &custom.surface1 { + self.surface1 = parse_color(c); + } + if let Some(c) = &custom.surface_dim { + self.surface_dim = parse_color(c); + } + if let Some(c) = &custom.overlay0 { + self.overlay0 = parse_color(c); + } + if let Some(c) = &custom.overlay1 { + self.overlay1 = parse_color(c); + } + if let Some(c) = &custom.text { + self.text = parse_color(c); + } + if let Some(c) = &custom.subtext0 { + self.subtext0 = parse_color(c); + } + if let Some(c) = &custom.mauve { + self.mauve = parse_color(c); + } + if let Some(c) = &custom.green { + self.green = parse_color(c); + } + if let Some(c) = &custom.yellow { + self.yellow = parse_color(c); + } + if let Some(c) = &custom.red { + self.red = parse_color(c); + } + if let Some(c) = &custom.blue { + self.blue = parse_color(c); + } + if let Some(c) = &custom.teal { + self.teal = parse_color(c); + } + if let Some(c) = &custom.peach { + self.peach = parse_color(c); + } + self + } } #[derive(Debug, Clone, Copy, PartialEq, Eq)] -- cgit v1.2.3