Skip to content

Commit

Permalink
Add start_separator (#2087)
Browse files Browse the repository at this point in the history
  • Loading branch information
lorber13 authored Nov 14, 2024
1 parent 0d782b8 commit ae2f92f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 8 additions & 2 deletions src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions src/themes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) => {
Expand Down Expand Up @@ -128,6 +132,7 @@ pub struct ThemeOverrides {
pub alternating_tint_bg: Option<ColorOrLink>,
pub alternating_tint_fg: Option<ColorOrLink>,
pub end_separator: Option<Separator>,
pub start_separator: Option<Separator>,
}

impl TryFrom<ThemeUserConfig> for Theme {
Expand Down

0 comments on commit ae2f92f

Please sign in to comment.