From 7e4e9f23978ba6c1313415c12064c9267ebbe7f2 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 23:51:03 -0300 Subject: layout.keepColumn: whether a new column may stay, its narrower neighbours' panes given back the rows their wrapped tags took or the column dropped, is one rule where Newcol and the finder each wrote the trial loop out; squeezed, which only that loop asked, is its body Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/layout.zig | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'src/layout.zig') diff --git a/src/layout.zig b/src/layout.zig index a3fb9b8e..91947997 100644 --- a/src/layout.zig +++ b/src/layout.zig @@ -725,17 +725,28 @@ pub fn restoreMinimaFrom(p: *Pardes, before: *const [MAX_PANES]Rect, before_min: compute(p); } -/// Whether a pane of column `c` is under its minimum now that had its -/// minimum then (`before`, `before_min`): one a step squeezed, not one -/// dragged short. -pub fn squeezed(p: *Pardes, c: usize, before: *const [MAX_PANES]Rect, before_min: *const [MAX_PANES]u16) bool { - compute(p); - if (p.col_n[c] < 2) return false; - for (p.col_panes[c][0..p.col_n[c]]) |k| { - const pane = p.panes[k] orelse continue; - if (!pane.collapsed and p.rects[k].h < minRows(p, k) and before[k].h >= before_min[k]) return true; +/// Whether new column `c` (Newcol's, the finder's) may stay. A narrower +/// column wraps long tags onto more rows, which can leave a pane under its +/// tag and two rows: each pane a column squeezed so (one that had its +/// minimum `before`, `before_min`, not one dragged short) takes rows back +/// from the panes with rows to spare, its column shared out again only +/// where that is not enough. False, `c` dropped unannounced, where nothing +/// holds every minimum, as a size too small is refused. +pub fn keepColumn(p: *Pardes, c: usize, before: *const [MAX_PANES]Rect, before_min: *const [MAX_PANES]u16) bool { + restoreMinimaFrom(p, before, before_min); + for (0..p.ncol) |k| { + compute(p); + if (p.col_n[k] < 2) continue; + const squeezed = for (p.col_panes[k][0..p.col_n[k]]) |id| { + const pane = p.panes[id] orelse continue; + if (!pane.collapsed and p.rects[id].h < minRows(p, id) and before[id].h >= before_min[id]) break true; + } else false; + if (squeezed and !shareColumn(p, k)) { + dropColumnUnannounced(p, c); + return false; + } } - return false; + return true; } /// Column `c`'s rows for `id`, last in it, at its minimum: a row at a -- cgit v1.3