Skip to content
Open
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
2 changes: 1 addition & 1 deletion extra/man/rio.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Colors are specified using their hexadecimal values with a _#_ prefix: _#RRGGBB_

*tabs-active* = _"<string>"_

Active tab title color.
Active tab title color. Defaults to *foreground*.

*split* = _"<string>"_

Expand Down
2 changes: 1 addition & 1 deletion frontends/rioterm/src/renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl Renderer {
let island = if config.navigation.is_enabled() {
Some(island::Island::new(
named_colors.tabs,
named_colors.tabs_active,
named_colors.tabs_active_or_foreground(),
config.navigation.hide_if_single,
config.navigation.max_tab_width,
))
Expand Down
5 changes: 4 additions & 1 deletion frontends/rioterm/src/screen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,10 @@ impl Screen<'_> {
self.renderer = Renderer::new(config);
self.renderer.is_window_focused = was_focused;
if let Some(mut island) = old_island {
island.update_colors(config.colors.tabs, config.colors.tabs_active);
island.update_colors(
config.colors.tabs,
config.colors.tabs_active_or_foreground(),
);
island.max_tab_width = config.navigation.max_tab_width;
self.renderer.island = Some(island);
}
Expand Down
60 changes: 46 additions & 14 deletions rio-backend/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ mod tests {
// Colors
assert_eq!(result.colors.background, colors::defaults::background());
assert_eq!(result.colors.foreground, colors::defaults::foreground());
assert_eq!(result.colors.tabs_active, colors::defaults::tabs_active());
assert_eq!(result.colors.tabs_active, None);
assert_eq!(result.colors.cursor, colors::defaults::cursor());
}

Expand All @@ -840,7 +840,7 @@ mod tests {
// Colors
assert_eq!(result.colors.background, colors::defaults::background());
assert_eq!(result.colors.foreground, colors::defaults::foreground());
assert_eq!(result.colors.tabs_active, colors::defaults::tabs_active());
assert_eq!(result.colors.tabs_active, None);
assert_eq!(result.colors.cursor, colors::defaults::cursor());
}

Expand All @@ -860,7 +860,7 @@ mod tests {
// Colors
assert_eq!(result.colors.background, colors::defaults::background());
assert_eq!(result.colors.foreground, colors::defaults::foreground());
assert_eq!(result.colors.tabs_active, colors::defaults::tabs_active());
assert_eq!(result.colors.tabs_active, None);
assert_eq!(result.colors.cursor, colors::defaults::cursor());
}

Expand All @@ -880,7 +880,7 @@ mod tests {
// Colors
assert_eq!(result.colors.background, colors::defaults::background());
assert_eq!(result.colors.foreground, colors::defaults::foreground());
assert_eq!(result.colors.tabs_active, colors::defaults::tabs_active());
assert_eq!(result.colors.tabs_active, None);
assert_eq!(
result.colors.selection_background,
colors::defaults::selection_background()
Expand Down Expand Up @@ -908,7 +908,7 @@ mod tests {
// Colors
assert_eq!(result.colors.background, colors::defaults::background());
assert_eq!(result.colors.foreground, colors::defaults::foreground());
assert_eq!(result.colors.tabs_active, colors::defaults::tabs_active());
assert_eq!(result.colors.tabs_active, None);
assert_eq!(result.colors.cursor, colors::defaults::cursor());
}

Expand All @@ -927,7 +927,7 @@ mod tests {
// Colors
assert_eq!(result.colors.background, colors::defaults::background());
assert_eq!(result.colors.foreground, colors::defaults::foreground());
assert_eq!(result.colors.tabs_active, colors::defaults::tabs_active());
assert_eq!(result.colors.tabs_active, None);
assert_eq!(result.colors.cursor, colors::defaults::cursor());
}

Expand All @@ -946,7 +946,7 @@ mod tests {
// Colors
assert_eq!(result.colors.background, colors::defaults::background());
assert_eq!(result.colors.foreground, colors::defaults::foreground());
assert_eq!(result.colors.tabs_active, colors::defaults::tabs_active());
assert_eq!(result.colors.tabs_active, None);
assert_eq!(result.colors.cursor, colors::defaults::cursor());
}

Expand Down Expand Up @@ -1010,7 +1010,7 @@ mod tests {
// Colors
assert_eq!(result.colors.background, colors::defaults::background());
assert_eq!(result.colors.foreground, colors::defaults::foreground());
assert_eq!(result.colors.tabs_active, colors::defaults::tabs_active());
assert_eq!(result.colors.tabs_active, None);
assert_eq!(result.colors.cursor, colors::defaults::cursor());
}

Expand All @@ -1028,7 +1028,7 @@ mod tests {
// Colors
assert_eq!(result.colors.background, colors::defaults::background());
assert_eq!(result.colors.foreground, colors::defaults::foreground());
assert_eq!(result.colors.tabs_active, colors::defaults::tabs_active());
assert_eq!(result.colors.tabs_active, None);
assert_eq!(result.colors.cursor, colors::defaults::cursor());
}

Expand All @@ -1055,7 +1055,7 @@ mod tests {
);

// Colors
assert_eq!(result.colors.tabs_active, colors::defaults::tabs_active());
assert_eq!(result.colors.tabs_active, None);
assert_eq!(result.colors.cursor, colors::defaults::cursor());
assert_eq!(result.colors.foreground, hex_to_color_arr("#F8F8F2"));
assert_eq!(result.colors.background.0, hex_to_color_arr("#2B3E50"));
Expand All @@ -1073,10 +1073,42 @@ mod tests {

assert_eq!(result.colors.background, colors::defaults::background());
assert_eq!(result.colors.foreground, [0.0, 0.0, 0.0, 1.0]);
assert_eq!(result.colors.tabs_active, colors::defaults::tabs_active());
assert_eq!(result.colors.tabs_active, None);
assert_eq!(result.colors.cursor, colors::defaults::cursor());
}

#[test]
fn test_tabs_active_falls_back_to_foreground() {
let result = create_temporary_config(
"tabs-active-fallback",
r#"
[colors]
background = '#EFF1F5'
foreground = '#4C4F69'
"#,
);

assert_eq!(result.colors.tabs_active, None);
assert_eq!(
result.colors.tabs_active_or_foreground(),
hex_to_color_arr("#4C4F69")
);

let result = create_temporary_config(
"tabs-active-explicit",
r#"
[colors]
foreground = '#4C4F69'
tabs-active = '#E6DB74'
"#,
);

assert_eq!(
result.colors.tabs_active_or_foreground(),
hex_to_color_arr("#E6DB74")
);
}

#[test]
fn test_change_colors() {
let result = create_temporary_config(
Expand Down Expand Up @@ -1130,7 +1162,7 @@ mod tests {
assert_eq!(result.colors.background.1, hex_to_color_wgpu("#2B3E50"));
assert_eq!(result.colors.cursor, hex_to_color_arr("#E6DB74"));
assert_eq!(result.colors.foreground, hex_to_color_arr("#F8F8F2"));
assert_eq!(result.colors.tabs_active, hex_to_color_arr("#E6DB74"));
assert_eq!(result.colors.tabs_active, Some(hex_to_color_arr("#E6DB74")));
assert_eq!(result.colors.black, hex_to_color_arr("#FFFFFF"));
assert_eq!(result.colors.blue, hex_to_color_arr("#030303"));
assert_eq!(result.colors.cyan, hex_to_color_arr("#030303"));
Expand Down Expand Up @@ -1170,7 +1202,7 @@ mod tests {
// Colors
assert_eq!(result.colors.background, colors::defaults::background());
assert_eq!(result.colors.foreground, colors::defaults::foreground());
assert_eq!(result.colors.tabs_active, colors::defaults::tabs_active());
assert_eq!(result.colors.tabs_active, None);
assert_eq!(result.colors.cursor, colors::defaults::cursor());
}

Expand Down Expand Up @@ -1236,7 +1268,7 @@ mod tests {
// Colors
assert_eq!(result.colors.background, colors::defaults::background());
assert_eq!(result.colors.foreground, colors::defaults::foreground());
assert_eq!(result.colors.tabs_active, colors::defaults::tabs_active());
assert_eq!(result.colors.tabs_active, None);
assert_eq!(result.colors.cursor, colors::defaults::cursor());
}

Expand Down
5 changes: 0 additions & 5 deletions rio-vt/src/config/colors/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ pub fn tabs() -> ColorArray {
.to_arr()
}

#[inline]
pub fn tabs_active() -> ColorArray {
[1., 1., 1., 1.]
}

#[inline]
pub fn foreground() -> ColorArray {
[1., 1., 1., 1.]
Expand Down
19 changes: 15 additions & 4 deletions rio-vt/src/config/colors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,15 @@ pub struct Colors {
pub red: ColorArray,
#[serde(deserialize_with = "deserialize_to_arr", default = "defaults::yellow")]
pub yellow: ColorArray,
/// Active tab title color. When unset, the title uses `foreground`,
/// which the theme already pairs with its background — a fixed
/// default can't suit both the dark and the light island fills.
#[serde(
deserialize_with = "deserialize_to_arr",
default = "defaults::tabs_active",
default = "Option::default",
deserialize_with = "deserialize_to_arr_opt",
rename = "tabs-active"
)]
pub tabs_active: ColorArray,
pub tabs_active: Option<ColorArray>,
#[serde(default = "defaults::cursor", deserialize_with = "deserialize_to_arr")]
pub cursor: ColorArray,
#[serde(
Expand Down Expand Up @@ -306,6 +309,14 @@ pub struct Colors {
pub hint_background: ColorArray,
}

impl Colors {
/// Resolved active tab title color: `tabs-active`, else `foreground`.
#[inline]
pub fn tabs_active_or_foreground(&self) -> ColorArray {
self.tabs_active.unwrap_or(self.foreground)
}
}

impl Default for Colors {
fn default() -> Colors {
Colors {
Expand All @@ -316,7 +327,7 @@ impl Default for Colors {
red: defaults::red(),
yellow: defaults::yellow(),
tabs: defaults::tabs(),
tabs_active: defaults::tabs_active(),
tabs_active: None,
cursor: defaults::cursor(),
split: defaults::split(),
split_active: defaults::split_active(),
Expand Down
Loading