diff options
| author | Aram Drevekenin <aram@poor.dev> | 2026-07-06 22:09:06 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-06 22:09:06 +0200 |
| commit | 5b310ada794559c8be459424db03e83548151700 (patch) | |
| tree | 31b32a998598f253a4171dcb72f82550199745e1 /default-plugins | |
| parent | fix: more verbose startup errors (#5334) (diff) | |
| download | sl0ppij-5b310ada794559c8be459424db03e83548151700.tar.gz sl0ppij-5b310ada794559c8be459424db03e83548151700.tar.xz sl0ppij-5b310ada794559c8be459424db03e83548151700.zip | |
UI tweaks (#5337)
* remove dimmed
* clearer list ui
* fix integration tests
* rustfmt
* move hint to tab-bar
* redesign stack list
* rustfmt
* fix e2e
* add pr
Diffstat (limited to 'default-plugins')
| -rw-r--r-- | default-plugins/status-bar/src/main.rs | 33 | ||||
| -rw-r--r-- | default-plugins/status-bar/src/one_line_ui.rs | 17 | ||||
| -rw-r--r-- | default-plugins/tab-bar/src/line.rs | 20 | ||||
| -rw-r--r-- | default-plugins/tab-bar/src/main.rs | 38 |
4 files changed, 60 insertions, 48 deletions
diff --git a/default-plugins/status-bar/src/main.rs b/default-plugins/status-bar/src/main.rs index 6cffc5c7..673d7c8c 100644 --- a/default-plugins/status-bar/src/main.rs +++ b/default-plugins/status-bar/src/main.rs @@ -42,8 +42,6 @@ struct State { classic_ui: bool, base_mode_is_locked: bool, cached_keybinds: KeybindsVec, - hint_text: Option<BTreeMap<usize, StyledText>>, - outstanding_hint_timeouts: usize, new_pane_ribbon_range: Option<(usize, usize)>, floating_ribbon_range: Option<(usize, usize)>, new_pane_ribbon_hovered: bool, @@ -222,8 +220,6 @@ impl ZellijPlugin for State { EventType::InputReceived, EventType::SystemClipboardFailure, EventType::InitialKeybinds, - EventType::HintText, - EventType::Timer, EventType::Mouse, ]); } @@ -276,33 +272,11 @@ impl ZellijPlugin for State { Event::InputReceived => { if self.text_copy_destination.is_some() || self.display_system_clipboard_failure == true - || self.hint_text.is_some() { should_render = true; } self.text_copy_destination = None; self.display_system_clipboard_failure = false; - self.hint_text = None; - }, - Event::HintText(hint_variants) => { - if hint_variants.is_empty() { - if self.hint_text.is_some() { - self.hint_text = None; - should_render = true; - } - } else { - self.hint_text = Some(hint_variants); - self.outstanding_hint_timeouts += 1; - set_timeout(5.0); - should_render = true; - } - }, - Event::Timer(_) => { - self.outstanding_hint_timeouts = self.outstanding_hint_timeouts.saturating_sub(1); - if self.outstanding_hint_timeouts == 0 && self.hint_text.is_some() { - self.hint_text = None; - should_render = true; - } }, Event::Mouse(mouse_event) => match mouse_event { Mouse::LeftClick(_, col) => { @@ -347,12 +321,6 @@ impl ZellijPlugin for State { PaletteColor::EightBit(color) => format!("\u{1b}[48;5;{}m\u{1b}[0K", color), }; let active_tab = self.tabs.iter().find(|t| t.active); - let full_pane_frames = self.mode_info.pane_frame_style == Some(PaneFrameStyle::Full); - let hint_text = if full_pane_frames { - None - } else { - self.hint_text.as_ref() - }; let (line, new_pane_ribbon_range, floating_ribbon_range) = one_line_ui( &self.mode_info, active_tab, @@ -361,7 +329,6 @@ impl ZellijPlugin for State { self.base_mode_is_locked, self.text_copy_destination, self.display_system_clipboard_failure, - hint_text, self.new_pane_ribbon_hovered, self.floating_ribbon_hovered, ); diff --git a/default-plugins/status-bar/src/one_line_ui.rs b/default-plugins/status-bar/src/one_line_ui.rs index 97721167..6d00a6bf 100644 --- a/default-plugins/status-bar/src/one_line_ui.rs +++ b/default-plugins/status-bar/src/one_line_ui.rs @@ -3,7 +3,7 @@ use ansi_term::{ Color::{Fixed, RGB}, Style, }; -use std::collections::{BTreeMap, HashMap}; +use std::collections::HashMap; use zellij_tile::prelude::actions::Action; use zellij_tile::prelude::*; use zellij_tile_utils::{palette_match, style}; @@ -22,7 +22,6 @@ pub fn one_line_ui( base_mode_is_locked: bool, text_copied_to_clipboard_destination: Option<CopyDestination>, clipboard_failure: bool, - hint: Option<&BTreeMap<usize, StyledText>>, new_pane_hovered: bool, floating_hovered: bool, ) -> (LinePart, Option<(usize, usize)>, Option<(usize, usize)>) { @@ -40,9 +39,7 @@ pub fn one_line_ui( let mut new_pane_range = None; let mut floating_range = None; - let left_part = hint - .and_then(|hint| hint_line_part(hint, max_len)) - .or_else(|| render_mode_key_indicators(help, max_len, separator, base_mode_is_locked)); + let left_part = render_mode_key_indicators(help, max_len, separator, base_mode_is_locked); if let Some(left) = left_part { line_part_to_render.append(&left); max_len = max_len.saturating_sub(left.len); @@ -77,16 +74,6 @@ pub fn one_line_ui( (line_part_to_render, new_pane_range, floating_range) } -fn hint_line_part(hint: &BTreeMap<usize, StyledText>, max_len: usize) -> Option<LinePart> { - let fitting_variant = hint - .range(..=max_len) - .next_back() - .map(|(_width, styled_text)| styled_text)?; - let len = fitting_variant.text.width(); - let part = serialize_text(&Text::from(fitting_variant.clone())); - Some(LinePart { part, len }) -} - fn to_base_mode(base_mode: InputMode) -> Action { Action::SwitchToMode { input_mode: base_mode, diff --git a/default-plugins/tab-bar/src/line.rs b/default-plugins/tab-bar/src/line.rs index 99b85f05..84c5b3aa 100644 --- a/default-plugins/tab-bar/src/line.rs +++ b/default-plugins/tab-bar/src/line.rs @@ -1,4 +1,5 @@ use ansi_term::ANSIStrings; +use std::collections::BTreeMap; use unicode_width::UnicodeWidthStr; use crate::{LinePart, ARROW_SEPARATOR}; @@ -225,6 +226,7 @@ pub fn tab_line( hide_swap_layout_indicator: bool, background: &PaletteColor, active_pane_scroll: Option<(usize, usize)>, + hint: Option<&BTreeMap<usize, StyledText>>, is_alternate_tab: bool, new_tab_button_is_hovered: bool, ) -> (Vec<LinePart>, Option<(usize, usize)>) { @@ -258,6 +260,10 @@ pub fn tab_line( // Drop indicator if it would cause wrapping (active tab always rendered unconditionally) let prefix_len = get_current_title_len(&prefix); + let hint_budget = cols.saturating_sub(prefix_len + active_tab.len); + if let Some(hint_part) = hint.and_then(|hint| hint_line_part(hint, hint_budget)) { + swap_layout_indicator = Some(hint_part); + } let indicator_len = swap_layout_indicator.as_ref().map(|s| s.len).unwrap_or(0); if indicator_len > 0 && prefix_len + active_tab.len + indicator_len > cols { swap_layout_indicator = None; @@ -362,6 +368,20 @@ fn swap_layout_status( } } +fn hint_line_part(hint: &BTreeMap<usize, StyledText>, max_len: usize) -> Option<LinePart> { + let fitting_variant = hint + .range(..=max_len) + .next_back() + .map(|(_width, styled_text)| styled_text)?; + let len = fitting_variant.text.width(); + let part = serialize_text(&Text::from(fitting_variant.clone())); + Some(LinePart { + part, + len, + tab_index: None, + }) +} + fn scroll_status(scroll: (usize, usize), palette: Styling) -> LinePart { let (position, length) = scroll; let text = format!("[ SCROLL {}/{} ]", position, length); diff --git a/default-plugins/tab-bar/src/main.rs b/default-plugins/tab-bar/src/main.rs index 6fa92c75..4b521969 100644 --- a/default-plugins/tab-bar/src/main.rs +++ b/default-plugins/tab-bar/src/main.rs @@ -37,6 +37,8 @@ struct State { new_tab_button_range: Option<(usize, usize)>, hovered_tab_idx: Option<usize>, hovered_new_tab_button: bool, + hint_text: Option<BTreeMap<usize, StyledText>>, + outstanding_hint_timeouts: usize, } static ARROW_SEPARATOR: &str = ""; @@ -56,6 +58,9 @@ impl ZellijPlugin for State { EventType::Mouse, EventType::InitialKeybinds, EventType::ActivePaneScroll, + EventType::HintText, + EventType::Timer, + EventType::InputReceived, ]); } @@ -100,6 +105,32 @@ impl ZellijPlugin for State { } self.active_pane_scroll = scroll; }, + Event::HintText(hint_variants) => { + if hint_variants.is_empty() { + if self.hint_text.is_some() { + self.hint_text = None; + should_render = true; + } + } else { + self.hint_text = Some(hint_variants); + self.outstanding_hint_timeouts += 1; + set_timeout(5.0); + should_render = true; + } + }, + Event::Timer(_) => { + self.outstanding_hint_timeouts = self.outstanding_hint_timeouts.saturating_sub(1); + if self.outstanding_hint_timeouts == 0 && self.hint_text.is_some() { + self.hint_text = None; + should_render = true; + } + }, + Event::InputReceived => { + if self.hint_text.is_some() { + self.hint_text = None; + should_render = true; + } + }, Event::Mouse(me) => match me { Mouse::LeftClick(_, col) => { if let Some((start, end)) = self.new_tab_button_range { @@ -188,6 +219,12 @@ impl ZellijPlugin for State { let background = self.mode_info.style.colors.text_unselected.background; + let full_pane_frames = self.mode_info.pane_frame_style == Some(PaneFrameStyle::Full); + let hint_text = if full_pane_frames { + None + } else { + self.hint_text.as_ref() + }; let (line, new_tab_button_range) = tab_line( self.mode_info.session_name.as_deref(), all_tabs, @@ -201,6 +238,7 @@ impl ZellijPlugin for State { self.hide_swap_layout_indication, &background, self.active_pane_scroll, + hint_text, is_alternate_tab, self.hovered_new_tab_button, ); |
