diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 19:22:32 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 19:51:13 -0300 |
| commit | 4e1432049765be6e793a3834c93c4cd5318e82bc (patch) | |
| tree | aa8e98c4cb2b7ee6ba33a49255fa85cab0089e2d /core/layout.zig | |
| parent | 486f347adeed5bac6aaabe8be34e6a69bf323a62 (diff) | |
| parent | 2d75490196a9d15eff6ac471e9584101a5697afe (diff) | |
| download | pardes-4e1432049765be6e793a3834c93c4cd5318e82bc.tar.gz pardes-4e1432049765be6e793a3834c93c4cd5318e82bc.zip | |
integration: six slot fields typed, the docking vocabulary, the Mac's callbacks and consumer-test, on six small faults: pardes-slots (Pipe.PendingPipe.pane, Ask.wait.pane, theme_file_pane, ThemeFileRequest.pane as Pane.Id; Authority.view_of and Peer.view as View.Id; layout.dockFrom and the prose; macos State.callbacks; the build step consumer-test) and pardes-merge42; one conflict, in Peers.detach, where the pair's lifetime rule (daemon.keepSession) and the view's type (peer.view.index()) met on neighbouring lines: both kept; tui core-test 874/1031 (157 skipped), shell-test 1073/1076, term-test 17/17, both soaks diverged 0, unequal 0, unlisted 0, the window builds; this line carries the client's heap corruption that came with pardes-merge40 (a fix is being made): not gated further until it has it
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/layout.zig')
| -rw-r--r-- | core/layout.zig | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/core/layout.zig b/core/layout.zig index 9c99dc7d..4c7d6afb 100644 --- a/core/layout.zig +++ b/core/layout.zig @@ -249,8 +249,8 @@ fn splitRowFor(y: u16, h: u16, cur_y: u16, least: ?u16) ?u16 { } /// Where pane `id` dragged by its grip to (`cur_x`, `cur_y`) lands. An -/// owner's grip drags its group; an attachment's drags it alone, which -/// within its group resizes it and anywhere else detaches it (movePane). +/// owner's grip drags its group; a docked pane's drags it alone, which +/// within its group resizes it and anywhere else undocks it (movePane). /// Another group is one place: a pane dropped on it lands under all of it. pub fn movePlacement(p: *Pardes, id: usize, cur_x: u16, cur_y: u16) ?MovePlacement { const v = p.view(); @@ -285,8 +285,8 @@ pub fn movePlacement(p: *Pardes, id: usize, cur_x: u16, cur_y: u16) ?MovePlaceme k += 1; continue; } - // Its own group's panes are places of their own: that is how an - // attachment's grip resizes it against its owner. + // Its own group's panes are places of their own: that is how a + // docked pane's grip resizes it against its owner. const unit_end = if (groupRoot(p, v.cols[tc].panes[k]) == own_root) k + 1 else groupEnd(p, tc, k); var h: u16 = 0; for (k..unit_end) |j| { @@ -313,8 +313,8 @@ pub fn movePlacement(p: *Pardes, id: usize, cur_x: u16, cur_y: u16) ?MovePlaceme return last; } -/// Move pane `id`, and the group it owns, where movePlacement says. An -/// attachment moved anywhere but within its own group is detached there. +/// Move pane `id`, and the group it owns, where movePlacement says. A +/// docked pane moved anywhere but within its own group is undocked there. pub fn movePane(p: *Pardes, id: usize, cur_x: u16, cur_y: u16) void { const v = p.view(); const placement = movePlacement(p, id, cur_x, cur_y) orelse return; @@ -549,7 +549,7 @@ pub fn acmePlace(p: *Pardes, c: usize, origin: ?usize, id: usize) void { var empty: ?usize = null; for (p.view().cols[c].panes[0..n]) |k| { const pane = p.panes[k] orelse continue; - // An attachment is its owner's: never halved for another pane. + // A docked pane is its owner's: never halved for another pane. if (pane.collapsed or ownerOf(p, k) != null) continue; // `>=`: at a tie the one nearer the bottom, as acme picks. if (big == null or bodyRows(p, k) >= bodyRows(p, big.?)) big = k; @@ -1076,7 +1076,7 @@ pub fn absorbVWeight(p: *Pardes, id: usize, to: ?usize) ?usize { var k = f.idx; while (to == null and k > 0) : (k -= 1) { sib = v.cols[f.col].panes[k - 1]; - // nor to a pane attached to another: rows go to owners + // nor to a pane docked to another: rows go to owners if (p.panes[sib]) |pp| if (if (pp.file) |ff| panes.Output.fileTraits(ff.output).doc else true) if (ownerOf(p, sib) == null) break; } const s = p.panes[sib] orelse return null; @@ -1112,26 +1112,26 @@ pub fn splitBelow(p: *Pardes, src_id: usize, nw: *Pane) void { }; } -// ---- Attached panes ---- +// ---- Docked panes ---- // -// A results pane (+Search, +Callstack, +Diff, +Errors) is ATTACHED to the +// A results pane (+Search, +Callstack, +Diff, +Errors) is DOCKED to the // pane it answers for, its owner (Pane.docked_to). The owner and what is -// attached to it, and what is attached to those (a preview under a +// docked to it, and what is docked to those (a preview under a // +Search), are a GROUP: contiguous in one column, the owner first. A group // is one place to everything else in the layout: an unrelated pane is never // put inside it (acmePlace, splitAt, splitTallest), a pane dragged onto it // lands under all of it (movePlacement), and its owner's grip, Collapse and -// Del take all of it (movePane, toggleCollapse, Pardes.removePane). An -// attachment's rows come from its owner and go back to it, nobody else's. +// Del take all of it (movePane, toggleCollapse, Pardes.removePane). A +// docked pane's rows come from its owner and go back to it, nobody else's. -/// The slot of `id`'s owner, when `id` is attached to a live pane. +/// The slot of `id`'s owner, when `id` is docked to a live pane. pub fn ownerOf(p: *const Pardes, id: usize) ?usize { const serial = (p.panes[id] orelse return null).docked_to orelse return null; for (p.panes, 0..) |slot, i| if (slot) |pane| if (pane.serial == serial and i != id) return i; return null; } -/// The owner at the top of `id`'s group: `id` itself when it is attached to +/// The owner at the top of `id`'s group: `id` itself when it is docked to /// nothing. Bounded: a dump could name a ring of owners. pub fn groupRoot(p: *const Pardes, id: usize) usize { var at = id; @@ -1139,7 +1139,7 @@ pub fn groupRoot(p: *const Pardes, id: usize) usize { return at; } -/// Whether `id` is `root` or attached to it through any number of owners. +/// Whether `id` is `root` or docked to it through any number of owners. fn descends(p: *const Pardes, id: usize, root: usize) bool { var at = id; for (0..MAX_PANES) |_| { @@ -1150,7 +1150,7 @@ fn descends(p: *const Pardes, id: usize, root: usize) bool { } /// One past the last pane of the group that pane `idx` of column `c` is -/// in: `idx + 1` for a pane with nothing attached. +/// in: `idx + 1` for a pane with nothing docked. pub fn groupEnd(p: *const Pardes, c: usize, idx: usize) usize { const v = p.view(); const root = groupRoot(p, v.cols[c].panes[idx]); @@ -1159,11 +1159,11 @@ pub fn groupEnd(p: *const Pardes, c: usize, idx: usize) usize { return k; } -/// The attachments kept where they are attached: one whose owner is gone, +/// The docked panes kept where they are docked: one whose owner is gone, /// or that something (a 9P move, a pane split into a column of its own, an /// owner moved by a route that does not carry its group) left anywhere but /// right under its owner's group, is an ordinary pane from then on, where -/// it stands. Nothing moves. Top to bottom, so a nested attachment is +/// it stands. Nothing moves. Top to bottom, so a nested docked pane is /// judged after the one it hangs from. pub fn keepGroups(p: *Pardes) void { for (0..p.view().ncol) |c| for (p.view().cols[c].panes[0..p.view().cols[c].n], 0..) |id, k| { @@ -1175,17 +1175,17 @@ pub fn keepGroups(p: *Pardes) void { }; } -/// Attach new pane `id`, in no column yet, to `owner`: under the owner's +/// Dock new pane `id`, in no column yet, to `owner`: under the owner's /// group, `rows` of the owner's rows (tag included), from the owner and /// from no other pane. The owner keeps its own minimum, else its tag (acme -/// lets a window shrink to it), so the attachment may get fewer. A folded -/// owner is unfolded first. The rows are the attachment's from then on: +/// lets a window shrink to it), so the docked pane may get fewer. A folded +/// owner is unfolded first. The rows are the docked pane's from then on: /// nothing here ever resizes it again; the seam is the user's to drag. /// False, `id` in no column, when the owner has not the rows for its tag -/// and the attachment's minimum. The rows are given by `giver`: the owner +/// and the docked pane's minimum. The rows are given by `giver`: the owner /// itself or a pane of its group (a +Preview added under a query pane later /// takes the text's rows, so the query pane, typed into, keeps its own). -pub fn attachFrom(p: *Pardes, owner: usize, id: usize, rows: u16, giver: usize) bool { +pub fn dockFrom(p: *Pardes, owner: usize, id: usize, rows: u16, giver: usize) bool { const v = p.view(); const o = p.panes[owner] orelse return false; const g = p.panes[giver] orelse return false; @@ -1238,10 +1238,10 @@ pub fn giveBack(p: *Pardes, id: usize, gainer: usize, below: bool, rows: u16) bo return true; } -/// Collapse on an owner with attachments: the whole group folds to its +/// Collapse on an owner with docked panes: the whole group folds to its /// tags, every row it gave up to the one unfolded neighbour outside it, /// and unfolds again from that neighbour, as one pane's Collapse does. -/// ponytail: unfolding opens every attachment, one folded alone before +/// ponytail: unfolding opens every docked pane, one folded alone before /// included; remembering which were is a bit a pane. fn collapseGroup(p: *Pardes, c: usize, start: usize, end: usize) void { const v = p.view(); @@ -1281,7 +1281,7 @@ pub fn toggleCollapse(p: *Pardes, id: usize) void { const pane = p.panes[id] orelse return; const at = findPane(p, id) orelse return; compute(p); - // An owner folds and unfolds with what is attached to it. + // An owner folds and unfolds with what is docked to it. if (ownerOf(p, id) == null) { const end = groupEnd(p, at.col, at.idx); if (end > at.idx + 1) return collapseGroup(p, at.col, at.idx, end); @@ -1635,8 +1635,8 @@ pub fn reprojectTagHit(p: *const Pardes, tag_hit: TagHit) ?TagHit { return Layer.tagAgain(tag_hit); } -/// A test's attachment: an empty +Search in a new slot, in no column. -fn testAttachment(p: *Pardes) !usize { +/// A test's docked pane: an empty +Search in a new slot, in no column. +fn testDocking(p: *Pardes) !usize { const free = p.freeSlot().?; _ = try panes.Output.open(p, free, "/tmp", .search, "", try p.gpa.dupe(u8, "q\n")); return free; @@ -1884,7 +1884,7 @@ test "column reorder moves only crossed state and preserves weights" { try std.testing.expectEqual(@as(i32, 21), p.view().col_tags[1].cur_col); } -test "an attachment takes its rows from its owner alone, keeps them, and moves, folds and closes with it" { +test "a docked pane takes its rows from its owner alone, keeps them, and moves, folds and closes with it" { const exec = pardes.exec; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 48 }); defer p.deinit(); @@ -1900,8 +1900,8 @@ test "an attachment takes its rows from its owner alone, keeps them, and moves, const unrelated = [_]usize{ below, other_col }; // Under its owner, the rows asked for, the owner's and nobody else's. - const s = try testAttachment(p); - try std.testing.expect(attachFrom(p, 0, s, 9, 0)); + const s = try testDocking(p); + try std.testing.expect(dockFrom(p, 0, s, 9, 0)); try std.testing.expectEqual(@as(?usize, 0), ownerOf(p, s)); try std.testing.expectEqual(s, p.view().cols[0].panes[1]); for (unrelated) |k| try std.testing.expectEqualDeep(before[k], p.view().rects[k]); @@ -1909,8 +1909,8 @@ test "an attachment takes its rows from its owner alone, keeps them, and moves, try std.testing.expectEqual(before[0].y, p.view().rects[0].y); try std.testing.expectEqual(@as(u16, 9), p.view().rects[s].h); // A second level (a preview under a query pane): out of the first's rows. - const pv = try testAttachment(p); - try std.testing.expect(attachFrom(p, s, pv, 4, s)); + const pv = try testDocking(p); + try std.testing.expect(dockFrom(p, s, pv, 4, s)); try std.testing.expectEqual(pv, p.view().cols[0].panes[2]); try std.testing.expectEqual(@as(usize, 0), groupRoot(p, pv)); try std.testing.expectEqual(@as(usize, 3), groupEnd(p, 0, 0)); @@ -1925,7 +1925,7 @@ test "an attachment takes its rows from its owner alone, keeps them, and moves, compute(p); try std.testing.expectEqual(@as(u16, 5), p.view().rects[s].h); - // An unrelated New, from the owner or from its attachment, never lands + // An unrelated New, from the owner or from its docked pane, never lands // inside the group. exec.runBuiltin(p, .New, 0, "", null); exec.runBuiltin(p, .New, s, "", null); @@ -1933,7 +1933,7 @@ test "an attachment takes its rows from its owner alone, keeps them, and moves, try std.testing.expectEqual(s, p.view().cols[at.col].panes[at.idx + 1]); try std.testing.expectEqual(pv, p.view().cols[at.col].panes[at.idx + 2]); - // The seam between owner and attachment is the user's: the pair alone. + // The seam between owner and docked pane is the user's: the pair alone. compute(p); const pre_drag = p.view().rects; applyRowSplit(p, at.col, at.idx, p.view().rects[s].y - 3); @@ -1965,7 +1965,7 @@ test "an attachment takes its rows from its owner alone, keeps them, and moves, try std.testing.expect(p.panes[pv] == null); compute(p); try std.testing.expectEqual(pair[s].h + pair[pv].h, p.view().rects[s].h); - // Del of the attachment gives its rows back to the owner, nobody else. + // Del of the docked pane gives its rows back to the owner, nobody else. pair = p.view().rects; exec.runBuiltin(p, .Del, s, "", null); try std.testing.expect(p.panes[s] == null); @@ -1973,19 +1973,19 @@ test "an attachment takes its rows from its owner alone, keeps them, and moves, try std.testing.expectEqual(pair[0].h + pair[s].h, p.view().rects[0].h); for (p.view().cols[1].panes[0..p.view().cols[1].n]) |k| if (k != 0) try std.testing.expectEqualDeep(pair[k], p.view().rects[k]); - // Del of the owner closes what is attached to it. - const again = try testAttachment(p); - try std.testing.expect(attachFrom(p, 0, again, 6, 0)); + // Del of the owner closes what is docked to it. + const again = try testDocking(p); + try std.testing.expect(dockFrom(p, 0, again, 6, 0)); exec.runBuiltin(p, .Del, 0, "", null); try std.testing.expect(p.panes[0] == null and p.panes[again] == null); } -test "an attachment survives Dump and Restore, and one left away from its owner is a pane of its own" { +test "a docked pane survives Dump and Restore, and one left away from its owner is a pane of its own" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 40 }); defer p.deinit(); _ = try p.setTestFile("alpha\nbeta\nalphabet\n"); - const s = try testAttachment(p); - try std.testing.expect(attachFrom(p, 0, s, 8, 0)); + const s = try testDocking(p); + try std.testing.expect(dockFrom(p, 0, s, 8, 0)); try std.testing.expectEqual(@as(?usize, 0), ownerOf(p, s)); try dump.dumpState(p); const restored = try dump.initFromDump(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 40 }, p.dump_out.?); @@ -1995,8 +1995,8 @@ test "an attachment survives Dump and Restore, and one left away from its owner pardes.exec.runBuiltin(p, .Undock, s, "", null); try std.testing.expect(p.panes[s].?.docked_to == null); // Put above its owner by a route that does not carry groups: detached. - const t = try testAttachment(p); - try std.testing.expect(attachFrom(p, 0, t, 8, 0)); + const t = try testDocking(p); + try std.testing.expect(dockFrom(p, 0, t, 8, 0)); try std.testing.expectEqual(@as(?usize, 0), ownerOf(p, t)); removePane(p, t); insert(p, 0, 0, t); |
