diff options
| author | Aram Drevekenin <aram@poor.dev> | 2025-12-11 14:25:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-11 14:25:42 +0100 |
| commit | 693fa082def5ef0fe030cd7fdc3b1df051b35dc6 (patch) | |
| tree | b3f651462bbc1cd2fa5b2d79207343413ef6b83c /zellij-server/src/ui/components | |
| parent | fix(zellij-server): unblock building on 32bit targets (#4484) (diff) | |
| download | sl0ppij-693fa082def5ef0fe030cd7fdc3b1df051b35dc6.tar.gz sl0ppij-693fa082def5ef0fe030cd7fdc3b1df051b35dc6.tar.xz sl0ppij-693fa082def5ef0fe030cd7fdc3b1df051b35dc6.zip | |
Command Sequences, Blocking CLI Commands, New Plugin APIs (#4546)
* fix deadlocks
* initial logging to plugin implementation
* only log actions, include keys as Action::Write
* send actions to plugins as a new Event::UserAction
* add Action::Write metadata to plugin API
* run_action plugin command and permission
* block-until-exit/success/failure in the cli
* fix tests
* add NewBlockingPane to the plugin API
* run actions in a different thread so as not to block plugin execution
* add custom context to run_action flow
* fixes for floating pane z_index sorting and unknown protobuf events not crashing plugins
* always render the frame of pinned panes
* macros module
* add macros to config
* KDL macro parsing
* thread macros to the plugin thread
* get/update/delete macros from plugins
* add macros updated event
* add ability to rename macros
* fix deadlock
* fix z_indices with pinned unselectable panes bug
* allow plugins to opt-in to show_cursor
* change show_cursor(bool) to show_cursor(Option<coordinates>)
* test
* upgrade strum to allow proper enum iteration and case insensitive fromstr implementation for Actions
* better cwd tracking for exited command panes
* add initial panes to NewTab Action (no-op for now)
* add initial panes to cli newtab action
* make initial panes work
* add close_on_exit and start_suspended to the cli
* properly convert newtab action (potentially breaking for plugins)
* allow first pane in tab to block
* make distinction between opening panes with the last active client and the current pane in the cli
* improve some apis
* fix fixed size closing pane bug
* fix plugin cursor coordinates
* fix issues with launch-or-focus-plugin having to do with in-place and suppressed panes
* fix: set affected pane in replace pane
* allow setting a pane in place when it is suppressed and being focused (tests failing)
* fix tests
* some fixes for unsuppression of panes
* some fixes for completion_tx in new tab action
* allow replace/suppressed rather than replace/close only
* fixes for inserting suppressed panes without conflicts
* pane focus history and explicit unsuppress plugin api
* fix: prefer explicitly provided pane id in placement in actions that provide it
* fix floating pane coordinate change and z_index
* fix plugin cache dir to persist between sessions
* fix some stack focusing issues when adding panes without a client id
* make sure pinned panes are always above non-pinned floating panes
* allow plugins to copy to clipboard
* initial text styling additions implementations - buggy
* fix dimming issues
* remove extras, stay with just dim and unbold
* unbold and dim as indices
* allow ui components to render success/error colors
* allow plugins to send sigint/sigkill to processes, as well as receive their pid
* ui component fixes and send originating plugin context with run_action
* originating plugin for new tab too
* make plugn show pane command also expand stacked panes
* add sequence plugin
* remove macros
* remove snapshots
* add shortcut for sequence plugin
* fix plugin tests
* plugin tests for new apis
* update snapshots for sequence shortcut
* cleanups and formatting
* Event::CwdChanged
* moar cleanups
* remove some warnings
* remove mroe warnings
* remove dead code
* remove more dead code
* fix minor bugs in sequence plugin
* update sequence help and format codebase
* fix conditional blocking cli commands
* fix initial-command new-tab cli flag
* add client_ids to CwdChanged Event
* last fixes
* add pr
Diffstat (limited to 'zellij-server/src/ui/components')
| -rw-r--r-- | zellij-server/src/ui/components/nested_list.rs | 1 | ||||
| -rw-r--r-- | zellij-server/src/ui/components/ribbon.rs | 1 | ||||
| -rw-r--r-- | zellij-server/src/ui/components/table.rs | 24 | ||||
| -rw-r--r-- | zellij-server/src/ui/components/text.rs | 71 |
4 files changed, 84 insertions, 13 deletions
diff --git a/zellij-server/src/ui/components/nested_list.rs b/zellij-server/src/ui/components/nested_list.rs index c2aa2860..b4b76b9b 100644 --- a/zellij-server/src/ui/components/nested_list.rs +++ b/zellij-server/src/ui/components/nested_list.rs @@ -49,6 +49,7 @@ pub fn nested_list( Some(padding + bulletin.len()), &coordinates, &style_declaration, + &style.colors, text_style.bold(Some(AnsiCode::On)), ); text = pad_line(text, max_width, padding, text_width); diff --git a/zellij-server/src/ui/components/ribbon.rs b/zellij-server/src/ui/components/ribbon.rs index 98b681a5..adfa3a79 100644 --- a/zellij-server/src/ui/components/ribbon.rs +++ b/zellij-server/src/ui/components/ribbon.rs @@ -34,6 +34,7 @@ pub fn ribbon( padding, &component_coordinates, &declaration, + &colors, text_style, ); let mut stringified = component_coordinates diff --git a/zellij-server/src/ui/components/table.rs b/zellij-server/src/ui/components/table.rs index 978b741e..80ab2a37 100644 --- a/zellij-server/src/ui/components/table.rs +++ b/zellij-server/src/ui/components/table.rs @@ -22,7 +22,8 @@ pub fn table( if is_too_high(row_index + 1, &coordinates) { break; } - for cell in row { + let cell_count = row.iter().len(); + for (cell_index, cell) in row.into_iter().enumerate() { let declaration = if is_title_row { style.colors.table_title } else { @@ -38,16 +39,21 @@ pub fn table( } else { CharacterStyles::from(declaration) }; + + // Default: bold + let text_style = text_style.bold(Some(AnsiCode::On)); + // here we intentionally don't pass our coordinates even if we have them, because // these cells have already been padded and truncated - let (text, _text_width) = stringify_text( - &cell, - None, - &None, - &declaration, - text_style.bold(Some(AnsiCode::On)), - ); - stringified.push_str(&format!("{}{} {}", text_style, text, RESET_STYLES)); + let (text, _text_width) = + stringify_text(&cell, None, &None, &declaration, &style.colors, text_style); + if cell_index == cell_count.saturating_sub(1) { + // do not add padding between columns for the last cell + stringified.push_str(&format!("{}{}{}", text_style, text, RESET_STYLES)); + } else { + // add padding between columns + stringified.push_str(&format!("{}{} {}", text_style, text, RESET_STYLES)); + } } let next_row_instruction = coordinates .as_ref() diff --git a/zellij-server/src/ui/components/text.rs b/zellij-server/src/ui/components/text.rs index c0088e60..eb8667f8 100644 --- a/zellij-server/src/ui/components/text.rs +++ b/zellij-server/src/ui/components/text.rs @@ -15,6 +15,7 @@ pub fn text(content: Text, style: &Style, component_coordinates: Option<Coordina style.colors.text_unselected }; + // Start with base style from declaration let base_text_style = CharacterStyles::from(declaration).bold(Some(AnsiCode::On)); let (text, _text_width) = stringify_text( @@ -22,6 +23,7 @@ pub fn text(content: Text, style: &Style, component_coordinates: Option<Coordina None, &component_coordinates, &declaration, + &style.colors, base_text_style, ); match component_coordinates { @@ -39,6 +41,7 @@ pub fn stringify_text( left_padding: Option<usize>, coordinates: &Option<Coordinates>, style: &StyleDeclaration, + styling: &zellij_utils::data::Styling, component_text_style: CharacterStyles, ) -> (String, usize) { let mut text_width = 0; @@ -48,6 +51,7 @@ pub fn stringify_text( } else { component_text_style }; + stringified.push_str(&format!("{}", base_text_style)); for (i, character) in text.text.chars().enumerate() { let character_width = character.width().unwrap_or(0); if is_too_wide( @@ -67,7 +71,7 @@ pub fn stringify_text( if !text.indices.is_empty() || text.selected || text.opaque { let character_with_styling = - color_index_character(character, i, &text, style, base_text_style); + color_index_character(character, i, &text, style, styling, base_text_style); stringified.push_str(&character_with_styling); } else { stringified.push(character) @@ -100,12 +104,32 @@ pub fn color_index_character( index: usize, text: &Text, declaration: &StyleDeclaration, + styling: &zellij_utils::data::Styling, base_text_style: CharacterStyles, ) -> String { - let character_style = text - .style_of_index(index, declaration) + let mut character_style = text + .style_of_index(index, declaration, styling) .map(|foreground_style| base_text_style.foreground(Some(foreground_style.into()))) .unwrap_or(base_text_style); + + // Apply dim and unbold per-character based on index levels 4 and 5 + if text.is_unbold_at(index) { + // Remove bold for this character + character_style = character_style.bold(Some(AnsiCode::Reset)); + } else if text.is_dimmed_at(index) { + // Apply dim for this character + character_style = character_style + .foreground(Some(AnsiCode::Reset)) // some terminals (eg. alacritty) do not support dimming non 16 + // colors, so we have to defer to the terminal's default here + .dim(Some(AnsiCode::On)); + } else { + character_style = character_style + .bold(Some(AnsiCode::On)) + .dim(Some(AnsiCode::Reset)); // default, to reset any + // possible dim/bold values + // from previous indices + } + format!("{}{}{}", character_style, character, base_text_style) } @@ -141,7 +165,46 @@ impl Text { } } - pub fn style_of_index(&self, index: usize, style: &StyleDeclaration) -> Option<PaletteColor> { + pub fn is_dimmed_at(&self, index: usize) -> bool { + const DIM_LEVEL: usize = 4; + self.indices + .get(DIM_LEVEL) + .map(|indices| indices.contains(&index)) + .unwrap_or(false) + } + + pub fn is_unbold_at(&self, index: usize) -> bool { + const UNBOLD_LEVEL: usize = 5; + self.indices + .get(UNBOLD_LEVEL) + .map(|indices| indices.contains(&index)) + .unwrap_or(false) + } + + pub fn style_of_index( + &self, + index: usize, + style: &StyleDeclaration, + styling: &zellij_utils::data::Styling, + ) -> Option<PaletteColor> { + const ERROR_COLOR_LEVEL: usize = 6; + const SUCCESS_COLOR_LEVEL: usize = 7; + + // Check error color first (highest precedence) + if let Some(indices) = self.indices.get(ERROR_COLOR_LEVEL) { + if indices.contains(&index) { + return Some(styling.exit_code_error.base); + } + } + + // Check success color (second highest precedence) + if let Some(indices) = self.indices.get(SUCCESS_COLOR_LEVEL) { + if indices.contains(&index) { + return Some(styling.exit_code_success.base); + } + } + + // Check regular emphasis levels (existing code) let index_variant_styles = [ style.emphasis_0, style.emphasis_1, |
