feat(ui): round frame corners (#1227)

* feat(ui): round frame corners

* Allow rounded_corners to be set without a palette

* Revert "Allow rounded_corners to be set without a palette"

This reverts commit 9271a4b545.

* fix(style): remove redundant code

* fix(style): clippy lints that somehow got missed

* feat(config): add ui config section
This commit is contained in:
Brooks Rady 2022-03-22 14:58:16 +00:00 committed by GitHub
parent 2d55a3e274
commit 9bfafde123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 249 additions and 193 deletions

View File

@ -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,

View File

@ -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 {

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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())),

View File

@ -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 {

View File

@ -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),

View File

@ -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(

View File

@ -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 {
geom_override: None,
vte_parser: vte::Parser::new(),
active_at: Instant::now(),
colors: palette,
style,
selection_scrolled_at: time::Instant::now(),
pane_title: initial_pane_title,
pane_name,

View File

@ -1,6 +1,7 @@
mod pane_resizer;
mod tiled_pane_grid;
use zellij_tile::prelude::Style;
use zellij_utils::zellij_tile;
use crate::tab::{Pane, MIN_TERMINAL_HEIGHT, MIN_TERMINAL_WIDTH};
@ -14,7 +15,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::{
input::layout::Direction,
pane_size::{Offset, PaneGeom, Size, Viewport},
@ -61,7 +62,7 @@ pub struct TiledPanes {
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,
active_panes: HashMap<ClientId, PaneId>,
draw_pane_frames: bool,
@ -71,6 +72,7 @@ pub struct TiledPanes {
}
impl TiledPanes {
#[allow(clippy::too_many_arguments)]
pub fn new(
display_area: Rc<RefCell<Size>>,
viewport: Rc<RefCell<Viewport>>,
@ -80,7 +82,7 @@ impl TiledPanes {
session_is_mirrored: bool,
draw_pane_frames: bool,
default_mode_info: ModeInfo,
colors: Palette,
style: Style,
os_api: Box<dyn ServerOsApi>,
) -> Self {
TiledPanes {
@ -91,7 +93,7 @@ impl TiledPanes {
connected_clients_in_app,
mode_info,
default_mode_info,
colors,
style,
session_is_mirrored,
active_panes: HashMap::new(),
draw_pane_frames,
@ -118,12 +120,7 @@ impl TiledPanes {
pane_to_split.set_geom(first_geom);
pane.set_geom(second_geom);
self.panes.insert(pane_id, pane);
// ¯\_(ツ)_/¯
let relayout_direction = match split_direction {
Direction::Vertical => Direction::Horizontal,
Direction::Horizontal => Direction::Vertical,
};
self.relayout(relayout_direction);
self.relayout(!split_direction);
}
}
}
@ -205,7 +202,7 @@ impl TiledPanes {
pane.set_content_offset(Offset::shift(pane_rows_offset, pane_columns_offset));
}
resize_pty!(pane, &mut self.os_api);
resize_pty!(pane, self.os_api);
}
}
pub fn can_split_pane_horizontally(&mut self, client_id: ClientId) -> bool {
@ -289,6 +286,9 @@ impl TiledPanes {
pub fn focused_pane_id(&self, client_id: ClientId) -> Option<PaneId> {
self.active_panes.get(&client_id).copied()
}
// FIXME: Really not a fan of allowing this... Someone with more energy
// than me should clean this up someday...
#[allow(clippy::borrowed_box)]
pub fn get_pane(&self, pane_id: PaneId) -> Option<&Box<dyn Pane>> {
self.panes.get(&pane_id)
}
@ -333,7 +333,7 @@ impl TiledPanes {
let mut pane_contents_and_ui = PaneContentsAndUi::new(
pane,
output,
self.colors,
self.style,
&active_panes,
multiple_users_exist_in_session,
None,
@ -342,7 +342,7 @@ impl TiledPanes {
let client_mode = self
.mode_info
.borrow()
.get(&client_id)
.get(client_id)
.unwrap_or(&self.default_mode_info)
.mode;
if let PaneId::Plugin(..) = kind {
@ -424,7 +424,7 @@ impl TiledPanes {
);
pane_grid.resize_pane_left(&active_pane_id);
for pane in self.panes.values_mut() {
resize_pty!(pane, &mut self.os_api);
resize_pty!(pane, self.os_api);
}
}
}
@ -437,7 +437,7 @@ impl TiledPanes {
);
pane_grid.resize_pane_right(&active_pane_id);
for pane in self.panes.values_mut() {
resize_pty!(pane, &mut self.os_api);
resize_pty!(pane, self.os_api);
}
}
}
@ -450,7 +450,7 @@ impl TiledPanes {
);
pane_grid.resize_pane_up(&active_pane_id);
for pane in self.panes.values_mut() {
resize_pty!(pane, &mut self.os_api);
resize_pty!(pane, self.os_api);
}
}
}
@ -463,7 +463,7 @@ impl TiledPanes {
);
pane_grid.resize_pane_down(&active_pane_id);
for pane in self.panes.values_mut() {
resize_pty!(pane, &mut self.os_api);
resize_pty!(pane, self.os_api);
}
}
}
@ -476,7 +476,7 @@ impl TiledPanes {
);
pane_grid.resize_increase(&active_pane_id);
for pane in self.panes.values_mut() {
resize_pty!(pane, &mut self.os_api);
resize_pty!(pane, self.os_api);
}
}
}
@ -489,7 +489,7 @@ impl TiledPanes {
);
pane_grid.resize_decrease(&active_pane_id);
for pane in self.panes.values_mut() {
resize_pty!(pane, &mut self.os_api);
resize_pty!(pane, self.os_api);
}
}
}
@ -560,16 +560,12 @@ impl TiledPanes {
self.focus_pane(p, client_id);
self.set_pane_active_at(p);
return true;
}
None => {
return false;
true
}
None => false,
}
}
None => {
return false;
}
None => false,
}
}
pub fn move_focus_down(&mut self, client_id: ClientId) -> bool {
@ -604,16 +600,12 @@ impl TiledPanes {
self.focus_pane(p, client_id);
self.set_pane_active_at(p);
return true;
}
None => {
return false;
true
}
None => false,
}
}
None => {
return false;
}
None => false,
}
}
pub fn move_focus_up(&mut self, client_id: ClientId) -> bool {
@ -648,16 +640,12 @@ impl TiledPanes {
self.focus_pane(p, client_id);
self.set_pane_active_at(p);
return true;
}
None => {
return false;
true
}
None => false,
}
}
None => {
return false;
}
None => false,
}
}
pub fn move_focus_right(&mut self, client_id: ClientId) -> bool {
@ -692,16 +680,12 @@ impl TiledPanes {
self.focus_pane(p, client_id);
self.set_pane_active_at(p);
return true;
}
None => {
return false;
true
}
None => false,
}
}
None => {
return false;
}
None => false,
}
}
pub fn move_active_pane(&mut self, client_id: ClientId) {
@ -723,7 +707,7 @@ impl TiledPanes {
if let Some(geom) = prev_geom_override {
new_position.get_geom_override(geom);
}
resize_pty!(new_position, &mut self.os_api);
resize_pty!(new_position, self.os_api);
new_position.set_should_render(true);
let current_position = self.panes.get_mut(&active_pane_id).unwrap();
@ -731,7 +715,7 @@ impl TiledPanes {
if let Some(geom) = next_geom_override {
current_position.get_geom_override(geom);
}
resize_pty!(current_position, &mut self.os_api);
resize_pty!(current_position, self.os_api);
current_position.set_should_render(true);
}
pub fn move_active_pane_down(&mut self, client_id: ClientId) {
@ -755,7 +739,7 @@ impl TiledPanes {
if let Some(geom) = prev_geom_override {
new_position.get_geom_override(geom);
}
resize_pty!(new_position, &mut self.os_api);
resize_pty!(new_position, self.os_api);
new_position.set_should_render(true);
let current_position = self.panes.get_mut(active_pane_id).unwrap();
@ -763,7 +747,7 @@ impl TiledPanes {
if let Some(geom) = next_geom_override {
current_position.get_geom_override(geom);
}
resize_pty!(current_position, &mut self.os_api);
resize_pty!(current_position, self.os_api);
current_position.set_should_render(true);
}
}
@ -789,7 +773,7 @@ impl TiledPanes {
if let Some(geom) = prev_geom_override {
new_position.get_geom_override(geom);
}
resize_pty!(new_position, &mut self.os_api);
resize_pty!(new_position, self.os_api);
new_position.set_should_render(true);
let current_position = self.panes.get_mut(active_pane_id).unwrap();
@ -797,7 +781,7 @@ impl TiledPanes {
if let Some(geom) = next_geom_override {
current_position.get_geom_override(geom);
}
resize_pty!(current_position, &mut self.os_api);
resize_pty!(current_position, self.os_api);
current_position.set_should_render(true);
}
}
@ -823,7 +807,7 @@ impl TiledPanes {
if let Some(geom) = prev_geom_override {
new_position.get_geom_override(geom);
}
resize_pty!(new_position, &mut self.os_api);
resize_pty!(new_position, self.os_api);
new_position.set_should_render(true);
let current_position = self.panes.get_mut(active_pane_id).unwrap();
@ -831,7 +815,7 @@ impl TiledPanes {
if let Some(geom) = next_geom_override {
current_position.get_geom_override(geom);
}
resize_pty!(current_position, &mut self.os_api);
resize_pty!(current_position, self.os_api);
current_position.set_should_render(true);
}
}
@ -857,7 +841,7 @@ impl TiledPanes {
if let Some(geom) = prev_geom_override {
new_position.get_geom_override(geom);
}
resize_pty!(new_position, &mut self.os_api);
resize_pty!(new_position, self.os_api);
new_position.set_should_render(true);
let current_position = self.panes.get_mut(active_pane_id).unwrap();
@ -865,7 +849,7 @@ impl TiledPanes {
if let Some(geom) = next_geom_override {
current_position.get_geom_override(geom);
}
resize_pty!(current_position, &mut self.os_api);
resize_pty!(current_position, self.os_api);
current_position.set_should_render(true);
}
}
@ -903,7 +887,7 @@ impl TiledPanes {
let closed_pane = self.panes.remove(&pane_id);
self.move_clients_out_of_pane(pane_id);
for pane in self.panes.values_mut() {
resize_pty!(pane, &mut self.os_api);
resize_pty!(pane, self.os_api);
}
closed_pane
} else {

View File

@ -4,8 +4,8 @@ use crate::tab::Pane;
use ::insta::assert_snapshot;
use std::cell::RefCell;
use std::rc::Rc;
use zellij_tile::prelude::Style;
use zellij_utils::pane_size::PaneGeom;
use zellij_utils::zellij_tile::data::Palette;
use std::fmt::Write;
@ -17,11 +17,11 @@ pub fn scrolling_inside_a_pane() {
fake_win_size.rows.set_inner(20);
let pid = 1;
let palette = Palette::default();
let style = Style::default();
let mut terminal_pane = TerminalPane::new(
pid,
fake_win_size,
palette,
style,
0,
String::new(),
Rc::new(RefCell::new(LinkHandler::new())),

View File

@ -66,7 +66,7 @@ fn route_action(
.unwrap();
}
Action::SwitchToMode(mode) => {
let palette = session.palette;
let style = session.style;
// TODO: use the palette from the client and remove it from the server os api
// this is left here as a stop gap measure until we shift some code around
// to allow for this
@ -75,13 +75,13 @@ fn route_action(
.send_to_plugin(PluginInstruction::Update(
None,
Some(client_id),
Event::ModeUpdate(get_mode_info(mode, palette, session.capabilities)),
Event::ModeUpdate(get_mode_info(mode, style, session.capabilities)),
))
.unwrap();
session
.senders
.send_to_screen(ScreenInstruction::ChangeMode(
get_mode_info(mode, palette, session.capabilities),
get_mode_info(mode, style, session.capabilities),
client_id,
))
.unwrap();

View File

@ -6,6 +6,7 @@ use std::os::unix::io::RawFd;
use std::rc::Rc;
use std::str;
use zellij_tile::prelude::Style;
use zellij_utils::input::options::Clipboard;
use zellij_utils::pane_size::Size;
use zellij_utils::{
@ -22,7 +23,7 @@ use crate::{
wasm_vm::PluginInstruction,
ClientId, ServerInstruction,
};
use zellij_tile::data::{Event, InputMode, ModeInfo, Palette, PluginCapabilities, TabInfo};
use zellij_tile::data::{Event, InputMode, ModeInfo, PluginCapabilities, TabInfo};
use zellij_utils::{
errors::{ContextType, ScreenContext},
input::{get_mode_info, options::Options},
@ -200,7 +201,7 @@ pub(crate) struct Screen {
tab_history: BTreeMap<ClientId, Vec<usize>>,
mode_info: BTreeMap<ClientId, ModeInfo>,
default_mode_info: ModeInfo, // TODO: restructure ModeInfo to prevent this duplication
colors: Palette,
style: Style,
draw_pane_frames: bool,
session_is_mirrored: bool,
copy_command: Option<String>,
@ -224,7 +225,7 @@ impl Screen {
bus,
max_panes,
size: client_attributes.size,
colors: client_attributes.palette,
style: client_attributes.style,
connected_clients: Rc::new(RefCell::new(HashSet::new())),
active_tab_indices: BTreeMap::new(),
tabs: BTreeMap::new(),
@ -503,8 +504,8 @@ impl Screen {
self.bus.os_input.as_ref().unwrap().clone(),
self.bus.senders.clone(),
self.max_panes,
self.style,
client_mode_info,
self.colors,
self.draw_pane_frames,
self.connected_clients.clone(),
self.session_is_mirrored,
@ -653,7 +654,7 @@ impl Screen {
.unwrap()
.clear_active_terminal_scroll(client_id);
}
self.colors = mode_info.palette;
self.style = mode_info.style;
self.mode_info.insert(client_id, mode_info.clone());
for tab in self.tabs.values_mut() {
tab.change_mode_info(mode_info.clone(), client_id);
@ -709,7 +710,7 @@ pub(crate) fn screen_thread_main(
max_panes,
get_mode_info(
config_options.default_mode.unwrap_or_default(),
client_attributes.palette,
client_attributes.style,
PluginCapabilities {
arrow_fonts: capabilities.unwrap_or_default(),
},
@ -1289,7 +1290,7 @@ pub(crate) fn screen_thread_main(
}
ScreenInstruction::ConfirmPrompt(_client_id) => {
let overlay = screen.get_active_overlays_mut().pop();
let instruction = overlay.map(|o| o.prompt_confirm()).flatten();
let instruction = overlay.and_then(|o| o.prompt_confirm());
if let Some(instruction) = instruction {
screen.bus.senders.send_to_server(*instruction).unwrap();
}

View File

@ -5,6 +5,7 @@ mod clipboard;
mod copy_command;
use copy_command::CopyCommand;
use zellij_tile::prelude::Style;
use zellij_utils::input::options::Clipboard;
use zellij_utils::position::{Column, Line};
use zellij_utils::{position::Position, serde, zellij_tile};
@ -77,7 +78,7 @@ pub(crate) struct Tab {
should_clear_display_before_rendering: bool,
mode_info: Rc<RefCell<HashMap<ClientId, ModeInfo>>>,
default_mode_info: ModeInfo,
pub colors: Palette,
pub style: Style,
connected_clients: Rc<RefCell<HashSet<ClientId>>>,
draw_pane_frames: bool,
pending_vte_events: HashMap<RawFd, Vec<VteBytes>>,
@ -272,8 +273,8 @@ impl Tab {
os_api: Box<dyn ServerOsApi>,
senders: ThreadSenders,
max_panes: Option<usize>,
style: Style,
default_mode_info: ModeInfo,
colors: Palette,
draw_pane_frames: bool,
connected_clients_in_app: Rc<RefCell<HashSet<ClientId>>>,
session_is_mirrored: bool,
@ -304,18 +305,18 @@ impl Tab {
session_is_mirrored,
draw_pane_frames,
default_mode_info.clone(),
colors,
style,
os_api.clone(),
);
let floating_panes = FloatingPanes::new(
display_area.clone(),
viewport.clone(),
connected_clients.clone(),
connected_clients_in_app.clone(),
connected_clients_in_app,
mode_info.clone(),
session_is_mirrored,
default_mode_info.clone(),
colors,
style,
);
let clipboard_provider = match copy_command {
@ -336,9 +337,9 @@ impl Tab {
os_api,
senders,
should_clear_display_before_rendering: false,
style,
mode_info,
default_mode_info,
colors,
draw_pane_frames,
pending_vte_events: HashMap::new(),
connected_clients,
@ -408,7 +409,7 @@ impl Tab {
let mut new_pane = TerminalPane::new(
*pid,
*position_and_size,
self.colors,
self.style,
next_terminal_position,
layout.pane_name.clone().unwrap_or_default(),
self.link_handler.clone(),
@ -632,7 +633,7 @@ impl Tab {
let mut new_pane = TerminalPane::new(
term_pid,
new_pane_geom,
self.colors,
self.style,
next_terminal_position,
String::new(),
self.link_handler.clone(),
@ -653,7 +654,7 @@ impl Tab {
let new_terminal = TerminalPane::new(
term_pid,
PaneGeom::default(), // the initial size will be set later
self.colors,
self.style,
next_terminal_position,
String::new(),
self.link_handler.clone(),
@ -681,7 +682,7 @@ impl Tab {
let new_terminal = TerminalPane::new(
term_pid,
PaneGeom::default(), // the initial size will be set later
self.colors,
self.style,
next_terminal_position,
String::new(),
self.link_handler.clone(),
@ -707,7 +708,7 @@ impl Tab {
let new_terminal = TerminalPane::new(
term_pid,
PaneGeom::default(), // the initial size will be set later
self.colors,
self.style,
next_terminal_position,
String::new(),
self.link_handler.clone(),
@ -1046,7 +1047,6 @@ impl Tab {
.resize_active_pane_left(client_id, &mut self.os_api);
if successfully_resized {
self.set_force_render(); // we force render here to make sure the panes under the floating pane render and don't leave "garbage" incase of a decrease
return;
}
} else {
self.tiled_panes.resize_active_pane_left(client_id);
@ -1059,7 +1059,6 @@ impl Tab {
.resize_active_pane_right(client_id, &mut self.os_api);
if successfully_resized {
self.set_force_render(); // we force render here to make sure the panes under the floating pane render and don't leave "garbage" incase of a decrease
return;
}
} else {
self.tiled_panes.resize_active_pane_right(client_id);
@ -1072,7 +1071,6 @@ impl Tab {
.resize_active_pane_down(client_id, &mut self.os_api);
if successfully_resized {
self.set_force_render(); // we force render here to make sure the panes under the floating pane render and don't leave "garbage" incase of a decrease
return;
}
} else {
self.tiled_panes.resize_active_pane_down(client_id);
@ -1085,7 +1083,6 @@ impl Tab {
.resize_active_pane_up(client_id, &mut self.os_api);
if successfully_resized {
self.set_force_render(); // we force render here to make sure the panes under the floating pane render and don't leave "garbage" incase of a decrease
return;
}
} else {
self.tiled_panes.resize_active_pane_up(client_id);
@ -1098,7 +1095,6 @@ impl Tab {
.resize_active_pane_increase(client_id, &mut self.os_api);
if successfully_resized {
self.set_force_render(); // we force render here to make sure the panes under the floating pane render and don't leave "garbage" incase of a decrease
return;
}
} else {
self.tiled_panes.resize_active_pane_increase(client_id);
@ -1111,7 +1107,6 @@ impl Tab {
.resize_active_pane_decrease(client_id, &mut self.os_api);
if successfully_resized {
self.set_force_render(); // we force render here to make sure the panes under the floating pane render and don't leave "garbage" incase of a decrease
return;
}
} else {
self.tiled_panes.resize_active_pane_decrease(client_id);

View File

@ -8,6 +8,7 @@ use crate::{
};
use std::convert::TryInto;
use std::path::PathBuf;
use zellij_tile::prelude::Style;
use zellij_utils::envs::set_session_name;
use zellij_utils::input::layout::LayoutTemplate;
use zellij_utils::input::options::Clipboard;
@ -94,7 +95,7 @@ fn create_new_tab(size: Size) -> Tab {
let senders = ThreadSenders::default().silently_fail_on_send();
let max_panes = None;
let mode_info = ModeInfo::default();
let colors = Palette::default();
let style = Style::default();
let draw_pane_frames = true;
let client_id = 1;
let session_is_mirrored = true;
@ -111,8 +112,8 @@ fn create_new_tab(size: Size) -> Tab {
os_api,
senders,
max_panes,
style,
mode_info,
colors,
draw_pane_frames,
connected_clients,
session_is_mirrored,

View File

@ -8,6 +8,7 @@ use crate::{
};
use std::convert::TryInto;
use std::path::PathBuf;
use zellij_tile::prelude::Style;
use zellij_utils::input::layout::LayoutTemplate;
use zellij_utils::input::options::Clipboard;
use zellij_utils::ipc::IpcReceiverWithContext;
@ -90,7 +91,7 @@ fn create_new_tab(size: Size) -> Tab {
let senders = ThreadSenders::default().silently_fail_on_send();
let max_panes = None;
let mode_info = ModeInfo::default();
let colors = Palette::default();
let style = Style::default();
let draw_pane_frames = true;
let client_id = 1;
let session_is_mirrored = true;
@ -107,8 +108,8 @@ fn create_new_tab(size: Size) -> Tab {
os_api,
senders,
max_panes,
style,
mode_info,
colors,
draw_pane_frames,
connected_clients,
session_is_mirrored,

View File

@ -11,11 +11,15 @@ use zellij_utils::shared::colors;
use std::fmt::{Display, Error, Formatter};
pub mod boundary_type {
pub const TOP_RIGHT: &str = "";
pub const TOP_RIGHT_ROUND: &str = "";
pub const VERTICAL: &str = "";
pub const HORIZONTAL: &str = "";
pub const TOP_LEFT: &str = "";
pub const TOP_LEFT_ROUND: &str = "";
pub const BOTTOM_RIGHT: &str = "";
pub const BOTTOM_RIGHT_ROUND: &str = "";
pub const BOTTOM_LEFT: &str = "";
pub const BOTTOM_LEFT_ROUND: &str = "";
pub const VERTICAL_LEFT: &str = "";
pub const VERTICAL_RIGHT: &str = "";
pub const HORIZONTAL_DOWN: &str = "";

View File

@ -2,8 +2,9 @@ use crate::output::CharacterChunk;
use crate::panes::{AnsiCode, CharacterStyles, TerminalCharacter, EMPTY_TERMINAL_CHARACTER};
use crate::ui::boundaries::boundary_type;
use crate::ClientId;
use zellij_tile::prelude::Style;
use zellij_utils::pane_size::Viewport;
use zellij_utils::zellij_tile::prelude::{client_id_to_colors, Palette, PaletteColor};
use zellij_utils::zellij_tile::prelude::{client_id_to_colors, PaletteColor};
use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};
@ -65,7 +66,7 @@ pub struct FrameParams {
pub focused_client: Option<ClientId>,
pub is_main_client: bool,
pub other_focused_clients: Vec<ClientId>,
pub colors: Palette,
pub style: Style,
pub color: Option<PaletteColor>,
pub other_cursors_exist_in_session: bool,
}
@ -75,7 +76,7 @@ pub struct PaneFrame {
pub geom: Viewport,
pub title: String,
pub scroll_position: (usize, usize), // (position, length)
pub colors: Palette,
pub style: Style,
pub color: Option<PaletteColor>,
pub focused_client: Option<ClientId>,
pub is_main_client: bool,
@ -94,7 +95,7 @@ impl PaneFrame {
geom,
title: main_title,
scroll_position,
colors: frame_params.colors,
style: frame_params.style,
color: frame_params.color,
focused_client: frame_params.focused_client,
is_main_client: frame_params.is_main_client,
@ -103,9 +104,22 @@ impl PaneFrame {
}
}
fn client_cursor(&self, client_id: ClientId) -> Vec<TerminalCharacter> {
let color = client_id_to_colors(client_id, self.colors);
let color = client_id_to_colors(client_id, self.style.colors);
background_color(" ", color.map(|c| c.0))
}
fn get_corner(&self, corner: &'static str) -> &'static str {
if self.style.rounded_corners {
match corner {
boundary_type::TOP_RIGHT => boundary_type::TOP_RIGHT_ROUND,
boundary_type::TOP_LEFT => boundary_type::TOP_LEFT_ROUND,
boundary_type::BOTTOM_RIGHT => boundary_type::BOTTOM_RIGHT_ROUND,
boundary_type::BOTTOM_LEFT => boundary_type::BOTTOM_LEFT_ROUND,
_ => corner,
}
} else {
corner
}
}
fn render_title_right_side(
&self,
max_length: usize,
@ -364,9 +378,15 @@ impl PaneFrame {
let mut col = self.geom.x;
loop {
if col == self.geom.x {
title_line.append(&mut foreground_color(boundary_type::TOP_LEFT, self.color));
title_line.append(&mut foreground_color(
self.get_corner(boundary_type::TOP_LEFT),
self.color,
));
} else if col == self.geom.x + self.geom.cols - 1 {
title_line.append(&mut foreground_color(boundary_type::TOP_RIGHT, self.color));
title_line.append(&mut foreground_color(
self.get_corner(boundary_type::TOP_RIGHT),
self.color,
));
} else if col == left_side_start_position {
title_line.append(&mut left_side);
col += left_side_len;
@ -404,9 +424,15 @@ impl PaneFrame {
let mut col = self.geom.x;
loop {
if col == self.geom.x {
title_line.append(&mut foreground_color(boundary_type::TOP_LEFT, self.color));
title_line.append(&mut foreground_color(
self.get_corner(boundary_type::TOP_LEFT),
self.color,
));
} else if col == self.geom.x + self.geom.cols - 1 {
title_line.append(&mut foreground_color(boundary_type::TOP_RIGHT, self.color));
title_line.append(&mut foreground_color(
self.get_corner(boundary_type::TOP_RIGHT),
self.color,
));
} else if col == left_side_start_position {
title_line.append(&mut left_side);
col += *left_side_len;
@ -437,9 +463,15 @@ impl PaneFrame {
let mut col = self.geom.x;
loop {
if col == self.geom.x {
title_line.append(&mut foreground_color(boundary_type::TOP_LEFT, self.color));
title_line.append(&mut foreground_color(
self.get_corner(boundary_type::TOP_LEFT),
self.color,
));
} else if col == self.geom.x + self.geom.cols - 1 {
title_line.append(&mut foreground_color(boundary_type::TOP_RIGHT, self.color));
title_line.append(&mut foreground_color(
self.get_corner(boundary_type::TOP_RIGHT),
self.color,
));
} else if col == middle_start_position {
title_line.append(&mut middle);
col += *middle_len;
@ -461,8 +493,10 @@ impl PaneFrame {
mut right_side: Vec<TerminalCharacter>,
right_side_len: &usize,
) -> Vec<TerminalCharacter> {
let mut left_boundary = foreground_color(boundary_type::TOP_LEFT, self.color);
let mut right_boundary = foreground_color(boundary_type::TOP_RIGHT, self.color);
let mut left_boundary =
foreground_color(self.get_corner(boundary_type::TOP_LEFT), self.color);
let mut right_boundary =
foreground_color(self.get_corner(boundary_type::TOP_RIGHT), self.color);
let total_title_length = self.geom.cols.saturating_sub(2); // 2 for the left and right corners
let mut middle = String::new();
for _ in (left_side_len + right_side_len)..total_title_length {
@ -481,8 +515,10 @@ impl PaneFrame {
mut left_side: Vec<TerminalCharacter>,
left_side_len: &usize,
) -> Vec<TerminalCharacter> {
let mut left_boundary = foreground_color(boundary_type::TOP_LEFT, self.color);
let mut right_boundary = foreground_color(boundary_type::TOP_RIGHT, self.color);
let mut left_boundary =
foreground_color(self.get_corner(boundary_type::TOP_LEFT), self.color);
let mut right_boundary =
foreground_color(self.get_corner(boundary_type::TOP_RIGHT), self.color);
let total_title_length = self.geom.cols.saturating_sub(2); // 2 for the left and right corners
let mut middle_padding = String::new();
for _ in *left_side_len..total_title_length {
@ -496,8 +532,10 @@ impl PaneFrame {
ret
}
fn empty_title_line(&self) -> Vec<TerminalCharacter> {
let mut left_boundary = foreground_color(boundary_type::TOP_LEFT, self.color);
let mut right_boundary = foreground_color(boundary_type::TOP_RIGHT, self.color);
let mut left_boundary =
foreground_color(self.get_corner(boundary_type::TOP_LEFT), self.color);
let mut right_boundary =
foreground_color(self.get_corner(boundary_type::TOP_RIGHT), self.color);
let total_title_length = self.geom.cols.saturating_sub(2); // 2 for the left and right corners
let mut middle_padding = String::new();
for _ in 0..total_title_length {
@ -575,10 +613,10 @@ impl PaneFrame {
for col in 0..self.geom.cols {
let boundary = if col == 0 {
// bottom left corner
boundary_type::BOTTOM_LEFT
self.get_corner(boundary_type::BOTTOM_LEFT)
} else if col == self.geom.cols - 1 {
// bottom right corner
boundary_type::BOTTOM_RIGHT
self.get_corner(boundary_type::BOTTOM_RIGHT)
} else {
boundary_type::HORIZONTAL
};

View File

@ -5,13 +5,14 @@ use crate::ui::boundaries::Boundaries;
use crate::ui::pane_boundaries_frame::FrameParams;
use crate::ClientId;
use std::collections::HashMap;
use zellij_tile::data::{
client_id_to_colors, single_client_color, InputMode, Palette, PaletteColor,
use zellij_tile::{
data::{client_id_to_colors, single_client_color, InputMode, PaletteColor},
prelude::Style,
};
pub struct PaneContentsAndUi<'a> {
pane: &'a mut Box<dyn Pane>,
output: &'a mut Output,
colors: Palette,
style: Style,
focused_clients: Vec<ClientId>,
multiple_users_exist_in_session: bool,
z_index: Option<usize>,
@ -21,7 +22,7 @@ impl<'a> PaneContentsAndUi<'a> {
pub fn new(
pane: &'a mut Box<dyn Pane>,
output: &'a mut Output,
colors: Palette,
style: Style,
active_panes: &HashMap<ClientId, PaneId>,
multiple_users_exist_in_session: bool,
z_index: Option<usize>,
@ -34,7 +35,7 @@ impl<'a> PaneContentsAndUi<'a> {
PaneContentsAndUi {
pane,
output,
colors,
style,
focused_clients,
multiple_users_exist_in_session,
z_index,
@ -95,7 +96,7 @@ impl<'a> PaneContentsAndUi<'a> {
.iter()
.find(|&&c_id| c_id != client_id)
.unwrap();
if let Some(colors) = client_id_to_colors(*fake_cursor_client_id, self.colors) {
if let Some(colors) = client_id_to_colors(*fake_cursor_client_id, self.style.colors) {
if let Some(vte_output) = self.pane.render_fake_cursor(colors.0, colors.1) {
self.output.add_post_vte_instruction_to_client(
client_id,
@ -146,7 +147,7 @@ impl<'a> PaneContentsAndUi<'a> {
focused_client,
is_main_client: pane_focused_for_client_id,
other_focused_clients: vec![],
colors: self.colors,
style: self.style,
color: frame_color,
other_cursors_exist_in_session: false,
}
@ -155,7 +156,7 @@ impl<'a> PaneContentsAndUi<'a> {
focused_client,
is_main_client: pane_focused_for_client_id,
other_focused_clients,
colors: self.colors,
style: self.style,
color: frame_color,
other_cursors_exist_in_session: self.multiple_users_exist_in_session,
}
@ -195,14 +196,14 @@ impl<'a> PaneContentsAndUi<'a> {
match mode {
InputMode::Normal | InputMode::Locked => {
if session_is_mirrored || !self.multiple_users_exist_in_session {
let colors = single_client_color(self.colors); // mirrored sessions only have one focused color
let colors = single_client_color(self.style.colors); // mirrored sessions only have one focused color
Some(colors.0)
} else {
let colors = client_id_to_colors(client_id, self.colors);
let colors = client_id_to_colors(client_id, self.style.colors);
colors.map(|colors| colors.0)
}
}
_ => Some(self.colors.orange),
_ => Some(self.style.colors.orange),
}
} else {
None

View File

@ -208,6 +208,12 @@ pub struct Palette {
pub brown: PaletteColor,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub struct Style {
pub colors: Palette,
pub rounded_corners: bool,
}
/// Represents the contents of the help message that is printed in the status bar,
/// which indicates the current [`InputMode`] and what the keybinds for that mode
/// are. Related to the default `status-bar` plugin.
@ -216,7 +222,7 @@ pub struct ModeInfo {
pub mode: InputMode,
// FIXME: This should probably return Keys and Actions, then sort out strings plugin-side
pub keybinds: Vec<(String, String)>, // <shortcut> => <shortcut description>
pub palette: Palette,
pub style: Style,
pub capabilities: PluginCapabilities,
pub session_name: Option<String>,
}

View File

@ -95,7 +95,7 @@ where
println!("\u{1b}[2J{}", fmt_report(report));
process::exit(1);
} else {
let _ = sender.send(T::error(format!("{}", fmt_report(report))));
let _ = sender.send(T::error(fmt_report(report)));
}
}

View File

@ -11,7 +11,7 @@ use std::convert::{TryFrom, TryInto};
use super::keybinds::{Keybinds, KeybindsFromYaml};
use super::options::Options;
use super::plugins::{PluginsConfig, PluginsConfigError, PluginsConfigFromYaml};
use super::theme::ThemesFromYaml;
use super::theme::{ThemesFromYaml, UiConfigFromYaml};
use crate::cli::{CliArgs, Command};
use crate::envs::EnvironmentVariablesFromYaml;
use crate::setup;
@ -31,6 +31,7 @@ pub struct ConfigFromYaml {
pub env: Option<EnvironmentVariablesFromYaml>,
#[serde(default)]
pub plugins: PluginsConfigFromYaml,
pub ui: Option<UiConfigFromYaml>,
}
/// Main configuration.
@ -40,6 +41,7 @@ pub struct Config {
pub options: Options,
pub themes: Option<ThemesFromYaml>,
pub plugins: PluginsConfig,
pub ui: Option<UiConfigFromYaml>,
pub env: EnvironmentVariablesFromYaml,
}
@ -72,6 +74,7 @@ impl Default for Config {
let themes = None;
let env = EnvironmentVariablesFromYaml::default();
let plugins = PluginsConfig::default();
let ui = None;
Config {
keybinds,
@ -79,6 +82,7 @@ impl Default for Config {
themes,
plugins,
env,
ui,
}
}
}
@ -168,6 +172,7 @@ impl Config {
themes: self.themes.clone(), // TODO
env: self.env.merge(other.env),
plugins: self.plugins.merge(other.plugins),
ui: self.ui, // TODO
}
}
}
@ -181,12 +186,14 @@ impl TryFrom<ConfigFromYaml> for Config {
let themes = config_from_yaml.themes;
let env = config_from_yaml.env.unwrap_or_default();
let plugins = PluginsConfig::get_plugins_with_default(config_from_yaml.plugins.try_into()?);
let ui = config_from_yaml.ui;
Ok(Self {
keybinds,
options,
plugins,
themes,
env,
ui,
})
}
}

View File

@ -12,15 +12,14 @@ pub mod theme;
use crate::envs;
use termion::input::TermRead;
use zellij_tile::data::{InputMode, Key, ModeInfo, Palette, PluginCapabilities};
use zellij_tile::{
data::{InputMode, Key, ModeInfo, PluginCapabilities},
prelude::Style,
};
/// Creates a [`ModeInfo`] struct indicating the current [`InputMode`] and its keybinds
/// (as pairs of [`String`]s).
pub fn get_mode_info(
mode: InputMode,
palette: Palette,
capabilities: PluginCapabilities,
) -> ModeInfo {
pub fn get_mode_info(mode: InputMode, style: Style, capabilities: PluginCapabilities) -> ModeInfo {
let keybinds = match mode {
InputMode::Normal | InputMode::Locked | InputMode::Prompt => Vec::new(),
InputMode::Resize => vec![
@ -77,7 +76,7 @@ pub fn get_mode_info(
ModeInfo {
mode,
keybinds,
palette,
style,
capabilities,
session_name,
}

View File

@ -8,6 +8,16 @@ use zellij_tile::data::{Palette, PaletteColor};
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct ThemesFromYaml(HashMap<String, Theme>);
#[derive(Debug, Default, Clone, Copy, PartialEq, Deserialize, Serialize)]
pub struct UiConfigFromYaml {
pub pane_frames: FrameConfigFromYaml,
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Deserialize, Serialize)]
pub struct FrameConfigFromYaml {
pub rounded_corners: bool,
}
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
struct Theme {
#[serde(flatten)]

View File

@ -16,7 +16,7 @@ use std::{
os::unix::io::{AsRawFd, FromRawFd},
};
use zellij_tile::data::{InputMode, Palette};
use zellij_tile::{data::InputMode, prelude::Style};
type SessionId = u64;
@ -40,7 +40,7 @@ pub enum ClientType {
#[derive(Default, Serialize, Deserialize, Debug, Clone, Copy)]
pub struct ClientAttributes {
pub size: Size,
pub palette: Palette,
pub style: Style,
}
// Types of messages sent from the client to the server

View File

@ -398,7 +398,7 @@ impl Setup {
Shell::Bash => {}
Shell::Elvish => {}
Shell::Fish => {
let _ = out.write_all(&FISH_EXTRA_COMPLETION);
let _ = out.write_all(FISH_EXTRA_COMPLETION);
}
Shell::PowerShell => {}
Shell::Zsh => {}