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/tab-bar/src | |
| 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/tab-bar/src')
| -rw-r--r-- | default-plugins/tab-bar/src/line.rs | 20 | ||||
| -rw-r--r-- | default-plugins/tab-bar/src/main.rs | 38 |
2 files changed, 58 insertions, 0 deletions
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, ); |
