Skip to content

Commit

Permalink
fix(colors): stabilize colors (#453)
Browse files Browse the repository at this point in the history
* fix(colors): stabilize colors

* style(fmt): rustfmt
  • Loading branch information
imsnif authored May 4, 2021
1 parent f2f20f6 commit 1f88b34
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 301 deletions.
28 changes: 0 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ lazy_static = "1.4.0"
wasmer = "1.0.0"
wasmer-wasi = "1.0.0"
interprocess = "1.0.1"
xrdb = "0.1.1"
colors-transform = "0.2.5"
zellij-tile = { path = "zellij-tile/", version = "1.1.0" }
zellij-tile-extra = { path = "zellij-tile-extra/", version="1.0.0" }
Expand Down
2 changes: 1 addition & 1 deletion default-plugins/status-bar/src/first_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
25 changes: 13 additions & 12 deletions default-plugins/status-bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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);
}
}
188 changes: 87 additions & 101 deletions default-plugins/status-bar/src/second_line.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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!(
Expand All @@ -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();
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
}
Expand All @@ -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,
Expand All @@ -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!(
Expand Down
Loading

0 comments on commit 1f88b34

Please sign in to comment.