aboutsummaryrefslogtreecommitdiffstats
path: root/default-plugins/tab-bar/src
diff options
context:
space:
mode:
authorDaniel Jankowski <Daniel.Jankowski@rub.de>2024-10-24 18:21:44 +0200
committerGitHub <noreply@github.com>2024-10-24 18:21:44 +0200
commit0cd6d5f4e5e7afcdd25cc45aaeeb80161498e322 (patch)
treef72011676c902a37828beee75f3d6e85a50124e4 /default-plugins/tab-bar/src
parentdocs(changelog): suspend commands in remote layouts (diff)
downloadsl0ppij-0cd6d5f4e5e7afcdd25cc45aaeeb80161498e322.tar.gz
sl0ppij-0cd6d5f4e5e7afcdd25cc45aaeeb80161498e322.tar.xz
sl0ppij-0cd6d5f4e5e7afcdd25cc45aaeeb80161498e322.zip
feat(plugins): add configurable black background for ui components (#3681)
* feat(plugins): add transparent background for text and nested_list * chore: fix formatting issue * feat: invert flag behaviour * feat: implement bg_black handling for table cells * fix: order of selected and bg_black in protocol * chore: rename from bg_black to opaque * fix: explicit selected, if opaque and selected for text * chore: fix formatting issues * feat: opaque tab-bar * feat: opaque session-manager bars * feat: opaque ribbon in plugin manager * feat: opaque one-line ui * feat: opaque tab-bar in configuration plugin
Diffstat (limited to 'default-plugins/tab-bar/src')
-rw-r--r--default-plugins/tab-bar/src/line.rs18
-rw-r--r--default-plugins/tab-bar/src/main.rs11
2 files changed, 22 insertions, 7 deletions
diff --git a/default-plugins/tab-bar/src/line.rs b/default-plugins/tab-bar/src/line.rs
index 349981f4..9384eaf1 100644
--- a/default-plugins/tab-bar/src/line.rs
+++ b/default-plugins/tab-bar/src/line.rs
@@ -232,6 +232,7 @@ pub fn tab_line(
tab_info: Option<&TabInfo>,
mode_info: &ModeInfo,
hide_swap_layout_indicator: bool,
+ background: &PaletteColor,
) -> Vec<LinePart> {
let mut tabs_after_active = all_tabs.split_off(active_tab_index);
let mut tabs_before_active = all_tabs;
@@ -278,6 +279,14 @@ pub fn tab_line(
capabilities,
);
prefix.append(&mut tabs_to_render);
+ prefix.append(&mut vec![LinePart {
+ part: match background {
+ PaletteColor::Rgb((r, g, b)) => format!("\u{1b}[48;2;{};{};{}m\u{1b}[0K", r, g, b),
+ PaletteColor::EightBit(color) => format!("\u{1b}[48;5;{}m\u{1b}[0K", color),
+ },
+ len: 0,
+ tab_index: None,
+ }]);
if let Some(mut swap_layout_indicator) = swap_layout_indicator.take() {
let remaining_space = cols
@@ -382,9 +391,11 @@ pub fn style_key_with_modifier(keyvec: &[KeyWithModifier], color_index: Option<u
if no_common_modifier || key.len() == 1 {
let key_string_text = format!(" {} ", key.join(key_separator));
let text = if let Some(color_index) = color_index {
- Text::new(&key_string_text).color_range(color_index, ..)
- } else {
Text::new(&key_string_text)
+ .color_range(color_index, ..)
+ .opaque()
+ } else {
+ Text::new(&key_string_text).opaque()
};
LinePart {
part: serialize_text(&text),
@@ -402,8 +413,9 @@ pub fn style_key_with_modifier(keyvec: &[KeyWithModifier], color_index: Option<u
modifier_str.width() + 3
..modifier_str.width() + 3 + key_string_without_modifier.width(),
)
+ .opaque()
} else {
- Text::new(&key_string_text)
+ Text::new(&key_string_text).opaque()
};
LinePart {
part: serialize_text(&text),
diff --git a/default-plugins/tab-bar/src/main.rs b/default-plugins/tab-bar/src/main.rs
index 8230467d..f38c245b 100644
--- a/default-plugins/tab-bar/src/main.rs
+++ b/default-plugins/tab-bar/src/main.rs
@@ -124,6 +124,12 @@ impl ZellijPlugin for State {
is_alternate_tab = !is_alternate_tab;
all_tabs.push(tab);
}
+
+ let background = match self.mode_info.style.colors.theme_hue {
+ ThemeHue::Dark => self.mode_info.style.colors.black,
+ ThemeHue::Light => self.mode_info.style.colors.white,
+ };
+
self.tab_line = tab_line(
self.mode_info.session_name.as_deref(),
all_tabs,
@@ -135,6 +141,7 @@ impl ZellijPlugin for State {
self.tabs.iter().find(|t| t.active),
&self.mode_info,
self.hide_swap_layout_indication,
+ &background,
);
let output = self
@@ -142,10 +149,6 @@ impl ZellijPlugin for State {
.iter()
.fold(String::new(), |output, part| output + &part.part);
- let background = match self.mode_info.style.colors.theme_hue {
- ThemeHue::Dark => self.mode_info.style.colors.black,
- ThemeHue::Light => self.mode_info.style.colors.white,
- };
match background {
PaletteColor::Rgb((r, g, b)) => {
print!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", output, r, g, b);