aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/kdl/mod.rs
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-08 19:49:23 +0200
committeruser <user@clank>2026-08-08 19:49:23 +0200
commit30782cbb2fab4e01cadb9815927a404591472064 (patch)
tree29bdd07fc0c56c7ec38b1238066f1ae0ee6e53c5 /zellij-utils/src/kdl/mod.rs
parentsl0p: configurable pane title alignment (diff)
downloadsl0ppij-30782cbb2fab4e01cadb9815927a404591472064.tar.gz
sl0ppij-30782cbb2fab4e01cadb9815927a404591472064.tar.xz
sl0ppij-30782cbb2fab4e01cadb9815927a404591472064.zip
sl0p: configurable pane gap (outer) and padding (inner)
Adds `ui { pane_frames { gap N; padding N } }`, both defaulting to 0 so stock configs are unaffected. gap - cells each pane gives up on every side, leaving real empty terminal between neighbouring panes (WM-style outer gaps). Two adjacent panes therefore show 2*gap between them. padding - cells between a pane's frame and its content; breathing room inside the pane without moving the frame. Design: the pane KEEPS its allocated PaneGeom. Only two things move: 1. the drawn frame, via Viewport::inset(gap), reusing the existing frame_geom_override mechanism already used for stacked panes; 2. the content, via Offset::expanded_by(gap + padding) inside set_content_offset. Because the allocation is untouched, the kasuari resize solver and mouse hit-testing need no changes at all, and a click landing in a gap still resolves to the owning pane. Content position, size and cursor are all derived from content_offset, so widening it in one place keeps every consumer consistent. Viewport::inset refuses to shrink a pane below a frame's minimum viable extent (two borders + one content cell) rather than emitting a degenerate or zero-sized frame. Negative KDL values clamp to 0 instead of wrapping. Tests cover: inset identity/shrink/recentre, the containment invariant (an inset frame never escapes its allocation), small-pane refusal, and the key safety property that content inset by gap+border+padding lands strictly inside the frame drawn at inset(gap).
Diffstat (limited to 'zellij-utils/src/kdl/mod.rs')
-rw-r--r--zellij-utils/src/kdl/mod.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/zellij-utils/src/kdl/mod.rs b/zellij-utils/src/kdl/mod.rs
index bc188aed..6589d30f 100644
--- a/zellij-utils/src/kdl/mod.rs
+++ b/zellij-utils/src/kdl/mod.rs
@@ -2482,6 +2482,17 @@ macro_rules! kdl_children_property_first_arg_as_bool {
}
#[macro_export]
+macro_rules! kdl_children_property_first_arg_as_i64 {
+ ( $kdl_node:expr, $property_name:expr ) => {
+ $kdl_node
+ .children()
+ .and_then(|c| c.get($property_name))
+ .and_then(|p| p.entries().iter().next())
+ .and_then(|p| p.value().as_i64())
+ };
+}
+
+#[macro_export]
macro_rules! kdl_property_first_arg_as_i64 {
( $kdl_node:expr, $property_name:expr ) => {
$kdl_node
@@ -5535,10 +5546,20 @@ impl UiConfig {
},
None => crate::data::PaneTitleAlignment::default(),
};
+ // negative values are meaningless here and would wrap on `as usize`,
+ // so clamp at 0 rather than silently producing a gigantic inset
+ let gap = kdl_children_property_first_arg_as_i64!(pane_frames, "gap")
+ .unwrap_or(0)
+ .max(0) as usize;
+ let padding = kdl_children_property_first_arg_as_i64!(pane_frames, "padding")
+ .unwrap_or(0)
+ .max(0) as usize;
let frame_config = FrameConfig {
rounded_corners,
hide_session_name,
title_alignment,
+ gap,
+ padding,
};
ui_config.pane_frames = frame_config;
}
@@ -5575,6 +5596,18 @@ impl UiConfig {
));
frame_config_children.nodes_mut().push(title_alignment);
}
+ if self.pane_frames.gap > 0 {
+ has_ui_config = true;
+ let mut gap = KdlNode::new("gap");
+ gap.push(KdlValue::Base10(self.pane_frames.gap as i64));
+ frame_config_children.nodes_mut().push(gap);
+ }
+ if self.pane_frames.padding > 0 {
+ has_ui_config = true;
+ let mut padding = KdlNode::new("padding");
+ padding.push(KdlValue::Base10(self.pane_frames.padding as i64));
+ frame_config_children.nodes_mut().push(padding);
+ }
if has_ui_config {
frame_config.set_children(frame_config_children);
ui_config_children.nodes_mut().push(frame_config);