diff options
Diffstat (limited to 'default-plugins')
-rw-r--r-- | default-plugins/status-bar/src/main.rs | 87 | ||||
-rw-r--r-- | default-plugins/status-bar/src/second_line.rs | 132 | ||||
-rw-r--r-- | default-plugins/tab-bar/src/line.rs | 42 | ||||
-rw-r--r-- | default-plugins/tab-bar/src/main.rs | 6 | ||||
-rw-r--r-- | default-plugins/tab-bar/src/tab.rs | 14 |
5 files changed, 142 insertions, 139 deletions
diff --git a/default-plugins/status-bar/src/main.rs b/default-plugins/status-bar/src/main.rs index 471c45c76..27e549d1c 100644 --- a/default-plugins/status-bar/src/main.rs +++ b/default-plugins/status-bar/src/main.rs @@ -81,56 +81,64 @@ pub struct ColoredElements { // plus here we can add new sources in the future, like Theme // that can be defined in the config perhaps fn color_elements(palette: Palette) -> ColoredElements { + let background = match palette.theme_hue { + ThemeHue::Dark => palette.black, + ThemeHue::Light => palette.white, + }; + let foreground = match palette.theme_hue { + ThemeHue::Dark => palette.white, + ThemeHue::Light => palette.black, + }; match palette.source { PaletteSource::Default => ColoredElements { - selected_prefix_separator: style!(palette.gray, palette.green), - selected_char_left_separator: style!(palette.black, palette.green).bold(), + selected_prefix_separator: style!(background, palette.green), + selected_char_left_separator: style!(background, palette.green).bold(), selected_char_shortcut: style!(palette.red, palette.green).bold(), - selected_char_right_separator: style!(palette.black, palette.green).bold(), - selected_styled_text: style!(palette.black, palette.green).bold(), - selected_suffix_separator: style!(palette.green, palette.gray).bold(), - unselected_prefix_separator: style!(palette.gray, palette.fg), - unselected_char_left_separator: style!(palette.black, palette.fg).bold(), + selected_char_right_separator: style!(background, palette.green).bold(), + selected_styled_text: style!(background, palette.green).bold(), + selected_suffix_separator: style!(palette.green, background).bold(), + unselected_prefix_separator: style!(background, palette.fg), + unselected_char_left_separator: style!(background, palette.fg).bold(), unselected_char_shortcut: style!(palette.red, palette.fg).bold(), - unselected_char_right_separator: style!(palette.black, palette.fg).bold(), - unselected_styled_text: style!(palette.black, palette.fg).bold(), - unselected_suffix_separator: style!(palette.fg, palette.gray), - disabled_prefix_separator: style!(palette.gray, palette.fg), - disabled_styled_text: style!(palette.gray, palette.fg).dimmed(), - disabled_suffix_separator: style!(palette.fg, palette.gray), - selected_single_letter_prefix_separator: style!(palette.gray, palette.green), + unselected_char_right_separator: style!(background, palette.fg).bold(), + unselected_styled_text: style!(background, palette.fg).bold(), + unselected_suffix_separator: style!(palette.fg, background), + disabled_prefix_separator: style!(background, palette.fg), + disabled_styled_text: style!(background, palette.fg).dimmed(), + disabled_suffix_separator: style!(palette.fg, background), + selected_single_letter_prefix_separator: style!(background, palette.green), selected_single_letter_char_shortcut: style!(palette.red, palette.green).bold(), - selected_single_letter_suffix_separator: style!(palette.green, palette.gray), - unselected_single_letter_prefix_separator: style!(palette.gray, palette.fg), - unselected_single_letter_char_shortcut: style!(palette.red, palette.fg).bold(), - unselected_single_letter_suffix_separator: style!(palette.fg, palette.gray), - superkey_prefix: style!(palette.white, palette.gray).bold(), - superkey_suffix_separator: style!(palette.gray, palette.gray), + selected_single_letter_suffix_separator: style!(palette.green, background), + unselected_single_letter_prefix_separator: style!(background, palette.fg), + unselected_single_letter_char_shortcut: style!(palette.red, palette.fg).bold().dimmed(), + unselected_single_letter_suffix_separator: style!(palette.fg, background), + superkey_prefix: style!(foreground, background).bold(), + superkey_suffix_separator: style!(background, background), }, PaletteSource::Xresources => ColoredElements { - selected_prefix_separator: style!(palette.gray, palette.green), + selected_prefix_separator: style!(background, palette.green), selected_char_left_separator: style!(palette.fg, palette.green).bold(), selected_char_shortcut: style!(palette.red, palette.green).bold(), selected_char_right_separator: style!(palette.fg, palette.green).bold(), - selected_styled_text: style!(palette.gray, palette.green).bold(), - selected_suffix_separator: style!(palette.green, palette.gray).bold(), - unselected_prefix_separator: style!(palette.gray, palette.fg), - unselected_char_left_separator: style!(palette.gray, palette.fg).bold(), + selected_styled_text: style!(background, palette.green).bold(), + selected_suffix_separator: style!(palette.green, background).bold(), + unselected_prefix_separator: style!(background, palette.fg), + unselected_char_left_separator: style!(background, palette.fg).bold(), unselected_char_shortcut: style!(palette.red, palette.fg).bold(), - unselected_char_right_separator: style!(palette.gray, palette.fg).bold(), - unselected_styled_text: style!(palette.gray, palette.fg).bold(), - unselected_suffix_separator: style!(palette.fg, palette.gray), - disabled_prefix_separator: style!(palette.gray, palette.fg), - disabled_styled_text: style!(palette.gray, palette.fg).dimmed(), - disabled_suffix_separator: style!(palette.fg, palette.gray), + unselected_char_right_separator: style!(background, palette.fg).bold(), + unselected_styled_text: style!(background, palette.fg).bold(), + unselected_suffix_separator: style!(palette.fg, background), + disabled_prefix_separator: style!(background, palette.fg), + disabled_styled_text: style!(background, palette.fg).dimmed(), + disabled_suffix_separator: style!(palette.fg, background), selected_single_letter_prefix_separator: style!(palette.fg, palette.green), selected_single_letter_char_shortcut: style!(palette.red, palette.green).bold(), selected_single_letter_suffix_separator: style!(palette.green, palette.fg), - unselected_single_letter_prefix_separator: style!(palette.fg, palette.gray), + unselected_single_letter_prefix_separator: style!(palette.fg, background), unselected_single_letter_char_shortcut: style!(palette.red, palette.fg).bold(), - unselected_single_letter_suffix_separator: style!(palette.fg, palette.gray), - superkey_prefix: style!(palette.gray, palette.fg).bold(), - superkey_suffix_separator: style!(palette.fg, palette.gray), + unselected_single_letter_suffix_separator: style!(palette.fg, background), + superkey_prefix: style!(background, palette.fg).bold(), + superkey_suffix_separator: style!(palette.fg, background), }, } } @@ -189,9 +197,14 @@ impl ZellijPlugin for State { let first_line = format!("{}{}", superkey, ctrl_keys); let second_line = self.second_line(cols); - // [48;5;238m is gray background, [0K is so that it fills the rest of the line + 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, + }; + + // [48;5;238m is white background, [0K is so that it fills the rest of the line // [m is background reset, [0K is so that it clears the rest of the line - match self.mode_info.style.colors.gray { + match background { PaletteColor::Rgb((r, g, b)) => { println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", first_line, r, g, b); } diff --git a/default-plugins/status-bar/src/second_line.rs b/default-plugins/status-bar/src/second_line.rs index 9601c4251..6f7a89a89 100644 --- a/default-plugins/status-bar/src/second_line.rs +++ b/default-plugins/status-bar/src/second_line.rs @@ -4,6 +4,7 @@ use ansi_term::{ Style, }; use zellij_tile::prelude::*; +use zellij_tile_utils::palette_match; use crate::{ tip::{data::TIPS, TipFn}, @@ -29,22 +30,19 @@ fn full_length_shortcut( description: &str, palette: Palette, ) -> LinePart { - let white_color = match palette.white { - PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), - PaletteColor::EightBit(color) => Fixed(color), - }; - let green_color = match palette.green { - PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), - PaletteColor::EightBit(color) => Fixed(color), - }; + let text_color = palette_match!(match palette.theme_hue { + ThemeHue::Dark => palette.white, + ThemeHue::Light => palette.black, + }); + let green_color = palette_match!(palette.green); let separator = if is_first_shortcut { " " } else { " / " }; - let separator = Style::new().fg(white_color).paint(separator); + let separator = Style::new().fg(text_color).paint(separator); let shortcut_len = letter.chars().count() + 3; // 2 for <>'s around shortcut, 1 for the space - let shortcut_left_separator = Style::new().fg(white_color).paint("<"); + let shortcut_left_separator = Style::new().fg(text_color).paint("<"); let shortcut = Style::new().fg(green_color).bold().paint(letter); - let shortcut_right_separator = Style::new().fg(white_color).paint("> "); + let shortcut_right_separator = Style::new().fg(text_color).paint("> "); let description_len = description.chars().count(); - let description = Style::new().fg(white_color).bold().paint(description); + let description = Style::new().fg(text_color).bold().paint(description); let len = shortcut_len + description_len + separator.chars().count(); LinePart { part: ANSIStrings(&[ @@ -65,24 +63,21 @@ fn first_word_shortcut( description: &str, palette: Palette, ) -> LinePart { - let white_color = match palette.white { - PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), - PaletteColor::EightBit(color) => Fixed(color), - }; - let green_color = match palette.green { - PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), - PaletteColor::EightBit(color) => Fixed(color), - }; + let text_color = palette_match!(match palette.theme_hue { + ThemeHue::Dark => palette.white, + ThemeHue::Light => palette.black, + }); + let green_color = palette_match!(palette.green); let separator = if is_first_shortcut { " " } else { " / " }; - let separator = Style::new().fg(white_color).paint(separator); + let separator = Style::new().fg(text_color).paint(separator); let shortcut_len = letter.chars().count() + 3; // 2 for <>'s around shortcut, 1 for the space - let shortcut_left_separator = Style::new().fg(white_color).paint("<"); + let shortcut_left_separator = Style::new().fg(text_color).paint("<"); let shortcut = Style::new().fg(green_color).bold().paint(letter); - let shortcut_right_separator = Style::new().fg(white_color).paint("> "); + let shortcut_right_separator = Style::new().fg(text_color).paint("> "); let description_first_word = description.split(' ').next().unwrap_or(""); let description_first_word_length = description_first_word.chars().count(); let description_first_word = Style::new() - .fg(white_color) + .fg(text_color) .bold() .paint(description_first_word); let len = shortcut_len + description_first_word_length + separator.chars().count(); @@ -102,11 +97,11 @@ fn first_word_shortcut( fn locked_interface_indication(palette: Palette) -> LinePart { let locked_text = " -- INTERFACE LOCKED -- "; let locked_text_len = locked_text.chars().count(); - let white_color = match palette.white { - PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), - PaletteColor::EightBit(color) => Fixed(color), - }; - let locked_styled_text = Style::new().fg(white_color).bold().paint(locked_text); + let text_color = palette_match!(match palette.theme_hue { + ThemeHue::Dark => palette.white, + ThemeHue::Light => palette.black, + }); + let locked_styled_text = Style::new().fg(text_color).bold().paint(locked_text); LinePart { part: locked_styled_text.to_string(), len: locked_text_len, @@ -120,18 +115,9 @@ fn show_extra_hints( use StatusBarTextBoldness::*; use StatusBarTextColor::*; // get the colors - let white_color = match palette.white { - PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), - PaletteColor::EightBit(color) => Fixed(color), - }; - let green_color = match palette.green { - PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), - PaletteColor::EightBit(color) => Fixed(color), - }; - let orange_color = match palette.orange { - PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), - PaletteColor::EightBit(color) => Fixed(color), - }; + let white_color = palette_match!(palette.white); + let green_color = palette_match!(palette.green); + let orange_color = palette_match!(palette.orange); // calculate length of tipp let len = text_with_style .iter() @@ -328,10 +314,7 @@ pub fn keybinds(help: &ModeInfo, tip_name: &str, max_width: usize) -> LinePart { } pub fn text_copied_hint(palette: &Palette, copy_destination: CopyDestination) -> LinePart { - let green_color = match palette.green { - PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), - PaletteColor::EightBit(color) => Fixed(color), - }; + let green_color = palette_match!(palette.green); let hint = match copy_destination { CopyDestination::Command => "Text piped to external command", #[cfg(not(target_os = "macos"))] @@ -348,10 +331,7 @@ pub fn text_copied_hint(palette: &Palette, copy_destination: CopyDestination) -> pub fn system_clipboard_error(palette: &Palette) -> LinePart { let hint = " Error using the system clipboard."; - let red_color = match palette.red { - PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), - PaletteColor::EightBit(color) => Fixed(color), - }; + let red_color = palette_match!(palette.red); LinePart { part: Style::new().fg(red_color).bold().paint(hint).to_string(), len: hint.len(), @@ -359,20 +339,14 @@ pub fn system_clipboard_error(palette: &Palette) -> LinePart { } pub fn fullscreen_panes_to_hide(palette: &Palette, panes_to_hide: usize) -> LinePart { - let white_color = match palette.white { - PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), - PaletteColor::EightBit(color) => Fixed(color), - }; - let green_color = match palette.green { - PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), - PaletteColor::EightBit(color) => Fixed(color), - }; - let orange_color = match palette.orange { - PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), - PaletteColor::EightBit(color) => Fixed(color), - }; - let shortcut_left_separator = Style::new().fg(white_color).bold().paint(" ("); - let shortcut_right_separator = Style::new().fg(white_color).bold().paint("): "); + let text_color = palette_match!(match palette.theme_hue { + ThemeHue::Dark => palette.white, + ThemeHue::Light => palette.black, + }); + let green_color = palette_match!(palette.green); + let orange_color = palette_match!(palette.orange); + let shortcut_left_separator = Style::new().fg(text_color).bold().paint(" ("); + let shortcut_right_separator = Style::new().fg(text_color).bold().paint("): "); let fullscreen = "FULLSCREEN"; let puls = "+ "; let panes = panes_to_hide.to_string(); @@ -388,9 +362,9 @@ pub fn fullscreen_panes_to_hide(palette: &Palette, panes_to_hide: usize) -> Line shortcut_left_separator, Style::new().fg(orange_color).bold().paint(fullscreen), shortcut_right_separator, - Style::new().fg(white_color).bold().paint(puls), + Style::new().fg(text_color).bold().paint(puls), Style::new().fg(green_color).bold().paint(panes), - Style::new().fg(white_color).bold().paint(hide) + Style::new().fg(text_color).bold().paint(hide) ), len, } @@ -532,21 +506,15 @@ pub fn short_tmux_mode_indication(help: &ModeInfo) -> LinePart { } pub fn locked_fullscreen_panes_to_hide(palette: &Palette, panes_to_hide: usize) -> LinePart { - let white_color = match palette.white { - PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), - PaletteColor::EightBit(color) => Fixed(color), - }; - let green_color = match palette.green { - PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), - PaletteColor::EightBit(color) => Fixed(color), - }; - let orange_color = match palette.orange { - PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), - PaletteColor::EightBit(color) => Fixed(color), - }; + let text_color = palette_match!(match palette.theme_hue { + ThemeHue::Dark => palette.white, + ThemeHue::Light => palette.black, + }); + let green_color = palette_match!(palette.green); + let orange_color = palette_match!(palette.orange); let locked_text = " -- INTERFACE LOCKED -- "; - let shortcut_left_separator = Style::new().fg(white_color).bold().paint(" ("); - let shortcut_right_separator = Style::new().fg(white_color).bold().paint("): "); + let shortcut_left_separator = Style::new().fg(text_color).bold().paint(" ("); + let shortcut_right_separator = Style::new().fg(text_color).bold().paint("): "); let fullscreen = "FULLSCREEN"; let puls = "+ "; let panes = panes_to_hide.to_string(); @@ -560,13 +528,13 @@ pub fn locked_fullscreen_panes_to_hide(palette: &Palette, panes_to_hide: usize) LinePart { part: format!( "{}{}{}{}{}{}{}", - Style::new().fg(white_color).bold().paint(locked_text), + Style::new().fg(text_color).bold().paint(locked_text), shortcut_left_separator, Style::new().fg(orange_color).bold().paint(fullscreen), shortcut_right_separator, - Style::new().fg(white_color).bold().paint(puls), + Style::new().fg(text_color).bold().paint(puls), Style::new().fg(green_color).bold().paint(panes), - Style::new().fg(white_color).bold().paint(hide) + Style::new().fg(text_color).bold().paint(hide) ), len, } diff --git a/default-plugins/tab-bar/src/line.rs b/default-plugins/tab-bar/src/line.rs index b8c58854d..51af1474b 100644 --- a/default-plugins/tab-bar/src/line.rs +++ b/default-plugins/tab-bar/src/line.rs @@ -102,11 +102,13 @@ fn left_more_message(tab_count_to_the_left: usize, palette: Palette, separator: // 238 // chars length plus separator length on both sides let more_text_len = more_text.width() + 2 * separator.width(); - let left_separator = style!(palette.gray, palette.orange).paint(separator); - let more_styled_text = style!(palette.black, palette.orange) - .bold() - .paint(more_text); - let right_separator = style!(palette.orange, palette.gray).paint(separator); + let text_color = match palette.theme_hue { + ThemeHue::Dark => palette.white, + ThemeHue::Light => palette.black, + }; + let left_separator = style!(text_color, palette.orange).paint(separator); + let more_styled_text = style!(text_color, palette.orange).bold().paint(more_text); + let right_separator = style!(palette.orange, text_color).paint(separator); let more_styled_text = ANSIStrings(&[left_separator, more_styled_text, right_separator]).to_string(); LinePart { @@ -130,11 +132,13 @@ fn right_more_message( }; // chars length plus separator length on both sides let more_text_len = more_text.width() + 2 * separator.width(); - let left_separator = style!(palette.gray, palette.orange).paint(separator); - let more_styled_text = style!(palette.black, palette.orange) - .bold() - .paint(more_text); - let right_separator = style!(palette.orange, palette.gray).paint(separator); + let text_color = match palette.theme_hue { + ThemeHue::Dark => palette.white, + ThemeHue::Light => palette.black, + }; + let left_separator = style!(text_color, palette.orange).paint(separator); + let more_styled_text = style!(text_color, palette.orange).bold().paint(more_text); + let right_separator = style!(palette.orange, text_color).paint(separator); let more_styled_text = ANSIStrings(&[left_separator, more_styled_text, right_separator]).to_string(); LinePart { @@ -147,9 +151,15 @@ fn tab_line_prefix(session_name: Option<&str>, palette: Palette, cols: usize) -> let prefix_text = " Zellij ".to_string(); let prefix_text_len = prefix_text.chars().count(); - let prefix_styled_text = style!(palette.white, palette.gray) - .bold() - .paint(prefix_text); + let text_color = match palette.theme_hue { + ThemeHue::Dark => palette.white, + ThemeHue::Light => palette.black, + }; + let bg_color = match palette.theme_hue { + ThemeHue::Dark => palette.black, + ThemeHue::Light => palette.white, + }; + let prefix_styled_text = style!(text_color, bg_color).bold().paint(prefix_text); let mut parts = vec![LinePart { part: prefix_styled_text.to_string(), len: prefix_text_len, @@ -157,7 +167,11 @@ fn tab_line_prefix(session_name: Option<&str>, palette: Palette, cols: usize) -> if let Some(name) = session_name { let name_part = format!("({}) ", name); let name_part_len = name_part.width(); - let name_part_styled_text = style!(palette.white, palette.gray).bold().paint(name_part); + let text_color = match palette.theme_hue { + ThemeHue::Dark => palette.white, + ThemeHue::Light => palette.black, + }; + let name_part_styled_text = style!(text_color, bg_color).bold().paint(name_part); if cols.saturating_sub(prefix_text_len) >= name_part_len { parts.push(LinePart { part: name_part_styled_text.to_string(), diff --git a/default-plugins/tab-bar/src/main.rs b/default-plugins/tab-bar/src/main.rs index 2067af9d2..726a77d16 100644 --- a/default-plugins/tab-bar/src/main.rs +++ b/default-plugins/tab-bar/src/main.rs @@ -119,7 +119,11 @@ impl ZellijPlugin for State { } len_cnt += bar_part.len; } - match self.mode_info.style.colors.gray { + 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)) => { println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", s, r, g, b); } diff --git a/default-plugins/tab-bar/src/tab.rs b/default-plugins/tab-bar/src/tab.rs index 4ed3b2076..993489620 100644 --- a/default-plugins/tab-bar/src/tab.rs +++ b/default-plugins/tab-bar/src/tab.rs @@ -25,24 +25,28 @@ pub fn render_tab( active: bool, ) -> LinePart { let background_color = if active { palette.green } else { palette.fg }; - let left_separator = style!(palette.gray, background_color).paint(separator); + let foreground_color = match palette.theme_hue { + ThemeHue::Dark => palette.black, + ThemeHue::Light => palette.white, + }; + let left_separator = style!(foreground_color, background_color).paint(separator); let mut tab_text_len = text.width() + 2 + separator.width() * 2; // 2 for left and right separators, 2 for the text padding - let tab_styled_text = style!(palette.black, background_color) + let tab_styled_text = style!(foreground_color, background_color) .bold() .paint(format!(" {} ", text)); - let right_separator = style!(background_color, palette.gray).paint(separator); + let right_separator = style!(background_color, foreground_color).paint(separator); let tab_styled_text = if !focused_clients.is_empty() { let (cursor_section, extra_length) = cursors(focused_clients, palette); tab_text_len += extra_length; let mut s = String::new(); - let cursor_beginning = style!(palette.black, background_color) + let cursor_beginning = style!(foreground_color, background_color) .bold() .paint("[") .to_string(); let cursor_section = ANSIStrings(&cursor_section).to_string(); - let cursor_end = style!(palette.black, background_color) + let cursor_end = style!(foreground_color, background_color) .bold() .paint("]") .to_string(); |