diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-24 19:37:15 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-24 19:38:18 -0300 |
| commit | 480f36b85299fa7407c20a2d6482dd093f842bf7 (patch) | |
| tree | 5d07c37c3e4eae82ec35ed100799d5810a8912aa /core/layout.zig | |
| parent | f44d1b7d040acf674814be3cde336527833450e9 (diff) | |
| parent | 9f63733156853c925c31a948b50d4a3a7b77aa70 (diff) | |
| download | pardes-480f36b85299fa7407c20a2d6482dd093f842bf7.tar.gz pardes-480f36b85299fa7407c20a2d6482dd093f842bf7.zip | |
walk UI wave-2 base: line A items 1-4 (kquzozvs) merged with line B items 1-5 (mqmtqvtt)
Diffstat (limited to 'core/layout.zig')
| -rw-r--r-- | core/layout.zig | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/core/layout.zig b/core/layout.zig index f9b9ef81..c2f0f96c 100644 --- a/core/layout.zig +++ b/core/layout.zig @@ -860,8 +860,46 @@ fn blankRows(p: *const Pardes, id: usize) u16 { } /// What a new pane is, and who asked: each rule places them differently. -/// `scratch` is New's, `fs` 9P's pane/new, `errors` a +Errors pane. -pub const NewPane = enum { scratch, fs, shell, doc, command, errors }; +/// `scratch` is New's, `fs` 9P's pane/new, `errors` a +Errors pane, +/// `reader` a held pane's reader (Trail.zig). +pub const NewPane = enum { scratch, fs, shell, doc, command, errors, reader }; + +/// The body rows a held pane keeps above its reader: with fewer, the +/// reader goes to the next column (pick-ui SPEC §6.1). +pub const reader_keeps = 8; + +/// A reader's place (pick-ui SPEC §6.1): under its held pane `from`, +/// taking half its rows, unless that leaves it fewer than `reader_keeps` +/// body rows; then at the bottom of the next column, the previous one +/// when `from`'s is the last, as New takes the bottom of a column. +fn readerPlace(p: *Pardes, from: usize, id: usize) void { + const v = p.view(); + const c = columnOf(p, from); + const r = v.rects[from]; + if (findPane(p, from) != null and r.h / 2 >= p.panes[from].?.tag_rows + reader_keeps) return splitAt(p, c, id, r.y + r.h / 2); + acmePlace(p, if (c + 1 < v.ncol) c + 1 else c -| 1, null, id); +} + +/// Pane `new` in pane `old`'s place in every view, with its rows: a +/// reader's step to another file (Trail.zig). `old` leaves no layout. +pub fn replacePane(p: *Pardes, old: usize, new: usize) void { + const was = p.panes[old].?; + const now = p.panes[new].?; + now.vweight = was.vweight; + now.collapsed = was.collapsed; + for (0..pardes.views.max) |k| if (now.pv_known & was.pv_known & (@as(u8, 1) << @intCast(k)) != 0) { + now.pv[k].vweight = was.pv[k].vweight; + now.pv[k].collapsed = was.pv[k].collapsed; + }; + for (&p.views) |*slot| { + const v = &(slot.* orelse continue); + for (v.cols[0..v.ncol]) |*col| for (col.panes[0..col.n]) |*k| if (k.* == old) { + k.* = new; + }; + v.rects[new] = v.rects[old]; + if (v.active == old) v.active = new; + } +} /// Put new pane `id` in the layout: every new pane comes through here, as /// acme's makenewwindow places it, and every one but a command pane takes @@ -888,6 +926,7 @@ pub fn placeNew(p: *Pardes, from: usize, origin: ?usize, id: usize, kind: NewPan // makenewwindow(nil) for 9P's new (acme.c:877), else (t). .fs => acmePlace(p, acmeColumn(p, from), null, id), .shell, .doc => acmePlace(p, acmeColumn(p, from), asked, id), + .reader => readerPlace(p, from, id), } // No pane is made shorter than its tag and two rows: where the place // chosen has not the room, the column's tallest pane gives it, and |
