fix(ui): floating panes UI (#1074)
* basic ui * update plugins * rustfmt
This commit is contained in:
parent
a3e69fe6da
commit
9fa94970cc
9 changed files with 94 additions and 2 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -10,7 +10,8 @@ use zellij_tile_utils::style;
|
||||||
|
|
||||||
use first_line::{ctrl_keys, superkey};
|
use first_line::{ctrl_keys, superkey};
|
||||||
use second_line::{
|
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,
|
text_copied_hint,
|
||||||
};
|
};
|
||||||
use tip::utils::get_cached_tip_name;
|
use tip::utils::get_cached_tip_name;
|
||||||
|
|
@ -222,6 +223,12 @@ impl State {
|
||||||
),
|
),
|
||||||
_ => keybinds(&self.mode_info, &self.tip_name, cols),
|
_ => 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 {
|
} else {
|
||||||
keybinds(&self.mode_info, &self.tip_name, cols)
|
keybinds(&self.mode_info, &self.tip_name, cols)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
pub fn tmux_mode_indication(help: &ModeInfo) -> LinePart {
|
||||||
let white_color = match help.palette.white {
|
let white_color = match help.palette.white {
|
||||||
PaletteColor::Rgb((r, g, b)) => RGB(r, g, b),
|
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,
|
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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,4 +26,4 @@ expression: last_snapshot
|
||||||
│ │
|
│ │
|
||||||
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||||
Ctrl + <g> LOCK <p> PANE <t> TAB <n> RESIZE <h> MOVE <s> SCROLL <o> SESSION <q> QUIT
|
Ctrl + <g> LOCK <p> PANE <t> TAB <n> RESIZE <h> MOVE <s> SCROLL <o> SESSION <q> QUIT
|
||||||
Tip: Alt + <n> => new pane. Alt + <[] or hjkl> => navigate. Alt + <+-> => resize pane.
|
(FLOATING PANES VISIBLE): Press Ctrl-p + <w> to hide.
|
||||||
|
|
|
||||||
|
|
@ -605,6 +605,7 @@ impl Screen {
|
||||||
panes_to_hide: tab.panes_to_hide.len(),
|
panes_to_hide: tab.panes_to_hide.len(),
|
||||||
is_fullscreen_active: tab.is_fullscreen_active(),
|
is_fullscreen_active: tab.is_fullscreen_active(),
|
||||||
is_sync_panes_active: tab.is_sync_panes_active(),
|
is_sync_panes_active: tab.is_sync_panes_active(),
|
||||||
|
are_floating_panes_visible: tab.are_floating_panes_visible(),
|
||||||
other_focused_clients,
|
other_focused_clients,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -768,6 +769,7 @@ pub(crate) fn screen_thread_main(
|
||||||
.senders
|
.senders
|
||||||
.send_to_server(ServerInstruction::UnblockInputThread)
|
.send_to_server(ServerInstruction::UnblockInputThread)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
screen.update_tabs(); // update tabs so that the ui indication will be send to the plugins
|
||||||
screen.render();
|
screen.render();
|
||||||
}
|
}
|
||||||
ScreenInstruction::ToggleFloatingPanes(client_id, default_shell) => {
|
ScreenInstruction::ToggleFloatingPanes(client_id, default_shell) => {
|
||||||
|
|
@ -780,6 +782,7 @@ pub(crate) fn screen_thread_main(
|
||||||
.senders
|
.senders
|
||||||
.send_to_server(ServerInstruction::UnblockInputThread)
|
.send_to_server(ServerInstruction::UnblockInputThread)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
screen.update_tabs(); // update tabs so that the ui indication will be send to the plugins
|
||||||
screen.render();
|
screen.render();
|
||||||
}
|
}
|
||||||
ScreenInstruction::HorizontalSplit(pid, client_id) => {
|
ScreenInstruction::HorizontalSplit(pid, client_id) => {
|
||||||
|
|
|
||||||
|
|
@ -1086,6 +1086,9 @@ impl Tab {
|
||||||
pub fn is_fullscreen_active(&self) -> bool {
|
pub fn is_fullscreen_active(&self) -> bool {
|
||||||
self.fullscreen_is_active
|
self.fullscreen_is_active
|
||||||
}
|
}
|
||||||
|
pub fn are_floating_panes_visible(&self) -> bool {
|
||||||
|
self.floating_panes.panes_are_visible()
|
||||||
|
}
|
||||||
pub fn toggle_fullscreen_is_active(&mut self) {
|
pub fn toggle_fullscreen_is_active(&mut self) {
|
||||||
self.fullscreen_is_active = !self.fullscreen_is_active;
|
self.fullscreen_is_active = !self.fullscreen_is_active;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -230,6 +230,7 @@ pub struct TabInfo {
|
||||||
pub panes_to_hide: usize,
|
pub panes_to_hide: usize,
|
||||||
pub is_fullscreen_active: bool,
|
pub is_fullscreen_active: bool,
|
||||||
pub is_sync_panes_active: bool,
|
pub is_sync_panes_active: bool,
|
||||||
|
pub are_floating_panes_visible: bool,
|
||||||
pub other_focused_clients: Vec<ClientId>,
|
pub other_focused_clients: Vec<ClientId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue