diff options
26 files changed, 249 insertions, 193 deletions
diff --git a/default-plugins/status-bar/src/first_line.rs b/default-plugins/status-bar/src/first_line.rs index ed67e5cc5..7ca0b0fb6 100644 --- a/default-plugins/status-bar/src/first_line.rs +++ b/default-plugins/status-bar/src/first_line.rs @@ -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, diff --git a/default-plugins/status-bar/src/main.rs b/default-plugins/status-bar/src/main.rs index daeb30f13..471c45c76 100644 --- a/default-plugins/status-bar/src/main.rs +++ b/default-plugins/status-bar/src/main.rs @@ -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, @@ -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); } @@ -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 { diff --git a/default-plugins/status-bar/src/second_line.rs b/default-plugins/status-bar/src/second_line.rs index 77868a72c..9601c4251 100644 --- a/default-plugins/status-bar/src/second_line.rs +++ b/default-plugins/status-bar/src/second_line.rs @@ -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 @@ -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), @@ -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 @@ -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) @@ -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); @@ -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,); @@ -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); @@ -287,7 +287,7 @@ 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 { @@ -295,7 +295,7 @@ fn best_effort_shortcut_list(help: &ModeInfo, tip: TipFn, max_len: usize) -> Lin } } 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 { @@ -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), }; @@ -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), }; @@ -494,7 +494,7 @@ 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,); } @@ -502,11 +502,11 @@ pub fn full_tmux_mode_indication(help: &ModeInfo) -> LinePart { } 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), }; @@ -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); } diff --git a/default-plugins/tab-bar/src/main.rs b/default-plugins/tab-bar/src/main.rs index 3db531384..05f241bbb 100644 --- a/default-plugins/tab-bar/src/main.rs +++ b/default-plugins/tab-bar/src/main.rs @@ -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(), ); @@ -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(); @@ -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); } diff --git a/src/tests/e2e/remote_runner.rs b/src/tests/e2e/remote_runner.rs index 4a7d7fbfd..042ae9b6f 100644 --- a/src/tests/e2e/remote_runner.rs +++ b/src/tests/e2e/remote_runner.rs @@ -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::*; @@ -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())), diff --git a/zellij-client/src/lib.rs b/zellij-client/src/lib.rs index bd5db5cd1..207216638 100644 --- a/zellij-client/src/lib.rs +++ b/zellij-client/src/lib.rs @@ -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, @@ -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 { diff --git a/zellij-server/src/lib.rs b/zellij-server/src/lib.rs index 7880d5f9d..13d2f5c56 100644 --- a/zellij-server/src/lib.rs +++ b/zellij-server/src/lib.rs @@ -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, @@ -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<()>>, @@ -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 @@ -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), diff --git a/zellij-server/src/panes/floating_panes/mod.rs b/zellij-server/src/panes/floating_panes/mod.rs index 99cf7e9de..e4925c365 100644 --- a/zellij-server/src/panes/floating_panes/mod.rs +++ b/zellij-server/src/panes/floating_panes/mod.rs @@ -1,5 +1,5 @@ +use zellij_tile::prelude::Style; mod floating_pane_grid; - use zellij_utils::{position::Position, zellij_tile}; use crate::tab::Pane; @@ -16,7 +16,7 @@ use std::cell::RefCell; use std::collections::{BTreeMap, HashMap, HashSet}; use std::rc::Rc; use std::time::Instant; -use zellij_tile::data::{ModeInfo, Palette}; +use zellij_tile::data::ModeInfo; use zellij_utils::pane_size::{Offset, PaneGeom, Size, Viewport}; macro_rules! resize_pty { @@ -41,7 +41,7 @@ pub struct FloatingPanes { connected_clients_in_app: Rc<RefCell<HashSet<ClientId>>>, mode_info: Rc<RefCell<HashMap<ClientId, ModeInfo>>>, default_mode_info: ModeInfo, - colors: Palette, + style: Style, session_is_mirrored: bool, desired_pane_positions: HashMap<PaneId, PaneGeom>, // this represents the positions of panes the user moved with intention, rather than by resizing the terminal window z_indices: Vec<PaneId>, @@ -51,6 +51,7 @@ pub struct FloatingPanes { } #[allow(clippy::borrowed_box)] +#[allow(clippy::too_many_arguments)] impl FloatingPanes { pub fn new( display_area: Rc<RefCell<Size>>, @@ -60,7 +61,7 @@ impl FloatingPanes { mode_info: Rc<RefCell<HashMap<ClientId, ModeInfo>>>, session_is_mirrored: bool, default_mode_info: ModeInfo, - colors: Palette, + style: Style, ) -> Self { FloatingPanes { panes: BTreeMap::new(), @@ -71,7 +72,7 @@ impl FloatingPanes { mode_info, session_is_mirrored, default_mode_info, - colors, + style, desired_pane_positions: HashMap::new(), z_indices: vec![], show_panes: false, @@ -198,7 +199,7 @@ impl FloatingPanes { let mut pane_contents_and_ui = PaneContentsAndUi::new( pane, output, - self.colors, + self.style, &active_panes, multiple_users_exist_in_session, Some(z_index + 1), // +1 because 0 is reserved for non-floating panes @@ -207,7 +208,7 @@ impl FloatingPanes { let client_mode = self .mode_info .borrow() - .get(&client_id) + .get(client_id) .unwrap_or(&self.default_mode_info) .mode; pane_contents_and_ui.render_pane_frame( diff --git a/zellij-server/src/panes/terminal_pane.rs b/zellij-server/src/panes/terminal_pane.rs index 5ac94c4f3..fb6a07221 100644 --- a/zellij-server/src/panes/terminal_pane.rs +++ b/zellij-server/src/panes/terminal_pane.rs @@ -13,13 +13,14 @@ use std::fmt::Debug; use std::os::unix::io::RawFd; use std::rc::Rc; use std::time::{self, Instant}; +use zellij_tile::prelude::Style; use zellij_utils::pane_size::Offset; use zellij_utils::{ pane_size::{Dimension, PaneGeom}, position::Position, shared::make_terminal_title, vte, - zellij_tile::data::{InputMode, Palette, PaletteColor}, + zellij_tile::data::{InputMode, PaletteColor}, }; pub const SELECTION_SCROLL_INTERVAL_MS: u64 = 10; @@ -41,7 +42,7 @@ pub struct TerminalPane { pub geom: PaneGeom, pub geom_override: Option<PaneGeom>, pub active_at: Instant, - pub colors: Palette, + pub style: Style, vte_parser: vte::Parser, selection_scrolled_at: time::Instant, content_offset: Offset, @@ -216,7 +217,7 @@ impl Pane for TerminalPane { .selection .contains_row(character_chunk.y.saturating_sub(content_y)) { - let background_color = match self.colors.bg { + let background_color = match self.style.colors.bg { PaletteColor::Rgb(rgb) => AnsiCode::RgbCode(rgb), PaletteColor::EightBit(col) => AnsiCode::ColorIndex(col), }; @@ -482,7 +483,7 @@ impl TerminalPane { pub fn new( pid: RawFd, position_and_size: PaneGeom, - palette: Palette, + style: Style, pane_index: usize, pane_name: String, link_handler: Rc<RefCell<LinkHandler>>, @@ -491,7 +492,7 @@ impl TerminalPane { let grid = Grid::new( position_and_size.rows.as_usize(), position_and_size.cols.as_usize(), - palette, + style.colors, link_handler, ); TerminalPane { @@ -504,7 +505,7 @@ impl TerminalPane |