From 9fa94970cc78345a4c9ca051f16d6510ecc51297 Mon Sep 17 00:00:00 2001 From: Aram Drevekenin Date: Mon, 21 Feb 2022 18:01:35 +0100 Subject: fix(ui): floating panes UI (#1074) * basic ui * update plugins * rustfmt --- default-plugins/status-bar/src/main.rs | 9 +++- default-plugins/status-bar/src/second_line.rs | 78 +++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) (limited to 'default-plugins') diff --git a/default-plugins/status-bar/src/main.rs b/default-plugins/status-bar/src/main.rs index 27dc3262d..daeb30f13 100644 --- a/default-plugins/status-bar/src/main.rs +++ b/default-plugins/status-bar/src/main.rs @@ -10,7 +10,8 @@ use zellij_tile_utils::style; use first_line::{ctrl_keys, superkey}; use second_line::{ - fullscreen_panes_to_hide, keybinds, locked_fullscreen_panes_to_hide, system_clipboard_error, + floating_panes_are_visible, fullscreen_panes_to_hide, keybinds, + locked_floating_panes_are_visible, locked_fullscreen_panes_to_hide, system_clipboard_error, text_copied_hint, }; use tip::utils::get_cached_tip_name; @@ -222,6 +223,12 @@ impl State { ), _ => keybinds(&self.mode_info, &self.tip_name, cols), } + } else if active_tab.are_floating_panes_visible { + match self.mode_info.mode { + InputMode::Normal => floating_panes_are_visible(&self.mode_info.palette), + InputMode::Locked => locked_floating_panes_are_visible(&self.mode_info.palette), + _ => keybinds(&self.mode_info, &self.tip_name, cols), + } } else { keybinds(&self.mode_info, &self.tip_name, cols) } diff --git a/default-plugins/status-bar/src/second_line.rs b/default-plugins/status-bar/src/second_line.rs index d33efc02e..77868a72c 100644 --- a/default-plugins/status-bar/src/second_line.rs +++ b/default-plugins/status-bar/src/second_line.rs @@ -396,6 +396,57 @@ pub fn fullscreen_panes_to_hide(palette: &Palette, panes_to_hide: usize) -> Line } } +pub fn floating_panes_are_visible(palette: &Palette) -> LinePart { + let white_color = match palette.white { + PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), + PaletteColor::EightBit(color) => Fixed(color), + }; + let green_color = match palette.green { + PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), + PaletteColor::EightBit(color) => Fixed(color), + }; + let orange_color = match palette.orange { + PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), + PaletteColor::EightBit(color) => Fixed(color), + }; + let shortcut_left_separator = Style::new().fg(white_color).bold().paint(" ("); + let shortcut_right_separator = Style::new().fg(white_color).bold().paint("): "); + let floating_panes = "FLOATING PANES VISIBLE"; + let press = "Press "; + let ctrl = "Ctrl-p "; + let plus = "+ "; + let p_left_separator = "<"; + let p = "w"; + let p_right_separator = "> "; + let to_hide = "to hide."; + + let len = floating_panes.chars().count() + + press.chars().count() + + ctrl.chars().count() + + plus.chars().count() + + p_left_separator.chars().count() + + p.chars().count() + + p_right_separator.chars().count() + + to_hide.chars().count() + + 5; // 3 for ():'s around floating_panes, 2 for the space + LinePart { + part: format!( + "{}{}{}{}{}{}{}{}{}{}", + shortcut_left_separator, + Style::new().fg(orange_color).bold().paint(floating_panes), + shortcut_right_separator, + Style::new().fg(white_color).bold().paint(press), + Style::new().fg(green_color).bold().paint(ctrl), + Style::new().fg(white_color).bold().paint(plus), + Style::new().fg(white_color).bold().paint(p_left_separator), + Style::new().fg(green_color).bold().paint(p), + Style::new().fg(white_color).bold().paint(p_right_separator), + Style::new().fg(white_color).bold().paint(to_hide), + ), + len, + } +} + pub fn tmux_mode_indication(help: &ModeInfo) -> LinePart { let white_color = match help.palette.white { PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), @@ -520,3 +571,30 @@ pub fn locked_fullscreen_panes_to_hide(palette: &Palette, panes_to_hide: usize) len, } } + +pub fn locked_floating_panes_are_visible(palette: &Palette) -> LinePart { + let white_color = match palette.white { + PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), + PaletteColor::EightBit(color) => Fixed(color), + }; + let orange_color = match palette.orange { + PaletteColor::Rgb((r, g, b)) => RGB(r, g, b), + PaletteColor::EightBit(color) => Fixed(color), + }; + let shortcut_left_separator = Style::new().fg(white_color).bold().paint(" ("); + let shortcut_right_separator = Style::new().fg(white_color).bold().paint(")"); + let locked_text = " -- INTERFACE LOCKED -- "; + let floating_panes = "FLOATING PANES VISIBLE"; + + let len = locked_text.chars().count() + floating_panes.chars().count(); + LinePart { + part: format!( + "{}{}{}{}", + Style::new().fg(white_color).bold().paint(locked_text), + shortcut_left_separator, + Style::new().fg(orange_color).bold().paint(floating_panes), + shortcut_right_separator, + ), + len, + } +} -- cgit v1.2.3