Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theme definition #3242

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a6dd070
Implement initial structs from spec
DeaconDesperado Feb 12, 2024
2bbe0a5
kdl configuration unmarshalling
DeaconDesperado Feb 12, 2024
9a14b57
Configuration of styles
DeaconDesperado Feb 20, 2024
17c522a
provisional styling of status bar component
DeaconDesperado Feb 27, 2024
127bd5e
status bar tips
DeaconDesperado Mar 29, 2024
8cb4bad
initial conversion palette->styling
DeaconDesperado Mar 29, 2024
ec45544
further style corrections to status bar
DeaconDesperado Mar 29, 2024
d1f0030
support alternate tab coloration
DeaconDesperado Apr 1, 2024
ac21871
tab bar and compact bar themeing
DeaconDesperado Apr 1, 2024
3c27075
plugin loading indication coloration
DeaconDesperado Apr 1, 2024
5c5f6c9
correct handling of arrow dividers
DeaconDesperado Apr 1, 2024
4e67c80
session manager prompt coloration
DeaconDesperado Apr 1, 2024
f550aec
client id based coloration draft
DeaconDesperado Apr 2, 2024
14fd2f9
naming for style specification
DeaconDesperado Apr 2, 2024
ed5a0b6
clean up unused params + vars
DeaconDesperado Apr 2, 2024
c38061c
corrections to exit code coloration
DeaconDesperado Apr 2, 2024
f8a6792
tip coloration
DeaconDesperado Apr 3, 2024
651aad6
selected list coloration
DeaconDesperado Apr 3, 2024
4469079
handle ThemeHue in palette conversion
DeaconDesperado Apr 3, 2024
96951fd
further compact bar coloration
DeaconDesperado Apr 3, 2024
f1cc117
panes coloration
DeaconDesperado Apr 3, 2024
3f7f8eb
styling -> palette into
DeaconDesperado Apr 3, 2024
6e8a5c6
migrate palette backwards compat to plugin-api
DeaconDesperado Apr 3, 2024
2292481
temporarily ignore snapshot assertions for draft
DeaconDesperado Apr 3, 2024
def2f5b
convert to structs with named fields
DeaconDesperado May 21, 2024
0ffbb8b
implement multiplayer colors
DeaconDesperado May 21, 2024
d4ba7d3
corrections
DeaconDesperado May 21, 2024
60f3580
WIP session manager
DeaconDesperado May 21, 2024
b898668
text styling for nested list
DeaconDesperado Jun 3, 2024
1990c91
emphasis styling for all components
DeaconDesperado Jun 4, 2024
db28a8e
default logic for new kdl styles
DeaconDesperado Jun 4, 2024
5ab6f83
pass style declaration explicity in UI components
DeaconDesperado Jun 5, 2024
8409da2
update test snapshots
DeaconDesperado Jul 10, 2024
6c44157
formatting
DeaconDesperado Jun 28, 2024
e90623a
correct styling for selected text
DeaconDesperado Jul 2, 2024
6651290
Add frame_highlight specification for non-normal state
DeaconDesperado Jul 2, 2024
52dff3f
update snapshots for theme
DeaconDesperado Jul 10, 2024
08745a5
remove unused import
DeaconDesperado Jul 10, 2024
ecb7948
incorporate new status bar ui into theming
DeaconDesperado Jul 8, 2024
0bc59cd
improve test coverage of config behavior
DeaconDesperado Jul 10, 2024
c06476e
tab bar correction
DeaconDesperado Jul 12, 2024
23855fd
correct also compact bar
DeaconDesperado Jul 12, 2024
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
94 changes: 42 additions & 52 deletions default-plugins/compact-bar/src/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn populate_tabs_in_tab_line(
tabs_after_active: &mut Vec<LinePart>,
tabs_to_render: &mut Vec<LinePart>,
cols: usize,
palette: Palette,
palette: Styling,
capabilities: PluginCapabilities,
) {
let mut middle_size = get_current_title_len(tabs_to_render);
Expand Down Expand Up @@ -107,7 +107,7 @@ fn populate_tabs_in_tab_line(

fn left_more_message(
tab_count_to_the_left: usize,
palette: Palette,
palette: Styling,
separator: &str,
tab_index: usize,
) -> LinePart {
Expand All @@ -122,13 +122,14 @@ fn left_more_message(
// 238
// chars length plus separator length on both sides
let more_text_len = more_text.width() + 2 * separator.width();
let (text_color, sep_color) = match palette.theme_hue {
ThemeHue::Dark => (palette.white, palette.black),
ThemeHue::Light => (palette.black, palette.white),
};
let left_separator = style!(sep_color, palette.orange).paint(separator);
let more_styled_text = style!(text_color, palette.orange).bold().paint(more_text);
let right_separator = style!(palette.orange, sep_color).paint(separator);
let (text_color, sep_color) = (
palette.ribbon_unselected.base,
palette.text_unselected.background,
);
let plus_ribbon_bg = palette.text_selected.emphasis_1;
let left_separator = style!(sep_color, plus_ribbon_bg).paint(separator);
let more_styled_text = style!(text_color, plus_ribbon_bg).bold().paint(more_text);
let right_separator = style!(plus_ribbon_bg, sep_color).paint(separator);
let more_styled_text =
ANSIStrings(&[left_separator, more_styled_text, right_separator]).to_string();
LinePart {
Expand All @@ -140,7 +141,7 @@ fn left_more_message(

fn right_more_message(
tab_count_to_the_right: usize,
palette: Palette,
palette: Styling,
separator: &str,
tab_index: usize,
) -> LinePart {
Expand All @@ -154,13 +155,15 @@ fn right_more_message(
};
// chars length plus separator length on both sides
let more_text_len = more_text.width() + 2 * separator.width();
let (text_color, sep_color) = match palette.theme_hue {
ThemeHue::Dark => (palette.white, palette.black),
ThemeHue::Light => (palette.black, palette.white),
};
let left_separator = style!(sep_color, palette.orange).paint(separator);
let more_styled_text = style!(text_color, palette.orange).bold().paint(more_text);
let right_separator = style!(palette.orange, sep_color).paint(separator);

let (text_color, sep_color) = (
palette.ribbon_unselected.base,
palette.text_unselected.background,
);
let plus_ribbon_bg = palette.text_selected.emphasis_1;
let left_separator = style!(sep_color, plus_ribbon_bg).paint(separator);
let more_styled_text = style!(text_color, plus_ribbon_bg).bold().paint(more_text);
let right_separator = style!(plus_ribbon_bg, sep_color).paint(separator);
let more_styled_text =
ANSIStrings(&[left_separator, more_styled_text, right_separator]).to_string();
LinePart {
Expand All @@ -173,24 +176,17 @@ fn right_more_message(
fn tab_line_prefix(
session_name: Option<&str>,
mode: InputMode,
palette: Palette,
palette: Styling,
cols: usize,
) -> Vec<LinePart> {
let prefix_text = " Zellij ".to_string();

let prefix_text_len = prefix_text.chars().count();
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 locked_mode_color = palette.magenta;
let normal_mode_color = palette.green;
let other_modes_color = palette.orange;
let text_color = palette.text_unselected.base;
let bg_color = palette.text_unselected.background;
let locked_mode_color = palette.text_unselected.emphasis_4;
let normal_mode_color = palette.text_unselected.emphasis_3;
let other_modes_color = palette.text_unselected.emphasis_1;

let prefix_styled_text = style!(text_color, bg_color).bold().paint(prefix_text);
let mut parts = vec![LinePart {
Expand All @@ -201,10 +197,6 @@ fn tab_line_prefix(
if let Some(name) = session_name {
let name_part = format!("({})", name);
let name_part_len = name_part.width();
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 {
Expand Down Expand Up @@ -253,7 +245,7 @@ pub fn tab_line(
mut all_tabs: Vec<LinePart>,
active_tab_index: usize,
cols: usize,
palette: Palette,
palette: Styling,
capabilities: PluginCapabilities,
hide_session_name: bool,
mode: InputMode,
Expand Down Expand Up @@ -293,6 +285,7 @@ pub fn tab_line(
let current_title_len = get_current_title_len(&prefix);
if current_title_len < cols {
let mut remaining_space = cols - current_title_len;
let remaining_bg = palette.text_unselected.background;
if let Some(swap_layout_status) = swap_layout_status(
remaining_space,
active_swap_layout_name,
Expand All @@ -304,7 +297,7 @@ pub fn tab_line(
remaining_space -= swap_layout_status.len;
let mut buffer = String::new();
for _ in 0..remaining_space {
buffer.push_str(&style!(palette.black, palette.black).paint(" ").to_string());
buffer.push_str(&style!(remaining_bg, remaining_bg).paint(" ").to_string());
}
prefix.push(LinePart {
part: buffer,
Expand All @@ -323,39 +316,36 @@ fn swap_layout_status(
swap_layout_name: &Option<String>,
is_swap_layout_damaged: bool,
input_mode: InputMode,
palette: &Palette,
palette: &Styling,
separator: &str,
) -> Option<LinePart> {
match swap_layout_name {
Some(swap_layout_name) => {
let mut swap_layout_name = format!(" {} ", swap_layout_name);
swap_layout_name.make_ascii_uppercase();
let swap_layout_name_len = swap_layout_name.len() + 3;
let bg = palette.text_unselected.background;
let fg = palette.ribbon_unselected.background;
let green = palette.ribbon_selected.background;

let (prefix_separator, swap_layout_name, suffix_separator) =
if input_mode == InputMode::Locked {
(
style!(palette.black, palette.fg).paint(separator),
style!(palette.black, palette.fg)
.italic()
.paint(&swap_layout_name),
style!(palette.fg, palette.black).paint(separator),
style!(bg, fg).paint(separator),
style!(bg, fg).italic().paint(&swap_layout_name),
style!(fg, bg).paint(separator),
)
} else if is_swap_layout_damaged {
(
style!(palette.black, palette.fg).paint(separator),
style!(palette.black, palette.fg)
.bold()
.paint(&swap_layout_name),
style!(palette.fg, palette.black).paint(separator),
style!(bg, fg).paint(separator),
style!(bg, fg).bold().paint(&swap_layout_name),
style!(fg, bg).paint(separator),
)
} else {
(
style!(palette.black, palette.green).paint(separator),
style!(palette.black, palette.green)
.bold()
.paint(&swap_layout_name),
style!(palette.green, palette.black).paint(separator),
style!(bg, green).paint(separator),
style!(bg, green).bold().paint(&swap_layout_name),
style!(green, bg).paint(separator),
)
};
let swap_layout_indicator = format!(
Expand Down
5 changes: 1 addition & 4 deletions default-plugins/compact-bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,7 @@ impl ZellijPlugin for State {
.tab_line
.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,
};
let background = self.mode_info.style.colors.text_unselected.background;
match background {
PaletteColor::Rgb((r, g, b)) => {
print!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", output, r, g, b);
Expand Down
35 changes: 19 additions & 16 deletions default-plugins/compact-bar/src/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use unicode_width::UnicodeWidthStr;
use zellij_tile::prelude::*;
use zellij_tile_utils::style;

fn cursors(focused_clients: &[ClientId], palette: Palette) -> (Vec<ANSIString>, usize) {
fn cursors(focused_clients: &[ClientId], colors: MultiplayerColors) -> (Vec<ANSIString>, usize) {
// cursor section, text length
let mut len = 0;
let mut cursors = vec![];
for client_id in focused_clients.iter() {
if let Some(color) = client_id_to_colors(*client_id, palette) {
if let Some(color) = client_id_to_colors(*client_id, colors) {
cursors.push(style!(color.1, color.0).paint(" "));
len += 1;
}
Expand All @@ -21,37 +21,40 @@ pub fn render_tab(
text: String,
tab: &TabInfo,
is_alternate_tab: bool,
palette: Palette,
palette: Styling,
separator: &str,
) -> LinePart {
let focused_clients = tab.other_focused_clients.as_slice();
let separator_width = separator.width();
let alternate_tab_color = match palette.theme_hue {
// TODO: only do this if we don't have the arrow capabilities
ThemeHue::Dark => palette.white,
ThemeHue::Light => palette.black,
let alternate_tab_color = if is_alternate_tab {
palette.ribbon_unselected.emphasis_1
} else {
palette.ribbon_unselected.background
};
let background_color = if tab.active {
palette.green
palette.ribbon_selected.background
} else if is_alternate_tab {
alternate_tab_color
} else {
palette.fg
palette.ribbon_unselected.background
};
let foreground_color = match palette.theme_hue {
ThemeHue::Dark => palette.black,
ThemeHue::Light => palette.white,
let foreground_color = if tab.active {
palette.ribbon_selected.base
} else {
palette.ribbon_unselected.base
};
let left_separator = style!(foreground_color, background_color).paint(separator);
let separator_fill_color = palette.text_unselected.background;
let left_separator = style!(separator_fill_color, background_color).paint(separator);
let mut tab_text_len = text.width() + (separator_width * 2) + 2; // + 2 for padding

let tab_styled_text = style!(foreground_color, background_color)
.bold()
.paint(format!(" {} ", text));

let right_separator = style!(background_color, foreground_color).paint(separator);
let right_separator = style!(background_color, separator_fill_color).paint(separator);
let tab_styled_text = if !focused_clients.is_empty() {
let (cursor_section, extra_length) = cursors(focused_clients, palette);
let (cursor_section, extra_length) =
cursors(focused_clients, palette.multiplayer_user_colors);
tab_text_len += extra_length;
let mut s = String::new();
let cursor_beginning = style!(foreground_color, background_color)
Expand Down Expand Up @@ -85,7 +88,7 @@ pub fn tab_style(
mut tabname: String,
tab: &TabInfo,
mut is_alternate_tab: bool,
palette: Palette,
palette: Styling,
capabilities: PluginCapabilities,
) -> LinePart {
let separator = tab_separator(capabilities);
Expand Down
Loading
Loading