summaryrefslogtreecommitdiff
path: root/core/layout.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 15:13:18 -0300
committerGabriel Schneider <[email protected]>2026-11-20 19:20:33 -0300
commite9a641ee2c743fec2fe2505d2e11c96fa36767b8 (patch)
tree0475bbf328bf21e41b573c0cd95684d8a7336741 /core/layout.zig
parent4887578ce82518c84ef76f7ee03748911f4f9933 (diff)
downloadpardes-e9a641ee2c743fec2fe2505d2e11c96fa36767b8.tar.gz
pardes-e9a641ee2c743fec2fe2505d2e11c96fa36767b8.zip
core, docs: the docking vocabulary, the family the rename of attached_to to docked_to left (P37): layout.attachFrom -> layout.dockFrom (its five callers: Query.zig x2, Store.zig, its tests), testAttachment -> testDocking, Query.zig's local attached -> docked, the section "Attached panes" -> "Docked panes" (and the three comments that name it), and "attached", "attachment(s)", "unattached", "Attach new pane", "detaches it" where a pane is docked to a pane -> "docked", "docked pane(s)", "undocked", "Dock new pane", "undocks it", through core/layout.zig (two test names with it), core/Handover.zig, core/Store.zig, core/Query.zig, comments in core/panes.zig (4) and core/builtins.zig (2), docs/next-drag.md, docs/search-proto-converge.md and docs/next-daemon.md (1); every attach of a client to a session stays, as do the search prototype's name "attached" and its setting SearchPlace attached|column (docs/search-proto-converge.md:18, :134: names of the past) and the changelog's past entries; no behaviour changes; gate on the stack through this change and the docking vocabulary (load 4-32): tui core-test 871/1028 (157 skipped), shell-test 1070/1073, pane-test 183/184, term-test 17/17, kitty-test 45/45, behaviour-test 275/275 and --replay 275/275, consumer-test passes, addon-test 5/5, process-test 0 of 144 (tty boot: msg failed once at load 32 and passed alone), replicas --clients 5 and --bytes --clients 5: diverged 0, unequal 0, deltas wrong 0, quiet checks differed 0, unlisted stops 0, corpus 22 of 22, no leak; the semantics word a73794ff9e03f814 as on merge40; daemon.py --far, --games, --window-clients pass, plain fails 2 of 4 at "client C agrees with a shell's output" (a timeout), as merge40's build does 3 of 6; the macOS library (x86_64-linux, aarch64-macos, the ABI guard 2/2) and the FreeBSD cross-build build; frames 77/77, gui unit-test 1666/1670 (the perf check's BaselineHarnessMismatch), perfab corpus2x +0.054% (noise 0.054%), the 121 per-operation counts within 0.1% against tree2 (key-down on medium 10,039,720 and render on medium 11,454,636, merge40's gate 10,039,703 and 11,454,619)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/layout.zig')
-rw-r--r--core/layout.zig90
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);