diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 23:51:03 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 01:00:59 -0300 |
| commit | 7e4e9f23978ba6c1313415c12064c9267ebbe7f2 (patch) | |
| tree | 1f879e16c00a49aa948142a01610c091fa241390 /src/layout.zig | |
| parent | 5d39c627bc3136dca1fc6ac6593bd4e4e34d9185 (diff) | |
| download | pardes-7e4e9f23978ba6c1313415c12064c9267ebbe7f2.tar.gz pardes-7e4e9f23978ba6c1313415c12064c9267ebbe7f2.zip | |
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/layout.zig')
| -rw-r--r-- | src/layout.zig | 31 |
1 files changed, 21 insertions, 10 deletions
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 |
