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

feat(ui): round frame corners #1227

Merged
merged 8 commits into from
Mar 22, 2022
2 changes: 1 addition & 1 deletion default-plugins/status-bar/src/first_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ pub fn superkey(palette: ColoredElements, separator: &str) -> LinePart {
}

pub fn ctrl_keys(help: &ModeInfo, max_len: usize, separator: &str) -> LinePart {
let colored_elements = color_elements(help.palette);
let colored_elements = color_elements(help.style.colors);
match &help.mode {
InputMode::Locked => key_indicators(
max_len,
Expand Down
25 changes: 14 additions & 11 deletions default-plugins/status-bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ impl ZellijPlugin for State {
let separator = if !self.mode_info.capabilities.arrow_fonts {
ARROW_SEPARATOR
} else {
&""
""
};

let colored_elements = color_elements(self.mode_info.palette);
let colored_elements = color_elements(self.mode_info.style.colors);
let superkey = superkey(colored_elements, separator);
let ctrl_keys = ctrl_keys(
&self.mode_info,
Expand All @@ -191,7 +191,7 @@ impl ZellijPlugin for State {

// [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
match self.mode_info.palette.gray {
match self.mode_info.style.colors.gray {
PaletteColor::Rgb((r, g, b)) => {
println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", first_line, r, g, b);
}
Expand All @@ -208,25 +208,28 @@ impl State {
let active_tab = self.tabs.iter().find(|t| t.active);

if let Some(copy_destination) = self.text_copy_destination {
text_copied_hint(&self.mode_info.palette, copy_destination)
text_copied_hint(&self.mode_info.style.colors, copy_destination)
} else if self.display_system_clipboard_failure {
system_clipboard_error(&self.mode_info.palette)
system_clipboard_error(&self.mode_info.style.colors)
} else if let Some(active_tab) = active_tab {
if active_tab.is_fullscreen_active {
match self.mode_info.mode {
InputMode::Normal => {
fullscreen_panes_to_hide(&self.mode_info.palette, active_tab.panes_to_hide)
}
InputMode::Normal => fullscreen_panes_to_hide(
&self.mode_info.style.colors,
active_tab.panes_to_hide,
),
InputMode::Locked => locked_fullscreen_panes_to_hide(
&self.mode_info.palette,
&self.mode_info.style.colors,
active_tab.panes_to_hide,
),
_ => 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),
InputMode::Normal => floating_panes_are_visible(&self.mode_info.style.colors),
InputMode::Locked => {
locked_floating_panes_are_visible(&self.mode_info.style.colors)
}
_ => keybinds(&self.mode_info, &self.tip_name, cols),
}
} else {
Expand Down
42 changes: 21 additions & 21 deletions default-plugins/status-bar/src/second_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ fn full_shortcut_list_nonstandard_mode(
move |help| {
let mut line_part = LinePart::default();
for (i, (letter, description)) in help.keybinds.iter().enumerate() {
let shortcut = full_length_shortcut(i == 0, letter, description, help.palette);
let shortcut = full_length_shortcut(i == 0, letter, description, help.style.colors);
line_part.len += shortcut.len;
line_part.part = format!("{}{}", line_part.part, shortcut,);
}
let select_pane_shortcut = extra_hint_producing_function(help.palette);
let select_pane_shortcut = extra_hint_producing_function(help.style.colors);
line_part.len += select_pane_shortcut.len;
line_part.part = format!("{}{}", line_part.part, select_pane_shortcut,);
line_part
Expand All @@ -206,8 +206,8 @@ fn full_shortcut_list_nonstandard_mode(

fn full_shortcut_list(help: &ModeInfo, tip: TipFn) -> LinePart {
match help.mode {
InputMode::Normal => tip(help.palette),
InputMode::Locked => locked_interface_indication(help.palette),
InputMode::Normal => tip(help.style.colors),
InputMode::Locked => locked_interface_indication(help.style.colors),
InputMode::Tmux => full_tmux_mode_indication(help),
InputMode::RenamePane => full_shortcut_list_nonstandard_mode(select_pane_shortcut)(help),
_ => full_shortcut_list_nonstandard_mode(confirm_pane_selection)(help),
Expand All @@ -220,11 +220,11 @@ fn shortened_shortcut_list_nonstandard_mode(
move |help| {
let mut line_part = LinePart::default();
for (i, (letter, description)) in help.keybinds.iter().enumerate() {
let shortcut = first_word_shortcut(i == 0, letter, description, help.palette);
let shortcut = first_word_shortcut(i == 0, letter, description, help.style.colors);
line_part.len += shortcut.len;
line_part.part = format!("{}{}", line_part.part, shortcut,);
}
let select_pane_shortcut = extra_hint_producing_function(help.palette);
let select_pane_shortcut = extra_hint_producing_function(help.style.colors);
line_part.len += select_pane_shortcut.len;
line_part.part = format!("{}{}", line_part.part, select_pane_shortcut,);
line_part
Expand All @@ -233,8 +233,8 @@ fn shortened_shortcut_list_nonstandard_mode(

fn shortened_shortcut_list(help: &ModeInfo, tip: TipFn) -> LinePart {
match help.mode {
InputMode::Normal => tip(help.palette),
InputMode::Locked => locked_interface_indication(help.palette),
InputMode::Normal => tip(help.style.colors),
InputMode::Locked => locked_interface_indication(help.style.colors),
InputMode::Tmux => short_tmux_mode_indication(help),
InputMode::RenamePane => {
shortened_shortcut_list_nonstandard_mode(select_pane_shortcut)(help)
Expand All @@ -249,7 +249,7 @@ fn best_effort_shortcut_list_nonstandard_mode(
move |help, max_len| {
let mut line_part = LinePart::default();
for (i, (letter, description)) in help.keybinds.iter().enumerate() {
let shortcut = first_word_shortcut(i == 0, letter, description, help.palette);
let shortcut = first_word_shortcut(i == 0, letter, description, help.style.colors);
if line_part.len + shortcut.len + MORE_MSG.chars().count() > max_len {
// TODO: better
line_part.part = format!("{}{}", line_part.part, MORE_MSG);
Expand All @@ -259,7 +259,7 @@ fn best_effort_shortcut_list_nonstandard_mode(
line_part.len += shortcut.len;
line_part.part = format!("{}{}", line_part.part, shortcut);
}
let select_pane_shortcut = extra_hint_producing_function(help.palette);
let select_pane_shortcut = extra_hint_producing_function(help.style.colors);
if line_part.len + select_pane_shortcut.len <= max_len {
line_part.len += select_pane_shortcut.len;
line_part.part = format!("{}{}", line_part.part, select_pane_shortcut,);
Expand All @@ -271,7 +271,7 @@ fn best_effort_shortcut_list_nonstandard_mode(
fn best_effort_tmux_shortcut_list(help: &ModeInfo, max_len: usize) -> LinePart {
let mut line_part = tmux_mode_indication(help);
for (i, (letter, description)) in help.keybinds.iter().enumerate() {
let shortcut = first_word_shortcut(i == 0, letter, description, help.palette);
let shortcut = first_word_shortcut(i == 0, letter, description, help.style.colors);
if line_part.len + shortcut.len + MORE_MSG.chars().count() > max_len {
// TODO: better
line_part.part = format!("{}{}", line_part.part, MORE_MSG);
Expand All @@ -287,15 +287,15 @@ fn best_effort_tmux_shortcut_list(help: &ModeInfo, max_len: usize) -> LinePart {
fn best_effort_shortcut_list(help: &ModeInfo, tip: TipFn, max_len: usize) -> LinePart {
match help.mode {
InputMode::Normal => {
let line_part = tip(help.palette);
let line_part = tip(help.style.colors);
if line_part.len <= max_len {
line_part
} else {
LinePart::default()
}
}
InputMode::Locked => {
let line_part = locked_interface_indication(help.palette);
let line_part = locked_interface_indication(help.style.colors);
if line_part.len <= max_len {
line_part
} else {
Expand Down Expand Up @@ -448,11 +448,11 @@ pub fn floating_panes_are_visible(palette: &Palette) -> LinePart {
}

pub fn tmux_mode_indication(help: &ModeInfo) -> LinePart {
let white_color = match help.palette.white {
let white_color = match help.style.colors.white {
PaletteColor::Rgb((r, g, b)) => RGB(r, g, b),
PaletteColor::EightBit(color) => Fixed(color),
};
let orange_color = match help.palette.orange {
let orange_color = match help.style.colors.orange {
PaletteColor::Rgb((r, g, b)) => RGB(r, g, b),
PaletteColor::EightBit(color) => Fixed(color),
};
Expand All @@ -472,11 +472,11 @@ pub fn tmux_mode_indication(help: &ModeInfo) -> LinePart {
}

pub fn full_tmux_mode_indication(help: &ModeInfo) -> LinePart {
let white_color = match help.palette.white {
let white_color = match help.style.colors.white {
PaletteColor::Rgb((r, g, b)) => RGB(r, g, b),
PaletteColor::EightBit(color) => Fixed(color),
};
let orange_color = match help.palette.orange {
let orange_color = match help.style.colors.orange {
PaletteColor::Rgb((r, g, b)) => RGB(r, g, b),
PaletteColor::EightBit(color) => Fixed(color),
};
Expand All @@ -494,19 +494,19 @@ pub fn full_tmux_mode_indication(help: &ModeInfo) -> LinePart {
};

for (i, (letter, description)) in help.keybinds.iter().enumerate() {
let shortcut = full_length_shortcut(i == 0, letter, description, help.palette);
let shortcut = full_length_shortcut(i == 0, letter, description, help.style.colors);
line_part.len += shortcut.len;
line_part.part = format!("{}{}", line_part.part, shortcut,);
}
line_part
}

pub fn short_tmux_mode_indication(help: &ModeInfo) -> LinePart {
let white_color = match help.palette.white {
let white_color = match help.style.colors.white {
PaletteColor::Rgb((r, g, b)) => RGB(r, g, b),
PaletteColor::EightBit(color) => Fixed(color),
};
let orange_color = match help.palette.orange {
let orange_color = match help.style.colors.orange {
PaletteColor::Rgb((r, g, b)) => RGB(r, g, b),
PaletteColor::EightBit(color) => Fixed(color),
};
Expand All @@ -524,7 +524,7 @@ pub fn short_tmux_mode_indication(help: &ModeInfo) -> LinePart {
};

for (i, (letter, description)) in help.keybinds.iter().enumerate() {
let shortcut = first_word_shortcut(i == 0, letter, description, help.palette);
let shortcut = first_word_shortcut(i == 0, letter, description, help.style.colors);
line_part.len += shortcut.len;
line_part.part = format!("{}{}", line_part.part, shortcut);
}
Expand Down
6 changes: 3 additions & 3 deletions default-plugins/tab-bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl ZellijPlugin for State {
tabname,
t.active,
t.is_sync_panes_active,
self.mode_info.palette,
self.mode_info.style.colors,
self.mode_info.capabilities,
t.other_focused_clients.as_slice(),
);
Expand All @@ -94,7 +94,7 @@ impl ZellijPlugin for State {
all_tabs,
active_tab_index,
cols.saturating_sub(1),
self.mode_info.palette,
self.mode_info.style.colors,
self.mode_info.capabilities,
);
let mut s = String::new();
Expand All @@ -113,7 +113,7 @@ impl ZellijPlugin for State {
}
len_cnt += bar_part.len;
}
match self.mode_info.palette.gray {
match self.mode_info.style.colors.gray {
PaletteColor::Rgb((r, g, b)) => {
println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", s, r, g, b);
}
Expand Down
6 changes: 3 additions & 3 deletions src/tests/e2e/remote_runner.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use zellij_tile::data::Palette;

use zellij_server::panes::{LinkHandler, TerminalPane};
use zellij_utils::pane_size::{Dimension, PaneGeom, Size};
use zellij_utils::{vte, zellij_tile};
use zellij_utils::vte;
use zellij_utils::zellij_tile::prelude::Style;

use ssh2::Session;
use std::io::prelude::*;
Expand Down Expand Up @@ -157,7 +157,7 @@ fn read_from_channel(
let mut terminal_output = TerminalPane::new(
0,
pane_geom,
Palette::default(),
Style::default(),
0,
String::new(),
Rc::new(RefCell::new(LinkHandler::new())),
Expand Down
6 changes: 5 additions & 1 deletion zellij-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::io::{self, Write};
use std::path::Path;
use std::process::Command;
use std::thread;
use zellij_tile::prelude::Style;

use crate::{
command_is_executing::CommandIsExecuting, input_handler::input_loop,
Expand Down Expand Up @@ -146,7 +147,10 @@ pub fn start_client(
let full_screen_ws = os_input.get_terminal_size_using_fd(0);
let client_attributes = ClientAttributes {
size: full_screen_ws,
palette,
style: Style {
colors: palette,
rounded_corners: config.ui.unwrap_or_default().pane_frames.rounded_corners,
},
};

let first_msg = match info {
Expand Down
10 changes: 5 additions & 5 deletions zellij-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ use std::{
sync::{Arc, Mutex, RwLock},
thread,
};
use zellij_tile::prelude::Style;
use zellij_utils::envs;
use zellij_utils::nix::sys::stat::{umask, Mode};
use zellij_utils::pane_size::Size;
use zellij_utils::zellij_tile;

use wasmer::Store;
use zellij_tile::data::{Event, Palette, PluginCapabilities};
use zellij_tile::data::{Event, PluginCapabilities};

use crate::{
os_input_output::ServerOsApi,
Expand Down Expand Up @@ -100,7 +101,7 @@ impl ErrorInstruction for ServerInstruction {
pub(crate) struct SessionMetaData {
pub senders: ThreadSenders,
pub capabilities: PluginCapabilities,
pub palette: Palette,
pub style: Style,
pub default_shell: Option<TerminalAction>,
screen_thread: Option<thread::JoinHandle<()>>,
pty_thread: Option<thread::JoinHandle<()>>,
Expand Down Expand Up @@ -371,8 +372,7 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
.send_to_plugin(PluginInstruction::AddClient(client_id))
.unwrap();
let default_mode = options.default_mode.unwrap_or_default();
let mode_info =
get_mode_info(default_mode, attrs.palette, session_data.capabilities);
let mode_info = get_mode_info(default_mode, attrs.style, session_data.capabilities);
let mode = mode_info.mode;
session_data
.senders
Expand Down Expand Up @@ -645,7 +645,7 @@ fn init_session(
},
capabilities,
default_shell,
palette: client_attributes.palette,
style: client_attributes.style,
screen_thread: Some(screen_thread),
pty_thread: Some(pty_thread),
wasm_thread: Some(wasm_thread),
Expand Down
Loading