diff options
author | Kaito Akita <kaito.akita@zozo.com> | 2021-09-27 19:07:28 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-27 12:07:28 +0200 |
commit | 4632e90b73d9eb5a70300c6221b88f9a000ac035 (patch) | |
tree | 473dfde8049d03cc61d8cac7bd08a1607e10ae48 /default-plugins | |
parent | 5c54bf18c21e60d82ef063b62337f6b545d914d3 (diff) |
feat(ui): The status bar indicates that the panes are full screen and how many hidden panes are (#450)
* fix(ui): offset content after viewport construction
* Added the feature to display fullscreen information on the second line of the status-bar.
* fix(strider): update host mount-point
* fix(plugin): create missing data directories as needed
* feat(layout): specify only tab name in `tabs` section (#722)
Allow specifying only the tab name in the `tabs` section
- For example this is now possible:
```
tabs:
- name: first
parts:
- direction: Vertical
- direction: Vertical
- name: second
- name: third
```
For that the tab section defaults the direction to
`direction::Horizontal`
- Adds an error upon specifying a tab name inside the `parts` section
of the tab-layout
* docs(changelog): Solely name tab in `tabs` section
* feature(release): Copy default config to the examples folder on release (#736)
fixes #733
* docs(changelog): Copy example config on release
* Update default config (#737)
* feat(plugin): add manifest to allow for plugin configuration (#660)
* feat(plugins-manifest): Add a plugins manifest to allow for more configuration of plugins
* refactor(plugins-manifest): Better storage of plugin metadata in wasm_vm
* fix(plugins-manifest): Inherit permissions from run configuration
* refactor(plugins-manifest): Rename things for more clarity
- The Plugins/Plugin structs had "Config" appended to them to clarify
that they're metadata about plugins, and not the plugins themselves.
- The PluginType::OncePerPane variant was renamed to be just
PluginType::Pane, and the documentation clarified to explain what it
is.
- The "service" nomenclature was completely removed in favor of
"headless".
* refactor(plugins-manifest): Move security warning into start plugin
* refactor(plugins-manifest): Remove hack in favor of standard method
* refactor(plugins-manifest): Change display of plugin location
The only time that a plugin location is displayed in Zellij is the
border of the pane. Having `zellij:strider` display instead of just
`strider` was a little annoying, so we're stripping out the scheme
information from a locations display.
* refactor(plugins-manifest): Add a little more documentation
* fix(plugins-manifest): Formatting
Co-authored-by: Jesse Tuchsen <not@disclosing>
* chore(docs): update changelog
* feat(sessions): mirrored sessions (#740)
* feat(sessions): mirrored sessions
* fix(tests): input units
* style(fmt): make rustfmt happy
* fix(tests): make mirrored sessions e2e test more robust
* refactor(sessions): remove force attach
* style(fmt): rustfmtify
* docs(changelog): update change
* fix(e2e): retry on all errors
Co-authored-by: Brooks J Rady <b.j.rady@gmail.com>
Co-authored-by: a-kenji <aks.kenji@protonmail.com>
Co-authored-by: spacemaison <tuchsen@protonmail.com>
Co-authored-by: Jesse Tuchsen <not@disclosing>
Co-authored-by: Aram Drevekenin <aram@poor.dev>
Diffstat (limited to 'default-plugins')
-rw-r--r-- | default-plugins/status-bar/src/main.rs | 62 | ||||
-rw-r--r-- | default-plugins/status-bar/src/second_line.rs | 79 |
2 files changed, 135 insertions, 6 deletions
diff --git a/default-plugins/status-bar/src/main.rs b/default-plugins/status-bar/src/main.rs index 9f8e9eaab..f1b2197e4 100644 --- a/default-plugins/status-bar/src/main.rs +++ b/default-plugins/status-bar/src/main.rs @@ -8,7 +8,9 @@ use zellij_tile::prelude::*; use zellij_tile_utils::style; use first_line::{ctrl_keys, superkey}; -use second_line::{keybinds, text_copied_hint}; +use second_line::{ + fullscreen_panes_to_hide, keybinds, locked_fullscreen_panes_to_hide, text_copied_hint, +}; // for more of these, copy paste from: https://en.wikipedia.org/wiki/Box-drawing_character static ARROW_SEPARATOR: &str = ""; @@ -16,6 +18,7 @@ static MORE_MSG: &str = " ... "; #[derive(Default)] struct State { + tabs: Vec<TabInfo>, mode_info: ModeInfo, diplay_text_copied_hint: bool, } @@ -137,6 +140,7 @@ impl ZellijPlugin for State { set_selectable(false); subscribe(&[ EventType::ModeUpdate, + EventType::TabUpdate, EventType::CopyToClipboard, EventType::InputReceived, ]); @@ -147,6 +151,9 @@ impl ZellijPlugin for State { Event::ModeUpdate(mode_info) => { self.mode_info = mode_info; } + Event::TabUpdate(tabs) => { + self.tabs = tabs; + } Event::CopyToClipboard => { self.diplay_text_copied_hint = true; } @@ -173,11 +180,54 @@ impl ZellijPlugin for State { ); let first_line = format!("{}{}", superkey, ctrl_keys); - let second_line = if self.diplay_text_copied_hint { - text_copied_hint(&self.mode_info.palette) - } else { - keybinds(&self.mode_info, cols) - }; + + let mut second_line = LinePart::default(); + for t in self.tabs.iter_mut() { + if t.active { + match self.mode_info.mode { + InputMode::Normal => { + if t.is_fullscreen_active { + second_line = if self.diplay_text_copied_hint { + text_copied_hint(&self.mode_info.palette) + } else { + fullscreen_panes_to_hide(&self.mode_info.palette, t.panes_to_hide) + } + } else { + second_line = if self.diplay_text_copied_hint { + text_copied_hint(&self.mode_info.palette) + } else { + keybinds(&self.mode_info, cols) + } + } + } + InputMode::Locked => { + if t.is_fullscreen_active { + second_line = if self.diplay_text_copied_hint { + text_copied_hint(&self.mode_info.palette) + } else { + locked_fullscreen_panes_to_hide( + &self.mode_info.palette, + t.panes_to_hide, + ) + } + } else { + second_line = if self.diplay_text_copied_hint { + text_copied_hint(&self.mode_info.palette) + } else { + keybinds(&self.mode_info, cols) + } + } + } + _ => { + second_line = if self.diplay_text_copied_hint { + text_copied_hint(&self.mode_info.palette) + } else { + keybinds(&self.mode_info, cols) + } + } + } + } + } // [48;5;238m is gray background, [0K is so that it fills the rest of the line // [m is background reset, [0K is so that it clears the rest of the line diff --git a/default-plugins/status-bar/src/second_line.rs b/default-plugins/status-bar/src/second_line.rs index d73cb2874..0e59fcb8e 100644 --- a/default-plugins/status-bar/src/second_line.rs +++ b/default-plugins/status-bar/src/second_line.rs @@ -387,3 +387,82 @@ pub fn text_copied_hint(palette: &Palette) -> LinePart { len: hint.len(), } } + +pub fn fullscreen_panes_to_hide(palette: &Palette, panes_to_hide: usize) -> 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 fullscreen = "FULLSCREEN"; + let puls = "+ "; + let panes = panes_to_hide.to_string(); + let hide = " hidden panes"; + let len = fullscreen.chars().count() + + puls.chars().count() + + panes.chars().count() + + hide.chars().count() + + 5; // 3 for ():'s around shortcut, 2 for the space + LinePart { + part: format!( + "{}{}{}{}{}{}", + shortcut_left_separator, + Style::new().fg(orange_color).bold().paint(fullscreen), + shortcut_right_separator, + Style::new().fg(white_color).bold().paint(puls), + Style::new().fg(green_color).bold().paint(panes), + Style::new().fg(white_color).bold().paint(hide) + ), + len, + } +} + +pub fn locked_fullscreen_panes_to_hide(palette: &Palette, panes_to_hide: usize) -> 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 locked_text = " -- INTERFACE LOCKED -- "; + let shortcut_left_separator = Style::new().fg(white_color).bold().paint(" ("); + let shortcut_right_separator = Style::new().fg(white_color).bold().paint("): "); + let fullscreen = "FULLSCREEN"; + let puls = "+ "; + let panes = panes_to_hide.to_string(); + let hide = " hidden panes"; + let len = locked_text.chars().count() + + fullscreen.chars().count() + + puls.chars().count() + + panes.chars().count() + + hide.chars().count() + + 5; // 3 for ():'s around shortcut, 2 for the space + LinePart { + part: format!( + "{}{}{}{}{}{}{}", + Style::new().fg(white_color).bold().paint(locked_text), + shortcut_left_separator, + Style::new().fg(orange_color).bold().paint(fullscreen), + shortcut_right_separator, + Style::new().fg(white_color).bold().paint(puls), + Style::new().fg(green_color).bold().paint(panes), + Style::new().fg(white_color).bold().paint(hide) + ), + len, + } +} |