diff options
Diffstat (limited to 'core/layout.zig')
| -rw-r--r-- | core/layout.zig | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/core/layout.zig b/core/layout.zig index 9c15833d..4b5b7d2c 100644 --- a/core/layout.zig +++ b/core/layout.zig @@ -586,7 +586,9 @@ pub fn acmePlace(p: *Pardes, c: usize, origin: ?usize, id: usize) void { pub const min_body_rows = 2; /// The rows pane `id`'s tag takes at its width, wrapped as `sync` wraps -/// it: what a placement must leave it above its body rows. +/// it: what a placement must leave it above its body rows. A walked file's +/// path is cut to the rows its pane has (tagline.folded): its tag never +/// wants a row more. pub fn wantedTagRows(p: *Pardes, id: usize) u16 { const pane = p.panes[id] orelse return BOX_H; if (pane.collapsed or !pane.tag_expanded) return BOX_H; @@ -744,6 +746,33 @@ pub fn restoreMinimaFrom(p: *Pardes, before: *const [MAX_PANES]Rect, before_min: compute(p); } +/// One row more for pane `id` from whichever pane of its column has the +/// most above its own minimum, as restoreMinimaFrom gives them; false, +/// changing nothing, when none has one (or the column holds a folded +/// pane). +pub fn giveRow(p: *Pardes, id: usize) bool { + const v = p.view(); + compute(p); + const c = (findPane(p, id) orelse return false).col; + const col = v.cols[c].panes[0..v.cols[c].n]; + var giver: ?usize = null; + var spare: u16 = 0; + for (col) |k| { + const pane = p.panes[k] orelse return false; + if (pane.collapsed) return false; + if (k != id and v.rects[k].h -| minRows(p, k) > spare) { + spare = v.rects[k].h - minRows(p, k); + giver = k; + } + } + const g = giver orelse return false; + for (col) |k| p.panes[k].?.vweight = @floatFromInt(@max(1, v.rects[k].h)); + p.panes[g].?.vweight -= 1; + p.panes[id].?.vweight += 1; + compute(p); + return true; +} + /// Column `c`'s rows for `id`, last in it, at its minimum: a row at a /// time from whichever pane has the most above its own minimum, so a pane /// dragged short keeps its rows and the others give only what they must. |
