diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-24 19:16:35 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-24 19:16:35 -0300 |
| commit | 08524143c84c069a80861895fafd0b7411a201f5 (patch) | |
| tree | e48aa971e9d31b038c428d7f8fcd9e1c9f6864bc /core/layout.zig | |
| parent | 7e7d9569a008124cb7ea01b6720a8d5963b0a42f (diff) | |
| download | pardes-08524143c84c069a80861895fafd0b7411a201f5.tar.gz pardes-08524143c84c069a80861895fafd0b7411a201f5.zip | |
walk (pick-ui SPEC §6.1, §6.2, item 2 of the Walk UI line B): a jump goes through look.open(from, path, at, how), the one way a Look at an address, a definition (lsp/Ask.zig), an error's place, a list's row and a closed jump-list entry land, for D's pickers too: under `Jumps walk` a held pane showing the file is focused and nothing replaced, the asking pane showing it moves in it (a step when it reads), a reading pane steps in place and a held one steps its one reader (Trail.readerOf: the reading pane whose trail starts with its owner), made on its first jump under it with half its rows (layout.placeNew .reader: unless that leaves it under reader_keeps 8 body rows; then the bottom of the next column, the previous from the last); a step to another file is a new pane in the reader's place in every view (layout.replacePane), its walk with it, the old one closed as a pane is (Recent keeps its dot) but kept by no Store record; a place on the trail is gone back or forward to, a jump to where it is takes no step, a path over max_text opens a pane as new-pane does; `Jumps new-pane` (the default) runs the code it always ran (openNew is lookAt's new-pane branch moved, and the .pane branch is untouched); TEST FIRST: Trail.zig "a jump from a held pane steps its reader ...", "a Look from inside the reader at a file its held pane shows focuses the held pane and replaces nothing", "the reader of a held pane too short to halve goes to the bottom of the next column ..."; core-test 996/1162 (166 skipped), pane-test 183/184, behaviour-test 277/277
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 7fa57ee9..bcf057fa 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 |
