Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add start_separator #2087

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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