summaryrefslogtreecommitdiffstats
path: root/default-plugins
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2021-05-04 16:06:55 +0200
committerGitHub <noreply@github.com>2021-05-04 16:06:55 +0200
commit1f88b342e2a381b958da4bebd852b73e42db1a8c (patch)
tree0edaf24bdfbe85c0f51a71ecf26a29d626d9e25d /default-plugins
parentf2f20f676fbcc408feac75d92d80d221a43b433e (diff)
fix(colors): stabilize colors (#453)
* fix(colors): stabilize colors * style(fmt): rustfmt
Diffstat (limited to 'default-plugins')
-rw-r--r--default-plugins/status-bar/src/first_line.rs2
-rw-r--r--default-plugins/status-bar/src/main.rs25
-rw-r--r--default-plugins/status-bar/src/second_line.rs188
-rw-r--r--default-plugins/tab-bar/src/line.rs14
-rw-r--r--default-plugins/tab-bar/src/main.rs15
-rw-r--r--default-plugins/tab-bar/src/tab.rs8
6 files changed, 122 insertions, 130 deletions
diff --git a/default-plugins/status-bar/src/first_line.rs b/default-plugins/status-bar/src/first_line.rs
index 77cb4dfc5..f679e8637 100644
--- a/default-plugins/status-bar/src/first_line.rs
+++ b/default-plugins/status-bar/src/first_line.rs
@@ -232,7 +232,7 @@ fn key_indicators(max_len: usize, keys: &[CtrlKeyShortcut], palette: ColoredElem
}
pub fn superkey(palette: ColoredElements) -> LinePart {
- let prefix_text = " Ctrl + ";
+ let prefix_text = " Ctrl +";
let prefix = palette.superkey_prefix.paint(prefix_text);
let suffix_separator = palette.superkey_suffix_separator.paint(ARROW_SEPARATOR);
LinePart {
diff --git a/default-plugins/status-bar/src/main.rs b/default-plugins/status-bar/src/main.rs
index 93898cea3..2613ba79a 100644
--- a/default-plugins/status-bar/src/main.rs
+++ b/default-plugins/status-bar/src/main.rs
@@ -80,18 +80,18 @@ fn color_elements(palette: Palette) -> ColoredElements {
selected_styled_text: style!(palette.black, palette.green).bold(),
selected_suffix_separator: style!(palette.green, palette.bg).bold(),
unselected_prefix_separator: style!(palette.bg, palette.fg),
- unselected_char_left_separator: style!(palette.bg, palette.fg).bold(),
+ unselected_char_left_separator: style!(palette.black, palette.fg).bold(),
unselected_char_shortcut: style!(palette.red, palette.fg).bold(),
- unselected_char_right_separator: style!(palette.bg, 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.bg),
disabled_prefix_separator: style!(palette.bg, palette.fg),
disabled_styled_text: style!(palette.bg, palette.fg).dimmed(),
disabled_suffix_separator: style!(palette.fg, palette.bg),
- selected_single_letter_prefix_separator: style!(palette.fg, palette.green),
+ selected_single_letter_prefix_separator: style!(palette.bg, 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.bg),
+ selected_single_letter_suffix_separator: style!(palette.green, palette.bg),
+ unselected_single_letter_prefix_separator: style!(palette.bg, palette.fg),
unselected_single_letter_char_shortcut: style!(palette.red, palette.fg).bold(),
unselected_single_letter_suffix_separator: style!(palette.fg, palette.bg),
superkey_prefix: style!(palette.white, palette.bg).bold(),
@@ -149,13 +149,14 @@ impl ZellijPlugin for State {
// [48;5;238m is gray 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
- println!(
- "{}\u{1b}[48;2;{};{};{}m\u{1b}[0K",
- first_line,
- self.mode_info.palette.bg.0,
- self.mode_info.palette.bg.1,
- self.mode_info.palette.bg.2
- );
+ match self.mode_info.palette.bg {
+ PaletteColor::Rgb((r, g, b)) => {
+ println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", first_line, r, g, b);
+ }
+ PaletteColor::EightBit(color) => {
+ println!("{}\u{1b}[48;5;{}m\u{1b}[0K", first_line, color);
+ }
+ }
println!("\u{1b}[m{}\u{1b}[0K", second_line);
}
}
diff --git a/default-plugins/status-bar/src/second_line.rs b/default-plugins/status-bar/src/second_line.rs
index 6982c4103..0861c4646 100644
--- a/default-plugins/status-bar/src/second_line.rs
+++ b/default-plugins/status-bar/src/second_line.rs
@@ -1,5 +1,8 @@
-// use colored::*;
-use ansi_term::{ANSIStrings, Color::RGB, Style};
+use ansi_term::{
+ ANSIStrings,
+ Color::{Fixed, RGB},
+ Style,
+};
use zellij_tile::prelude::*;
use crate::{LinePart, MORE_MSG};
@@ -10,26 +13,22 @@ 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 separator = if is_first_shortcut { " " } else { " / " };
- let separator = Style::new()
- .fg(RGB(palette.fg.0, palette.fg.1, palette.fg.2))
- .paint(separator);
+ let separator = Style::new().fg(white_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(RGB(palette.fg.0, palette.fg.1, palette.fg.2))
- .paint("<");
- let shortcut = Style::new()
- .fg(RGB(palette.green.0, palette.green.1, palette.green.2))
- .bold()
- .paint(letter);
- let shortcut_right_separator = Style::new()
- .fg(RGB(palette.fg.0, palette.fg.1, palette.fg.2))
- .paint("> ");
+ let shortcut_left_separator = Style::new().fg(white_color).paint("<");
+ let shortcut = Style::new().fg(green_color).bold().paint(letter);
+ let shortcut_right_separator = Style::new().fg(white_color).paint("> ");
let description_len = description.chars().count();
- let description = Style::new()
- .fg(RGB(palette.fg.0, palette.fg.1, palette.fg.2))
- .bold()
- .paint(description);
+ let description = Style::new().fg(white_color).bold().paint(description);
let len = shortcut_len + description_len + separator.chars().count();
LinePart {
part: format!(
@@ -52,25 +51,24 @@ 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 separator = if is_first_shortcut { " " } else { " / " };
- let separator = Style::new()
- .fg(RGB(palette.fg.0, palette.fg.1, palette.fg.2))
- .paint(separator);
+ let separator = Style::new().fg(white_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(RGB(palette.fg.0, palette.fg.1, palette.fg.2))
- .paint("<");
- let shortcut = Style::new()
- .fg(RGB(palette.green.0, palette.green.1, palette.green.2))
- .bold()
- .paint(letter);
- let shortcut_right_separator = Style::new()
- .fg(RGB(palette.fg.0, palette.fg.1, palette.fg.2))
- .paint("> ");
+ let shortcut_left_separator = Style::new().fg(white_color).paint("<");
+ let shortcut = Style::new().fg(green_color).bold().paint(letter);
+ let shortcut_right_separator = Style::new().fg(white_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(RGB(palette.fg.0, palette.fg.1, palette.fg.2))
+ .fg(white_color)
.bold()
.paint(description_first_word);
let len = shortcut_len + description_first_word_length + separator.chars().count();
@@ -111,34 +109,30 @@ fn quicknav_full(palette: Palette) -> LinePart {
+ text_fifth_part.chars().count()
+ hjkl_navigation.chars().count()
+ text_sixths_part.chars().count();
+ 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),
+ };
LinePart {
part: format!(
"{}{}{}{}{}{}{}{}{}{}{}",
text_first_part,
- Style::new()
- .fg(RGB(palette.orange.0, palette.orange.1, palette.orange.2))
- .bold()
- .paint(alt),
+ Style::new().fg(orange_color).bold().paint(alt),
text_second_part,
- Style::new()
- .fg(RGB(palette.green.0, palette.green.1, palette.green.2))
- .bold()
- .paint(new_pane_shortcut),
+ Style::new().fg(green_color).bold().paint(new_pane_shortcut),
text_third_part,
- Style::new()
- .fg(RGB(palette.orange.0, palette.orange.1, palette.orange.2))
- .bold()
- .paint(second_alt),
+ Style::new().fg(orange_color).bold().paint(second_alt),
text_fourth_part,
Style::new()
- .fg(RGB(palette.green.0, palette.green.1, palette.green.2))
+ .fg(green_color)
.bold()
.paint(brackets_navigation),
text_fifth_part,
- Style::new()
- .fg(RGB(palette.green.0, palette.green.1, palette.green.2))
- .bold()
- .paint(hjkl_navigation),
+ Style::new().fg(green_color).bold().paint(hjkl_navigation),
text_sixths_part,
),
len,
@@ -168,34 +162,30 @@ fn quicknav_medium(palette: Palette) -> LinePart {
+ text_fifth_part.chars().count()
+ hjkl_navigation.chars().count()
+ text_sixths_part.chars().count();
+ 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),
+ };
LinePart {
part: format!(
"{}{}{}{}{}{}{}{}{}{}{}",
text_first_part,
- Style::new()
- .fg(RGB(palette.orange.0, palette.orange.1, palette.orange.2))
- .bold()
- .paint(alt),
+ Style::new().fg(orange_color).bold().paint(alt),
text_second_part,
- Style::new()
- .fg(RGB(palette.green.0, palette.green.1, palette.green.2))
- .bold()
- .paint(new_pane_shortcut),
+ Style::new().fg(green_color).bold().paint(new_pane_shortcut),
text_third_part,
- Style::new()
- .fg(RGB(palette.orange.0, palette.orange.1, palette.orange.2))
- .bold()
- .paint(second_alt),
+ Style::new().fg(orange_color).bold().paint(second_alt),
text_fourth_part,
Style::new()
- .fg(RGB(palette.green.0, palette.green.1, palette.green.2))
+ .fg(green_color)
.bold()
.paint(brackets_navigation),
text_fifth_part,
- Style::new()
- .fg(RGB(palette.green.0, palette.green.1, palette.green.2))
- .bold()
- .paint(hjkl_navigation),
+ Style::new().fg(green_color).bold().paint(hjkl_navigation),
text_sixths_part,
),
len,
@@ -219,29 +209,28 @@ fn quicknav_short(palette: Palette) -> LinePart {
+ brackets_navigation.chars().count()
+ text_fifth_part.chars().count()
+ hjkl_navigation.chars().count();
+ 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),
+ };
LinePart {
part: format!(
"{}{}{}{}{}{}{}{}",
text_first_part,
- Style::new()
- .fg(RGB(palette.orange.0, palette.orange.1, palette.orange.2))
- .bold()
- .paint(alt),
+ Style::new().fg(orange_color).bold().paint(alt),
text_second_part,
- Style::new()
- .fg(RGB(palette.green.0, palette.green.1, palette.green.2))
- .bold()
- .paint(new_pane_shortcut),
+ Style::new().fg(green_color).bold().paint(new_pane_shortcut),
text_third_part,
Style::new()
- .fg(RGB(palette.green.0, palette.green.1, palette.green.2))
+ .fg(green_color)
.bold()
.paint(brackets_navigation),
text_fifth_part,
- Style::new()
- .fg(RGB(palette.green.0, palette.green.1, palette.green.2))
- .bold()
- .paint(hjkl_navigation),
+ Style::new().fg(green_color).bold().paint(hjkl_navigation),
),
len,
}
@@ -250,10 +239,11 @@ fn quicknav_short(palette: Palette) -> LinePart {
fn locked_interface_indication(palette: Palette) -> LinePart {
let locked_text = " -- INTERFACE LOCKED -- ";
let locked_text_len = locked_text.chars().count();
- let locked_styled_text = Style::new()
- .fg(RGB(palette.fg.0, palette.fg.1, palette.fg.2))
- .bold()
- .paint(locked_text);
+ 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);
LinePart {
part: format!("{}", locked_styled_text),
len: locked_text_len,
@@ -264,25 +254,21 @@ fn select_pane_shortcut(is_first_shortcut: bool, palette: Palette) -> LinePart {
let shortcut = "ENTER";
let description = "Select pane";
let separator = if is_first_shortcut { " " } else { " / " };
- let separator = Style::new()
- .fg(RGB(palette.fg.0, palette.fg.1, palette.fg.2))
- .paint(separator);
+ let white_color = match palette.white {
+ 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 separator = Style::new().fg(white_color).paint(separator);
let shortcut_len = shortcut.chars().count() + 3; // 2 for <>'s around shortcut, 1 for the space
- let shortcut_left_separator = Style::new()
- .fg(RGB(palette.fg.0, palette.fg.1, palette.fg.2))
- .paint("<");
- let shortcut = Style::new()
- .fg(RGB(palette.orange.0, palette.orange.1, palette.orange.2))
- .bold()
- .paint(shortcut);
- let shortcut_right_separator = Style::new()
- .fg(RGB(palette.fg.0, palette.fg.1, palette.fg.2))
- .paint("> ");
+ let shortcut_left_separator = Style::new().fg(white_color).paint("<");
+ let shortcut = Style::new().fg(orange_color).bold().paint(shortcut);
+ let shortcut_right_separator = Style::new().fg(white_color).paint("> ");
let description_len = description.chars().count();
- let description = Style::new()
- .fg(RGB(palette.fg.0, palette.fg.1, palette.fg.2))
- .bold()
- .paint(description);
+ let description = Style::new().fg(white_color).bold().paint(description);
let len = shortcut_len + description_len + separator.chars().count();
LinePart {
part: format!(
diff --git a/default-plugins/tab-bar/src/line.rs b/default-plugins/tab-bar/src/line.rs
index 98ad51668..cd8346557 100644
--- a/default-plugins/tab-bar/src/line.rs
+++ b/default-plugins/tab-bar/src/line.rs
@@ -62,8 +62,10 @@ fn left_more_message(tab_count_to_the_left: usize, palette: Palette) -> LinePart
};
// 238
let more_text_len = more_text.chars().count() + 2; // 2 for the arrows
- let left_separator = style!(palette.fg, palette.orange).paint(ARROW_SEPARATOR);
- let more_styled_text = style!(palette.fg, palette.orange).bold().paint(more_text);
+ let left_separator = style!(palette.bg, palette.orange).paint(ARROW_SEPARATOR);
+ let more_styled_text = style!(palette.black, palette.orange)
+ .bold()
+ .paint(more_text);
let right_separator = style!(palette.orange, palette.bg).paint(ARROW_SEPARATOR);
let more_styled_text = format!(
"{}",
@@ -88,8 +90,10 @@ fn right_more_message(tab_count_to_the_right: usize, palette: Palette) -> LinePa
" +many → ".to_string()
};
let more_text_len = more_text.chars().count() + 1; // 2 for the arrow
- let left_separator = style!(palette.fg, palette.orange).paint(ARROW_SEPARATOR);
- let more_styled_text = style!(palette.fg, palette.orange).bold().paint(more_text);
+ let left_separator = style!(palette.bg, palette.orange).paint(ARROW_SEPARATOR);
+ let more_styled_text = style!(palette.black, palette.orange)
+ .bold()
+ .paint(more_text);
let right_separator = style!(palette.orange, palette.bg).paint(ARROW_SEPARATOR);
let more_styled_text = format!(
"{}",
@@ -137,7 +141,7 @@ fn add_next_tabs_msg(
fn tab_line_prefix(palette: Palette) -> LinePart {
let prefix_text = " Zellij ".to_string();
let prefix_text_len = prefix_text.chars().count();
- let prefix_styled_text = style!(palette.fg, palette.bg).bold().paint(prefix_text);
+ let prefix_styled_text = style!(palette.white, palette.bg).bold().paint(prefix_text);
LinePart {
part: format!("{}", prefix_styled_text),
len: prefix_text_len,
diff --git a/default-plugins/tab-bar/src/main.rs b/default-plugins/tab-bar/src/main.rs
index 1c6d584e3..c62770137 100644
--- a/default-plugins/tab-bar/src/main.rs
+++ b/default-plugins/tab-bar/src/main.rs
@@ -68,12 +68,13 @@ impl ZellijPlugin for State {
for bar_part in tab_line {
s = format!("{}{}", s, bar_part.part);
}
- println!(
- "{}\u{1b}[48;2;{};{};{}m\u{1b}[0K",
- s,
- self.mode_info.palette.bg.0,
- self.mode_info.palette.bg.1,
- self.mode_info.palette.bg.2
- );
+ match self.mode_info.palette.bg {
+ PaletteColor::Rgb((r, g, b)) => {
+ println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", s, r, g, b);
+ }
+ PaletteColor::EightBit(color) => {
+ println!("{}\u{1b}[48;5;{}m\u{1b}[0K", s, color);
+ }
+ }
}
}
diff --git a/default-plugins/tab-bar/src/tab.rs b/default-plugins/tab-bar/src/tab.rs
index ab110634a..b89ccb7b7 100644
--- a/default-plugins/tab-bar/src/tab.rs
+++ b/default-plugins/tab-bar/src/tab.rs
@@ -6,7 +6,7 @@ use zellij_tile_extra::*;
pub fn active_tab(text: String, palette: Palette) -> LinePart {
let left_separator = style!(palette.bg, palette.green).paint(ARROW_SEPARATOR);
let tab_text_len = text.chars().count() + 4; // 2 for left and right separators, 2 for the text padding
- let tab_styled_text = style!(palette.bg, palette.green)
+ let tab_styled_text = style!(palette.black, palette.green)
.bold()
.paint(format!(" {} ", text));
let right_separator = style!(palette.green, palette.bg).paint(ARROW_SEPARATOR);
@@ -21,12 +21,12 @@ pub fn active_tab(text: String, palette: Palette) -> LinePart {
}
pub fn non_active_tab(text: String, palette: Palette) -> LinePart {
- let left_separator = style!(palette.bg, palette.bg).paint(ARROW_SEPARATOR);
+ let left_separator = style!(palette.bg, palette.fg).paint(ARROW_SEPARATOR);
let tab_text_len = text.chars().count() + 4; // 2 for left and right separators, 2 for the padding
- let tab_styled_text = style!(palette.fg, palette.bg)
+ let tab_styled_text = style!(palette.black, palette.fg)
.bold()
.paint(format!(" {} ", text));
- let right_separator = style!(palette.bg, palette.bg).paint(ARROW_SEPARATOR);
+ let right_separator = style!(palette.fg, palette.bg).paint(ARROW_SEPARATOR);
let tab_styled_text = format!(
"{}",
ANSIStrings(&[left_separator, tab_styled_text, right_separator,])