summaryrefslogtreecommitdiff
path: root/src/layout.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/layout.zig')
-rw-r--r--src/layout.zig17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/layout.zig b/src/layout.zig
index 6de7a912..25c95d30 100644
--- a/src/layout.zig
+++ b/src/layout.zig
@@ -162,8 +162,15 @@ pub fn targetColumn(p: *Pardes, cur_x: u16) usize {
}
pub fn splitRowForExtent(y: u16, h: u16, cur_y: u16) ?u16 {
+ return splitRowFor(y, h, cur_y, null);
+}
+
+/// As `splitRowForExtent`, each pane keeping at least `least` rows when
+/// given: a pane dragged by its grip within its own column is how a
+/// terminal resizes, and acme lets either window keep only its tag.
+fn splitRowFor(y: u16, h: u16, cur_y: u16, least: ?u16) ?u16 {
if (h < 2) return null;
- const min_each: u16 = if (h >= config.MINH * 2) config.MINH else 1;
+ const min_each: u16 = least orelse if (h >= config.MINH * 2) config.MINH else 1;
const lo = y +| min_each;
const hi = y + h - min_each;
if (lo > hi) return y + h / 2;
@@ -176,7 +183,11 @@ pub fn movePlacement(p: *Pardes, id: usize, cur_x: u16, cur_y: u16) ?MovePlaceme
if (tc == src.col and p.col_n[src.col] == 1) return null;
if (tc == src.col) {
const sr = p.rects[id];
- if (cur_y >= sr.y and cur_y < sr.y + sr.h) return null;
+ // Dropped on itself it stays, unless dragged down from its top with
+ // a pane above: its top moves down there, the pane above taking the
+ // rows, as acme's window dragged by its button does. With no rule
+ // between panes, that is how a terminal resizes them.
+ if (cur_y >= sr.y and cur_y < sr.y + sr.h and (src.idx == 0 or cur_y <= sr.y)) return null;
}
var heights: [MAX_PANES]u16 = @splat(0);
for (0..p.ncol) |c| {
@@ -196,7 +207,7 @@ pub fn movePlacement(p: *Pardes, id: usize, cur_x: u16, cur_y: u16) ?MovePlaceme
const pid = p.col_panes[tc][k];
if (pid == id) continue;
const h = heights[pid];
- const row = splitRowForExtent(y, h, cur_y) orelse {
+ const row = splitRowFor(y, h, cur_y, if (tc == src.col) BOX_H else null) orelse {
y +|= h;
continue;
};