diff options
author | Aram Drevekenin <aram@poor.dev> | 2024-07-05 15:13:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-05 15:13:51 +0200 |
commit | a6d6c0e4ff03c35cafb6f04363ecab856ee3682d (patch) | |
tree | eadf1c24c4c6a1e4b7499b3cd047351fd29e52de | |
parent | 8e33b20559ecddcaba17e5cc8d6f05b638718cac (diff) |
feat(ui): status bar redesign (#3475)
* work
* work
* working
* get default mode from server and some ui responsiveness
* work
* finish design and get tests to pass
* get e2e tests to pass
* add classic layout
* add classic layout assets
* fix e2e tests
* style(fmt): rustfmt
* fix plugin system test
* style(fmt): some cleanups
71 files changed, 2208 insertions, 225 deletions
diff --git a/Cargo.lock b/Cargo.lock index 2803fb4cd..cfb942043 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3811,6 +3811,7 @@ dependencies = [ "serde", "serde_json", "thiserror", + "unicode-width", "zellij-tile", "zellij-tile-utils", ] diff --git a/default-plugins/status-bar/Cargo.toml b/default-plugins/status-bar/Cargo.toml index a2ca3175a..c1492c197 100644 --- a/default-plugins/status-bar/Cargo.toml +++ b/default-plugins/status-bar/Cargo.toml @@ -13,6 +13,7 @@ rand = "0.8.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" thiserror = "1.0.30" +unicode-width = "0.1.8" zellij-tile = { path = "../../zellij-tile" } zellij-tile-utils = { path = "../../zellij-tile-utils" } diff --git a/default-plugins/status-bar/src/first_line.rs b/default-plugins/status-bar/src/first_line.rs index 1fffd7558..ee9b9478d 100644 --- a/default-plugins/status-bar/src/first_line.rs +++ b/default-plugins/status-bar/src/first_line.rs @@ -8,14 +8,16 @@ use crate::{ }; use crate::{ColoredElements, LinePart}; -struct KeyShortcut { - mode: KeyMode, - action: KeyAction, - key: Option<KeyWithModifier>, +#[derive(Debug)] +pub struct KeyShortcut { + pub mode: KeyMode, + pub action: KeyAction, + pub key: Option<KeyWithModifier>, } -#[derive(PartialEq)] -enum KeyAction { +#[derive(Debug, Copy, Clone, PartialEq)] +pub enum KeyAction { + Unlock, Lock, Pane, Tab, @@ -27,7 +29,8 @@ enum KeyAction { Tmux, } -enum KeyMode { +#[derive(Debug, Copy, Clone)] +pub enum KeyMode { Unselected, UnselectedAlternate, Selected, @@ -42,6 +45,7 @@ impl KeyShortcut { pub fn full_text(&self) -> String { match self.action { KeyAction::Lock => String::from("LOCK"), + KeyAction::Unlock => String::from("UNLOCK"), KeyAction::Pane => String::from("PANE"), KeyAction::Tab => String::from("TAB"), KeyAction::Resize => String::from("RESIZE"), @@ -82,6 +86,35 @@ impl KeyShortcut { }; format!("{}", key) } + pub fn get_key(&self) -> Option<KeyWithModifier> { + self.key.clone() + } + pub fn get_mode(&self) -> KeyMode { + self.mode + } + pub fn get_action(&self) -> KeyAction { + self.action + } + pub fn is_selected(&self) -> bool { + match self.mode { + KeyMode::Selected => true, + _ => false, + } + } + pub fn short_text(&self) -> String { + match self.action { + KeyAction::Lock => String::from("Lo"), + KeyAction::Unlock => String::from("Un"), + KeyAction::Pane => String::from("Pa"), + KeyAction::Tab => String::from("Ta"), + KeyAction::Resize => String::from("Re"), + KeyAction::Search => String::from("Se"), + KeyAction::Quit => String::from("Qu"), + KeyAction::Session => String::from("Se"), + KeyAction::Move => String::from("Mo"), + KeyAction::Tmux => String::from("Tm"), + } + } } /// Generate long mode shortcut tile. diff --git a/default-plugins/status-bar/src/main.rs b/default-plugins/status-bar/src/main.rs index 6fed529f4..7db9b09d9 100644 --- a/default-plugins/status-bar/src/main.rs +++ b/default-plugins/status-bar/src/main.rs @@ -1,4 +1,5 @@ mod first_line; +mod one_line_ui; mod second_line; mod tip; @@ -15,6 +16,7 @@ use zellij_tile::prelude::*; use zellij_tile_utils::{palette_match, style}; use first_line::first_line; +use one_line_ui::one_line_ui; use second_line::{ floating_panes_are_visible, fullscreen_panes_to_hide, keybinds, locked_floating_panes_are_visible, locked_fullscreen_panes_to_hide, system_clipboard_error, @@ -35,6 +37,8 @@ struct State { mode_info: ModeInfo, text_copy_destination: Option<CopyDestination>, display_system_clipboard_failure: bool, + classic_ui: bool, + base_mode_is_locked: bool, } register_plugin!(State); @@ -177,9 +181,13 @@ fn color_elements(palette: Palette, different_color_alternates: bool) -> Colored } impl ZellijPlugin for State { - fn load(&mut self, _configuration: BTreeMap<String, String>) { + fn load(&mut self, configuration: BTreeMap<String, String>) { // TODO: Should be able to choose whether to use the cache through config. self.tip_name = get_cached_tip_name(); + self.classic_ui = configuration + .get("classic") + .map(|c| c == "true") + .unwrap_or(false); set_selectable(false); subscribe(&[ EventType::ModeUpdate, @@ -198,6 +206,7 @@ impl ZellijPlugin for State { should_render = true; } |