diff options
| author | Daniel Jankowski <Daniel.Jankowski@rub.de> | 2024-10-24 18:21:44 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-24 18:21:44 +0200 |
| commit | 0cd6d5f4e5e7afcdd25cc45aaeeb80161498e322 (patch) | |
| tree | f72011676c902a37828beee75f3d6e85a50124e4 /default-plugins/plugin-manager/src | |
| parent | docs(changelog): suspend commands in remote layouts (diff) | |
| download | sl0ppij-0cd6d5f4e5e7afcdd25cc45aaeeb80161498e322.tar.gz sl0ppij-0cd6d5f4e5e7afcdd25cc45aaeeb80161498e322.tar.xz sl0ppij-0cd6d5f4e5e7afcdd25cc45aaeeb80161498e322.zip | |
feat(plugins): add configurable black background for ui components (#3681)
* feat(plugins): add transparent background for text and nested_list
* chore: fix formatting issue
* feat: invert flag behaviour
* feat: implement bg_black handling for table cells
* fix: order of selected and bg_black in protocol
* chore: rename from bg_black to opaque
* fix: explicit selected, if opaque and selected for text
* chore: fix formatting issues
* feat: opaque tab-bar
* feat: opaque session-manager bars
* feat: opaque ribbon in plugin manager
* feat: opaque one-line ui
* feat: opaque tab-bar in configuration plugin
Diffstat (limited to 'default-plugins/plugin-manager/src')
| -rw-r--r-- | default-plugins/plugin-manager/src/main.rs | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/default-plugins/plugin-manager/src/main.rs b/default-plugins/plugin-manager/src/main.rs index 3695b59f..63b36a22 100644 --- a/default-plugins/plugin-manager/src/main.rs +++ b/default-plugins/plugin-manager/src/main.rs @@ -34,6 +34,7 @@ pub struct NewPluginScreen { selected_config_index: Option<usize>, request_ids: Vec<String>, load_in_background: bool, + colors: Palette, } impl Default for NewPluginScreen { @@ -49,11 +50,19 @@ impl Default for NewPluginScreen { selected_config_index: None, request_ids: vec![], load_in_background: true, + colors: Palette::default(), } } } impl NewPluginScreen { + pub fn new(colors: Palette) -> Self { + Self { + colors, + ..Default::default() + } + } + pub fn render(&self, rows: usize, cols: usize) { self.render_title(cols); self.render_url_field(cols); @@ -246,12 +255,26 @@ impl NewPluginScreen { fn render_background_toggle(&self, y_coordinates: usize) { let key_shortcuts_text = format!("Ctrl l"); print_text_with_coordinates( - Text::new(&key_shortcuts_text).color_range(3, ..), + Text::new(&key_shortcuts_text).color_range(3, ..).opaque(), 0, y_coordinates, None, None, ); + let background = match self.colors.theme_hue { + ThemeHue::Dark => self.colors.black, + ThemeHue::Light => self.colors.white, + }; + 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), + }; + println!( + "\u{1b}[{};{}H{}", + y_coordinates + 1, + key_shortcuts_text.chars().count() + 1, + bg_color + ); let load_in_background_text = format!("Load in Background"); let load_in_foreground_text = format!("Load in Foreground"); let (load_in_background_ribbon, load_in_foreground_ribbon) = if self.load_in_background { @@ -473,6 +496,7 @@ struct State { plugin_id_to_tab_position: HashMap<u32, usize>, search_term: String, new_plugin_screen: Option<NewPluginScreen>, + colors: Palette, } register_plugin!(State); @@ -524,6 +548,10 @@ impl ZellijPlugin for State { fn update(&mut self, event: Event) -> bool { let mut should_render = false; match event { + Event::ModeUpdate(mode_info) => { + self.colors = mode_info.style.colors; + should_render = true; + }, Event::SessionUpdate(live_sessions, _dead_sessions) => { for session in live_sessions { if session.is_current_session { @@ -994,7 +1022,7 @@ impl State { self.reload_selected(); }, BareKey::Char('a') if key.has_modifiers(&[KeyModifier::Ctrl]) => { - self.new_plugin_screen = Some(Default::default()); + self.new_plugin_screen = Some(NewPluginScreen::new(self.colors)); should_render = true; }, BareKey::Delete if key.has_no_modifiers() => { |
