summaryrefslogtreecommitdiffstats
path: root/zellij-server
diff options
context:
space:
mode:
authorBrooks Rady <b.j.rady@gmail.com>2022-03-22 14:58:16 +0000
committerGitHub <noreply@github.com>2022-03-22 14:58:16 +0000
commit9bfafde12348623e2a5d1513ba0928e15d441efd (patch)
treeeced3310a2b8102189ae55e984104a94bed8a510 /zellij-server
parent2d55a3e274f1fc13d7adf8a1574188498efae82c (diff)
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 9271a4b5452f2e59e0ebd55136343f0fbfabaa13. * fix(style): remove redundant code * fix(style): clippy lints that somehow got missed * feat(config): add ui config section
Diffstat (limited to 'zellij-server')
-rw-r--r--zellij-server/src/lib.rs10
-rw-r--r--zellij-server/src/panes/floating_panes/mod.rs15
-rw-r--r--zellij-server/src/panes/terminal_pane.rs13
-rw-r--r--zellij-server/src/panes/tiled_panes/mod.rs100
-rw-r--r--zellij-server/src/panes/unit/terminal_pane_tests.rs6
-rw-r--r--zellij-server/src/route.rs6
-rw-r--r--zellij-server/src/screen.rs15
-rw-r--r--zellij-server/src/tab/mod.rs29
-rw-r--r--zellij-server/src/tab/unit/tab_integration_tests.rs5
-rw-r--r--zellij-server/src/tab/unit/tab_tests.rs5
-rw-r--r--zellij-server/src/ui/boundaries.rs4
-rw-r--r--zellij-server/src/ui/pane_boundaries_frame.rs76
-rw-r--r--zellij-server/src/ui/pane_contents_and_ui.rs23
13 files changed, 167 insertions, 140 deletions
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 {
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,
diff --git a/zellij-server/src/panes/tiled_panes/mod.rs b/zellij-server/src/panes/tiled_panes/mod.rs
index dc755af4a..32f4a513c 100644
--- a/zellij-server/src/panes/tiled_panes/mod.rs
+++ b/zellij-server/src/panes/tiled_panes/mod.rs
@@ -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 {
diff --git a/zellij-server/src/panes/unit/terminal_pane_tests.rs b/zellij-server/src/panes/unit/terminal_pane_tests.rs
index b5f986aae..adcdbd08d 100644
--- a/zellij-server/src/panes/unit/terminal_pane_tests.rs
+++ b/zellij-server/src/panes/unit/terminal_pane_tests.rs
@@ -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())),
diff --git a/zellij-server/src/route.rs b/zellij-server/src/route.rs
index 033a571b3..e5489818a 100644
--- a/zellij-server/src/route.rs
+++ b/zellij-server/src/route.rs
@@ -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();
diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs
index 8ba6cccfe..42558d230 100644
--- a/zellij-server/src/screen.rs
+++ b/zellij-server/src/screen.rs
@@ -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,
+ sty