Skip to content

Commit

Permalink
update newer plugins to use styling struct
Browse files Browse the repository at this point in the history
  • Loading branch information
DeaconDesperado committed Nov 1, 2024
1 parent f944d62 commit 85445c6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 24 deletions.
4 changes: 2 additions & 2 deletions default-plugins/configuration/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct State {
ui_size: usize,
current_screen: Screen,
latest_mode_info: Option<ModeInfo>,
colors: Palette,
colors: Styling,
}

impl Default for State {
Expand All @@ -82,7 +82,7 @@ impl Default for State {
ui_size: UI_SIZE,
current_screen: Screen::default(),
latest_mode_info: None,
colors: Palette::default(),
colors: Palette::default().into(),
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions default-plugins/configuration/src/ui_components.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use crate::{Screen, WIDTH_BREAKPOINTS};
use zellij_tile::prelude::*;

pub fn top_tab_menu(cols: usize, current_screen: &Screen, colors: &Palette) {
let background = match colors.theme_hue {
ThemeHue::Dark => colors.black,
ThemeHue::Light => colors.white,
};
pub fn top_tab_menu(cols: usize, current_screen: &Screen, colors: &Styling) {
let background = colors.text_unselected.background;
let bg_color = 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),
Expand Down
13 changes: 5 additions & 8 deletions default-plugins/plugin-manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct NewPluginScreen {
selected_config_index: Option<usize>,
request_ids: Vec<String>,
load_in_background: bool,
colors: Palette,
colors: Styling,
}

impl Default for NewPluginScreen {
Expand All @@ -50,13 +50,13 @@ impl Default for NewPluginScreen {
selected_config_index: None,
request_ids: vec![],
load_in_background: true,
colors: Palette::default(),
colors: Palette::default().into(),
}
}
}

impl NewPluginScreen {
pub fn new(colors: Palette) -> Self {
pub fn new(colors: Styling) -> Self {
Self {
colors,
..Default::default()
Expand Down Expand Up @@ -261,10 +261,7 @@ impl NewPluginScreen {
None,
None,
);
let background = match self.colors.theme_hue {
ThemeHue::Dark => self.colors.black,
ThemeHue::Light => self.colors.white,
};
let background = self.colors.text_unselected.background;
let bg_color = 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),
Expand Down Expand Up @@ -496,7 +493,7 @@ struct State {
plugin_id_to_tab_position: HashMap<u32, usize>,
search_term: String,
new_plugin_screen: Option<NewPluginScreen>,
colors: Palette,
colors: Styling,
}

register_plugin!(State);
Expand Down
5 changes: 1 addition & 4 deletions default-plugins/session-manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,7 @@ impl ZellijPlugin for State {
fn render(&mut self, rows: usize, cols: usize) {
let (x, y, width, height) = self.main_menu_size(rows, cols);

let background = match self.colors.palette.theme_hue {
ThemeHue::Dark => self.colors.palette.black,
ThemeHue::Light => self.colors.palette.white,
};
let background = self.colors.palette.text_unselected.background;

if self.is_welcome_screen {
render_banner(x, 0, rows.saturating_sub(height), width);
Expand Down
6 changes: 1 addition & 5 deletions default-plugins/status-bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,7 @@ impl ZellijPlugin for State {
""
};

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;

if rows == 1 && !self.classic_ui {
let fill_bg = match background {
Expand Down Expand Up @@ -294,7 +291,6 @@ impl ZellijPlugin for State {
let first_line = first_line(&self.mode_info, active_tab, cols, separator);
let second_line = self.second_line(cols);

let background = self.mode_info.style.colors.text_unselected.background;
// [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 background {
Expand Down

0 comments on commit 85445c6

Please sign in to comment.