diff options
| author | user <user@clank> | 2026-08-08 20:58:17 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-08 20:58:17 +0200 |
| commit | c21f7324abdb6d83300a62b95e2af27bfcc75a1e (patch) | |
| tree | 4bf95a6a71c5c0b6e36c96d2a2d58d654b13052b /zellij-server | |
| parent | sl0p: add fastdev build profile + SPEED.md (60x faster iteration) (diff) | |
| download | sl0ppij-c21f7324abdb6d83300a62b95e2af27bfcc75a1e.tar.gz sl0ppij-c21f7324abdb6d83300a62b95e2af27bfcc75a1e.tar.xz sl0ppij-c21f7324abdb6d83300a62b95e2af27bfcc75a1e.zip | |
sl0p: uniform pane gap + aspect-corrected horizontal gap
Two changes to how the gap is defined.
1. UNIFORM GAP. Previously every pane inset every side by `gap`, so two
neighbours each gave up a cell and the space between them was 2*gap while
the screen edge got only gap. Now a pane insets RIGHT and BOTTOM always,
and LEFT/TOP only where that edge is the viewport boundary. Two neighbours
contribute exactly one gap between them, and the outer screen edges get
the same gap. `gap 1` now means 1 everywhere.
The per-side offset is computed in tiled_panes, which is the layer that
knows the viewport, and pushed to panes via Pane::set_gap_offset before the
content-offset sweep. Floating panes keep a zero gap: they are positioned
explicitly by the user, so an inter-pane gap does not apply to them (they
still get padding).
2. ASPECT CORRECTION. Terminal cells are roughly twice as tall as they are
wide, so an equal number of rows and columns does not look like an equal
distance. `gap` and `padding` are now expressed in ROWS, and columns are
multiplied by `gap_aspect` (default 2, minimum 1). Style carries the
resolved pane_gap_x/y and pane_padding_x/y.
FrameConfig::Default is now hand-written rather than derived: gap_aspect must
default to 2 to match the KDL parser, otherwise a parsed config disagrees with
a default-constructed one and it surfaces as config round-trip diffs (this
broke can_define_ui_configuration_in_configfile and both
bare_config_from_default_assets_to_string tests).
Tests assert the actual invariants: stacked and side-by-side neighbours get
exactly one gap between them, screen edges get the same gap as between panes,
and inset_by refuses to collapse a pane too small to survive it.
Baselines held: zellij-server 1421/30, zellij-utils 433/5.
Diffstat (limited to 'zellij-server')
| -rw-r--r-- | zellij-server/src/lib.rs | 18 | ||||
| -rw-r--r-- | zellij-server/src/panes/floating_panes/mod.rs | 14 | ||||
| -rw-r--r-- | zellij-server/src/panes/plugin_pane.rs | 37 | ||||
| -rw-r--r-- | zellij-server/src/panes/terminal_pane.rs | 37 | ||||
| -rw-r--r-- | zellij-server/src/panes/tiled_panes/mod.rs | 47 | ||||
| -rw-r--r-- | zellij-server/src/screen.rs | 26 | ||||
| -rw-r--r-- | zellij-server/src/tab/mod.rs | 28 |
7 files changed, 157 insertions, 50 deletions
diff --git a/zellij-server/src/lib.rs b/zellij-server/src/lib.rs index 21238eab..a80bda2b 100644 --- a/zellij-server/src/lib.rs +++ b/zellij-server/src/lib.rs @@ -460,8 +460,10 @@ impl SessionMetaData { rounded_corners: new_config.ui.pane_frames.rounded_corners, hide_session_name: new_config.ui.pane_frames.hide_session_name, pane_title_alignment: new_config.ui.pane_frames.title_alignment, - pane_gap: new_config.ui.pane_frames.gap, - pane_padding: new_config.ui.pane_frames.padding, + pane_gap_x: new_config.ui.pane_frames.resolved_gap().0, + pane_gap_y: new_config.ui.pane_frames.resolved_gap().1, + pane_padding_x: new_config.ui.pane_frames.resolved_padding().0, + pane_padding_y: new_config.ui.pane_frames.resolved_padding().1, stacked_resize: new_config.options.stacked_resize.unwrap_or(true), stacked_pane_list: new_config.options.stacked_pane_list.unwrap_or(true), default_editor: new_config.options.scrollback_editor.clone(), @@ -1004,8 +1006,10 @@ pub fn start_server_impl( rounded_corners: config.ui.pane_frames.rounded_corners, hide_session_name: config.ui.pane_frames.hide_session_name, pane_title_alignment: config.ui.pane_frames.title_alignment, - pane_gap: config.ui.pane_frames.gap, - pane_padding: config.ui.pane_frames.padding, + pane_gap_x: config.ui.pane_frames.resolved_gap().0, + pane_gap_y: config.ui.pane_frames.resolved_gap().1, + pane_padding_x: config.ui.pane_frames.resolved_padding().0, + pane_padding_y: config.ui.pane_frames.resolved_padding().1, }, }; @@ -1190,8 +1194,10 @@ pub fn start_server_impl( rounded_corners: config.ui.pane_frames.rounded_corners, hide_session_name: config.ui.pane_frames.hide_session_name, pane_title_alignment: config.ui.pane_frames.title_alignment, - pane_gap: config.ui.pane_frames.gap, - pane_padding: config.ui.pane_frames.padding, + pane_gap_x: config.ui.pane_frames.resolved_gap().0, + pane_gap_y: config.ui.pane_frames.resolved_gap().1, + pane_padding_x: config.ui.pane_frames.resolved_padding().0, + pane_padding_y: config.ui.pane_frames.resolved_padding().1, }, }; diff --git a/zellij-server/src/panes/floating_panes/mod.rs b/zellij-server/src/panes/floating_panes/mod.rs index 157a912f..8252612c 100644 --- a/zellij-server/src/panes/floating_panes/mod.rs +++ b/zellij-server/src/panes/floating_panes/mod.rs @@ -1723,14 +1723,18 @@ impl FloatingPanes { pub fn update_pane_frame_layout( &mut self, title_alignment: zellij_utils::data::PaneTitleAlignment, - gap: usize, - padding: usize, + gap_x: usize, + gap_y: usize, + padding_x: usize, + padding_y: usize, ) { self.style.pane_title_alignment = title_alignment; - self.style.pane_gap = gap; - self.style.pane_padding = padding; + self.style.pane_gap_x = gap_x; + self.style.pane_gap_y = gap_y; + self.style.pane_padding_x = padding_x; + self.style.pane_padding_y = padding_y; for pane in self.panes.values_mut() { - pane.update_frame_layout(title_alignment, gap, padding); + pane.update_frame_layout(title_alignment, gap_x, gap_y, padding_x, padding_y); } // Unlike the tiled panes, `set_pane_frame_style` only re-runs the // content-offset sweep for a fullscreen floating pane, so gap/padding diff --git a/zellij-server/src/panes/plugin_pane.rs b/zellij-server/src/panes/plugin_pane.rs index c01db2ec..4f4e138d 100644 --- a/zellij-server/src/panes/plugin_pane.rs +++ b/zellij-server/src/panes/plugin_pane.rs @@ -82,6 +82,10 @@ pub(crate) struct PluginPane { pub geom: PaneGeom, pub geom_override: Option<PaneGeom>, pub content_offset: Offset, + /// Per-side outer gap. Set by the pane container, which knows the viewport: + /// a side only gets a gap where one belongs, so two neighbours produce ONE + /// gap between them rather than two. + gap_offset: Offset, pub send_plugin_instructions: SenderWithContext<PluginInstruction>, pub active_at: Instant, pub pane_title: String, @@ -144,6 +148,7 @@ impl PluginPane { active_at: Instant::now(), frame: HashMap::new(), content_offset: Offset::default(), + gap_offset: Offset::default(), pane_title: title, borderless: false, pane_name: pane_name.clone(), @@ -475,7 +480,7 @@ impl Pane for PluginPane { // see the matching comment in terminal_pane.rs: the frame is drawn // inset from the pane's allocated geometry to produce the outer gap let outer_frame_viewport = Viewport::from(frame_geom); - let frame_viewport = outer_frame_viewport.inset(self.style.pane_gap); + let frame_viewport = outer_frame_viewport.inset_by(self.gap_offset); // Every cell of the pane's allocation must be written by exactly one // pane each render, or stale glyphs survive as ghosting. The gap and // padding insets carve out TWO regions that neither the frame nor the @@ -754,16 +759,28 @@ impl Pane for PluginPane { fn set_frame(&mut self, _frame: bool) { self.frame.clear(); } + fn set_gap_offset(&mut self, gap_offset: Offset) { + self.gap_offset = gap_offset; + } fn set_content_offset(&mut self, offset: Offset) { // see terminal_pane.rs: borderless panes are chrome (this is the one // that matters in practice - zjstatus/status-bar/tab-bar are plugins) + // borderless panes are UI chrome (status bar, tab bar): they are sized + // exactly to their content, so insetting them makes them vanish + // borderless panes are UI chrome (status bar, tab bar): they are sized + // exactly to their content, so insetting them at all makes them vanish let inset = if self.borderless { - 0 + Offset::default() } else { - self.style.pane_gap + self.style.pane_padding + Offset { + top: self.gap_offset.top.saturating_add(self.style.pane_padding_y), + bottom: self.gap_offset.bottom.saturating_add(self.style.pane_padding_y), + left: self.gap_offset.left.saturating_add(self.style.pane_padding_x), + right: self.gap_offset.right.saturating_add(self.style.pane_padding_x), + } }; self.content_offset = - offset.expanded_by_within(inset, self.cols(), self.rows()); + offset.expanded_by_offset_within(inset, self.cols(), self.rows()); self.resize_grids(); } @@ -896,12 +913,16 @@ impl Pane for PluginPane { fn update_frame_layout( &mut self, title_alignment: zellij_utils::data::PaneTitleAlignment, - gap: usize, - padding: usize, + gap_x: usize, + gap_y: usize, + padding_x: usize, + padding_y: usize, ) { self.style.pane_title_alignment = title_alignment; - self.style.pane_gap = gap; - self.style.pane_padding = padding; + self.style.pane_gap_x = gap_x; + self.style.pane_gap_y = gap_y; + self.style.pane_padding_x = padding_x; + self.style.pane_padding_y = padding_y; self.frame.clear(); } fn set_should_be_suppressed(&mut self, should_be_suppressed: bool) { diff --git a/zellij-server/src/panes/terminal_pane.rs b/zellij-server/src/panes/terminal_pane.rs index 0ebdbe11..8c44d7b1 100644 --- a/zellij-server/src/panes/terminal_pane.rs +++ b/zellij-server/src/panes/terminal_pane.rs @@ -140,6 +140,10 @@ pub struct TerminalPane { vte_parser: vte::Parser, selection_scrolled_at: time::Instant, content_offset: Offset, + /// Per-side outer gap. Set by the pane container, which knows the + /// viewport: a side only gets a gap where one belongs, so two + /// neighbours produce ONE gap between them rather than two. + gap_offset: Offset, pane_title: String, pane_name: String, prev_pane_name: String, @@ -580,7 +584,7 @@ impl Pane for TerminalPane { // cells between neighbouring panes. Content is inset to match in // set_content_offset(). let outer_frame_viewport = Viewport::from(frame_geom); - let frame_viewport = outer_frame_viewport.inset(self.style.pane_gap); + let frame_viewport = outer_frame_viewport.inset_by(self.gap_offset); // Every cell of the pane's allocation must be written by exactly one // pane each render, or stale glyphs survive as ghosting. The gap and // padding insets carve out TWO regions that neither the frame nor the @@ -973,16 +977,28 @@ impl Pane for TerminalPane { self.frame.clear(); } + fn set_gap_offset(&mut self, gap_offset: Offset) { + self.gap_offset = gap_offset; + } fn set_content_offset(&mut self, offset: Offset) { // borderless panes are UI chrome (status bar, tab bar): they are sized // exactly to their content, so insetting them makes them vanish + // borderless panes are UI chrome (status bar, tab bar): they are sized + // exactly to their content, so insetting them makes them vanish + // borderless panes are UI chrome (status bar, tab bar): they are sized + // exactly to their content, so insetting them at all makes them vanish let inset = if self.borderless { - 0 + Offset::default() } else { - self.style.pane_gap + self.style.pane_padding + Offset { + top: self.gap_offset.top.saturating_add(self.style.pane_padding_y), + bottom: self.gap_offset.bottom.saturating_add(self.style.pane_padding_y), + left: self.gap_offset.left.saturating_add(self.style.pane_padding_x), + right: self.gap_offset.right.saturating_add(self.style.pane_padding_x), + } }; self.content_offset = - offset.expanded_by_within(inset, self.get_columns(), self.get_rows()); + offset.expanded_by_offset_within(inset, self.get_columns(), self.get_rows()); self.reflow_lines(); } @@ -1251,12 +1267,16 @@ impl Pane for TerminalPane { fn update_frame_layout( &mut self, title_alignment: zellij_utils::data::PaneTitleAlignment, - gap: usize, - padding: usize, + gap_x: usize, + gap_y: usize, + padding_x: usize, + padding_y: usize, ) { self.style.pane_title_alignment = title_alignment; - self.style.pane_gap = gap; - self.style.pane_padding = padding; + self.style.pane_gap_x = gap_x; + self.style.pane_gap_y = gap_y; + self.style.pane_padding_x = padding_x; + self.style.pane_padding_y = padding_y; self.frame.clear(); } fn drain_fake_cursors(&mut self) -> Option<HashSet<(usize, usize)>> { @@ -1432,6 +1452,7 @@ impl TerminalPane { TerminalPane { frame: HashMap::new(), content_offset: Offset::default(), + gap_offset: Offset::default(), pid, grid, selectable: true, diff --git a/zellij-server/src/panes/tiled_panes/mod.rs b/zellij-server/src/panes/tiled_panes/mod.rs index 1dbc7bb8..835c8e74 100644 --- a/zellij-server/src/panes/tiled_panes/mod.rs +++ b/zellij-server/src/panes/tiled_panes/mod.rs @@ -627,6 +627,39 @@ impl TiledPanes { pane.set_frame(draws_full_frames); } + // Per-side outer gap. + // + // A pane always gives up space on its RIGHT and BOTTOM, and gives + // up space on its LEFT/TOP only when that edge is the viewport + // boundary. Two neighbours therefore contribute exactly ONE gap + // between them (the left one's right side), while the outer edges + // of the screen still get a margin. Insetting every side on every + // pane would double the gap between neighbours. + // + // x and y are scaled differently on purpose: terminal cells are + // about twice as tall as they are wide, so an equal number of rows + // and columns does not look like an equal distance. + let gap_offset = if pane.borderless() { + Offset::default() + } else { + let geom = pane.current_geom(); + Offset { + left: if geom.x <= viewport.x { + self.style.pane_gap_x + } else { + 0 + }, + top: if geom.y <= viewport.y { + self.style.pane_gap_y + } else { + 0 + }, + right: self.style.pane_gap_x, + bottom: self.style.pane_gap_y, + } + }; + pane.set_gap_offset(gap_offset); + let pane_viewport = &viewport; let reserved_rows = reserved_top_rows.get(&pane.pid()).copied().unwrap_or(0); @@ -3121,14 +3154,18 @@ impl TiledPanes { pub fn update_pane_frame_layout( &mut self, title_alignment: zellij_utils::data::PaneTitleAlignment, - gap: usize, - padding: usize, + gap_x: usize, + gap_y: usize, + padding_x: usize, + padding_y: usize, ) { self.style.pane_title_alignment = title_alignment; - self.style.pane_gap = gap; - self.style.pane_padding = padding; + self.style.pane_gap_x = gap_x; + self.style.pane_gap_y = gap_y; + self.style.pane_padding_x = padding_x; + self.style.pane_padding_y = padding_y; for pane in self.panes.values_mut() { - pane.update_frame_layout(title_alignment, gap, padding); + pane.update_frame_layout(title_alignment, gap_x, gap_y, padding_x, padding_y); } } pub fn stack_panes( diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs index b17cc61f..c3c06ca9 100644 --- a/zellij-server/src/screen.rs +++ b/zellij-server/src/screen.rs @@ -777,8 +777,10 @@ pub enum ScreenInstruction { rounded_corners: bool, hide_session_name: bool, pane_title_alignment: PaneTitleAlignment, - pane_gap: usize, - pane_padding: usize, + pane_gap_x: usize, + pane_gap_y: usize, + pane_padding_x: usize, + pane_padding_y: usize, stacked_resize: bool, stacked_pane_list: bool, default_editor: Option<PathBuf>, @@ -6266,8 +6268,10 @@ impl Screen { rounded_corners: bool, hide_session_name: bool, pane_title_alignment: PaneTitleAlignment, - pane_gap: usize, - pane_padding: usize, + pane_gap_x: usize, + pane_gap_y: usize, + pane_padding_x: usize, + pane_padding_y: usize, stacked_resize: bool, stacked_pane_list: bool, default_editor: Option<PathBuf>, @@ -6327,7 +6331,7 @@ impl Screen { tab.update_copy_options(&self.copy_options); // must precede set_pane_frames: gap/padding are baked into // content_offset by the sweep that set_pane_frames triggers - tab.update_frame_layout(pane_title_alignment, pane_gap, pane_padding); + tab.update_frame_layout(pane_title_alignment, pane_gap_x, pane_gap_y, pane_padding_x, pane_padding_y); tab.set_pane_frames(pane_frame_style); tab.update_arrow_fonts(should_support_arrow_fonts); tab.update_advanced_mouse_actions(advanced_mouse_actions); @@ -10844,8 +10848,10 @@ pub(crate) fn screen_thread_main( rounded_corners, hide_session_name, pane_title_alignment, - pane_gap, - pane_padding, + pane_gap_x, + pane_gap_y, + pane_padding_x, + pane_padding_y, stacked_resize, stacked_pane_list, default_editor, @@ -10874,8 +10880,10 @@ pub(crate) fn screen_thread_main( rounded_corners, hide_session_name, pane_title_alignment, - pane_gap, - pane_padding, + pane_gap_x, + pane_gap_y, + pane_padding_x, + pane_padding_y, stacked_resize, stacked_pane_list, default_editor, diff --git a/zellij-server/src/tab/mod.rs b/zellij-server/src/tab/mod.rs index beec913b..c9047d68 100644 --- a/zellij-server/src/tab/mod.rs +++ b/zellij-server/src/tab/mod.rs @@ -737,6 +737,10 @@ pub trait Pane { fn update_arrow_fonts(&mut self, _should_support_arrow_fonts: bool) {} fn update_kitty_host_support(&mut self, _supported: KittyHostSupport) {} fn update_rounded_corners(&mut self, _rounded_corners: bool) {} + /// Per-side outer gap, decided by the container (which knows the viewport). + /// MUST be followed by set_content_offset: the gap is baked into + /// content_offset, so it only takes effect on the next offset sweep. + fn set_gap_offset(&mut self, _gap_offset: zellij_utils::pane_size::Offset) {} /// Live-update the sl0p frame layout options (title alignment, outer gap, /// inner padding). Callers MUST follow this with the usual /// `set_pane_frames` sweep: gap/padding are baked into `content_offset` @@ -745,8 +749,10 @@ pub trait Pane { fn update_frame_layout( &mut self, _title_alignment: zellij_utils::data::PaneTitleAlignment, - _gap: usize, - _padding: usize, + _gap_x: usize, + _gap_y: usize, + _padding_x: usize, + _padding_y: usize, ) { } fn set_should_be_suppressed(&mut self, _should_be_suppressed: bool) {} @@ -7412,18 +7418,22 @@ impl Tab { pub fn update_frame_layout( &mut self, title_alignment: zellij_utils::data::PaneTitleAlignment, - gap: usize, - padding: usize, + gap_x: usize, + gap_y: usize, + padding_x: usize, + padding_y: usize, ) { self.style.pane_title_alignment = title_alignment; - self.style.pane_gap = gap; - self.style.pane_padding = padding; + self.style.pane_gap_x = gap_x; + self.style.pane_gap_y = gap_y; + self.style.pane_padding_x = padding_x; + self.style.pane_padding_y = padding_y; self.floating_panes - .update_pane_frame_layout(title_alignment, gap, padding); + .update_pane_frame_layout(title_alignment, gap_x, gap_y, padding_x, padding_y); self.tiled_panes - .update_pane_frame_layout(title_alignment, gap, padding); + .update_pane_frame_layout(title_alignment, gap_x, gap_y, padding_x, padding_y); for (_, pane) in self.suppressed_panes.values_mut() { - pane.update_frame_layout(title_alignment, gap, padding); + pane.update_frame_layout(title_alignment, gap_x, gap_y, padding_x, padding_y); } } pub fn update_arrow_fonts(&mut self, should_support_arrow_fonts: bool) { |
