diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-09 02:14:21 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-09 02:21:58 -0300 |
| commit | bfb74e76ef7dfe305a26010edc86dac456034c3e (patch) | |
| tree | c90744aa2e0edf37c8e6cbc0033476230a086412 /src/layout.zig | |
| parent | c78d362fa20393621ac198861f891439f9d832e9 (diff) | |
| download | pardes-bfb74e76ef7dfe305a26010edc86dac456034c3e.tar.gz pardes-bfb74e76ef7dfe305a26010edc86dac456034c3e.zip | |
locality: single-caller helpers beside their caller: File's placeOf and restoreName beside undoStep, Query's row makers (clearPlaces, makeAllRows, makeNameRows, feedGrepPlaces) beside produce, look's helpers beside lookAt, lookSpanIn and lookUnresolved, mouse's beside handleMouse and dragUpdate, normal's beside handleNormal and executeNormalAction, and the rest in Core, draw, exec, layout, main, modal, replica, syntax, terminal; Messages.printRight into draw.zig beside joinNotice and edit.spanHas into exec.zig beside operandAt, their only callers
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/layout.zig')
| -rw-r--r-- | src/layout.zig | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/src/layout.zig b/src/layout.zig index f21eace1..1d93c993 100644 --- a/src/layout.zig +++ b/src/layout.zig @@ -585,6 +585,21 @@ pub fn acmePlace(p: *Pardes, c: usize, origin: ?usize, id: usize) void { /// its tag (acme's minht keeps one). 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. +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; + if (p.view().rects[id].w == 0) return pane.tag_rows; // never laid out + var wrap_room: [32 * 1024]u8 = undefined; + var wrap_fba = std.heap.FixedBufferAllocator.init(&wrap_room); + const wa = wrap_fba.allocator(); + const prefix = tagline.prefixIn(p, wa, pane) catch return pane.tag_rows; + const whole = std.mem.concat(wa, u8, &.{ prefix, tagline.curTail(pane) }) catch return pane.tag_rows; + const shown = tagline.wrapTag(wa, whole, tagline.tagWidth(p, id)) catch return pane.tag_rows; + return @intCast(@max(BOX_H, @min(shown.rows(), MAX_TAG_ROWS))); +} + /// The rows a placement, and a `size`, leave a pane: its tag at its width /// and `min_body_rows`. The one minimum both ask. pub fn minRows(p: *Pardes, id: usize) u16 { @@ -713,31 +728,6 @@ pub fn restoreMinimaFrom(p: *Pardes, before: *const [MAX_PANES]Rect, before_min: compute(p); } -/// Whether new column `c` (Newcol'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 { - const v = p.view(); - restoreMinimaFrom(p, before, before_min); - for (0..p.view().ncol) |k| { - compute(p); - if (v.cols[k].n < 2) continue; - const squeezed = for (v.cols[k].panes[0..p.view().cols[k].n]) |id| { - const pane = p.panes[id] orelse continue; - if (!pane.collapsed and v.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 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. @@ -1369,6 +1359,31 @@ pub fn columnBarHeight(p: *const Pardes) u16 { return COLBAR_H; } +/// Whether new column `c` (Newcol'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 { + const v = p.view(); + restoreMinimaFrom(p, before, before_min); + for (0..p.view().ncol) |k| { + compute(p); + if (v.cols[k].n < 2) continue; + const squeezed = for (v.cols[k].panes[0..p.view().cols[k].n]) |id| { + const pane = p.panes[id] orelse continue; + if (!pane.collapsed and v.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 true; +} + /// Newcol: an empty column right of the calling pane's, the keyboard /// on its tag, for the next pane made to fill. pub fn newColumn(p: *Pardes, from_id: usize) void { @@ -1474,21 +1489,6 @@ pub fn besideColumn(p: *const Pardes, col: usize, r: ?Rect) ?usize { return pick; } -/// 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. -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; - if (p.view().rects[id].w == 0) return pane.tag_rows; // never laid out - var wrap_room: [32 * 1024]u8 = undefined; - var wrap_fba = std.heap.FixedBufferAllocator.init(&wrap_room); - const wa = wrap_fba.allocator(); - const prefix = tagline.prefixIn(p, wa, pane) catch return pane.tag_rows; - const whole = std.mem.concat(wa, u8, &.{ prefix, tagline.curTail(pane) }) catch return pane.tag_rows; - const shown = tagline.wrapTag(wa, whole, tagline.tagWidth(p, id)) catch return pane.tag_rows; - return @intCast(@max(BOX_H, @min(shown.rows(), MAX_TAG_ROWS))); -} - /// The pane's first body row, under its tag. Notice bands do NOT move it /// -- they are an overlay, drawn over the top rows rather than taking them. pub fn bodyTop(_: *const Pardes, pane: *const Pane, r: Rect) u16 { |
