From ae2f92f21b266b9f36f37c22dfd635b94ed6c922 Mon Sep 17 00:00:00 2001 From: Lorenzo Bertetto <55274911+lorber13@users.noreply.github.com> Date: Thu, 14 Nov 2024 10:17:12 +0100 Subject: [PATCH] Add start_separator (#2087) --- doc/themes.md | 1 + src/protocol.rs | 10 ++++++++-- src/themes.rs | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/doc/themes.md b/doc/themes.md index fa3b50377a..32230c26b5 100644 --- a/doc/themes.md +++ b/doc/themes.md @@ -146,6 +146,7 @@ Feel free to take a look at the provided color schemes for reference. * `separator_fg` * `separator` * `end_separator` +* `start_separator` # Available icon overrides diff --git a/src/protocol.rs b/src/protocol.rs index aa6f2db294..72e7747014 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -38,11 +38,12 @@ where let mut prev_merge_with_next = false; - for widgets in blocks + for (i, widgets) in blocks .iter() .map(|x| x.borrow()) .filter(|x| !x.segments.is_empty()) .cloned() + .enumerate() { let RenderedBlock { mut segments, @@ -64,7 +65,12 @@ where alt = !alt; } - if let Separator::Custom(separator) = &config.theme.separator { + let separator = match &config.theme.start_separator { + Separator::Custom(_) if i == 0 => &config.theme.start_separator, + _ => &config.theme.separator, + }; + + if let Separator::Custom(separator) = separator { if !prev_merge_with_next { // The first widget's BG is used to get the FG color for the current separator let sep_fg = if config.theme.separator_fg == Color::Auto { diff --git a/src/themes.rs b/src/themes.rs index c46a04dbd7..c02b555e9d 100644 --- a/src/themes.rs +++ b/src/themes.rs @@ -54,6 +54,7 @@ pub struct ThemeInner { pub alternating_tint_bg: Color, pub alternating_tint_fg: Color, pub end_separator: Separator, + pub start_separator: Separator, } impl Theme { @@ -76,6 +77,9 @@ impl Theme { if let Some(end_separator) = overrides.end_separator { self.end_separator = end_separator; } + if let Some(start_separator) = overrides.start_separator { + self.start_separator = start_separator; + } macro_rules! apply { ($prop:tt) => { @@ -128,6 +132,7 @@ pub struct ThemeOverrides { pub alternating_tint_bg: Option, pub alternating_tint_fg: Option, pub end_separator: Option, + pub start_separator: Option, } impl TryFrom for Theme {