Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): floating panes UI #1074

Merged
merged 3 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified assets/plugins/status-bar.wasm
Binary file not shown.
Binary file modified assets/plugins/strider.wasm
Binary file not shown.
Binary file modified assets/plugins/tab-bar.wasm
Binary file not shown.
9 changes: 8 additions & 1 deletion default-plugins/status-bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
}
Expand Down
78 changes: 78 additions & 0 deletions default-plugins/status-bar/src/second_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ expression: last_snapshot
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
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.
3 changes: 3 additions & 0 deletions zellij-server/src/screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ impl Screen {
panes_to_hide: tab.panes_to_hide.len(),
is_fullscreen_active: tab.is_fullscreen_active(),
is_sync_panes_active: tab.is_sync_panes_active(),
are_floating_panes_visible: tab.are_floating_panes_visible(),
other_focused_clients,
});
}
Expand Down Expand Up @@ -768,6 +769,7 @@ pub(crate) fn screen_thread_main(
.senders
.send_to_server(ServerInstruction::UnblockInputThread)
.unwrap();
screen.update_tabs(); // update tabs so that the ui indication will be send to the plugins
screen.render();
}
ScreenInstruction::ToggleFloatingPanes(client_id, default_shell) => {
Expand All @@ -780,6 +782,7 @@ pub(crate) fn screen_thread_main(
.senders
.send_to_server(ServerInstruction::UnblockInputThread)
.unwrap();
screen.update_tabs(); // update tabs so that the ui indication will be send to the plugins
screen.render();
}
ScreenInstruction::HorizontalSplit(pid, client_id) => {
Expand Down
3 changes: 3 additions & 0 deletions zellij-server/src/tab/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,9 @@ impl Tab {
pub fn is_fullscreen_active(&self) -> bool {
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) {
self.fullscreen_is_active = !self.fullscreen_is_active;
}
Expand Down
1 change: 1 addition & 0 deletions zellij-tile/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ pub struct TabInfo {
pub panes_to_hide: usize,
pub is_fullscreen_active: bool,
pub is_sync_panes_active: bool,
pub are_floating_panes_visible: bool,
pub other_focused_clients: Vec<ClientId>,
}

Expand Down