summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 19:22:32 -0300
committerGabriel Schneider <[email protected]>2026-11-20 19:51:13 -0300
commit4e1432049765be6e793a3834c93c4cd5318e82bc (patch)
treeaa8e98c4cb2b7ee6ba33a49255fa85cab0089e2d /core
parent486f347adeed5bac6aaabe8be34e6a69bf323a62 (diff)
parent2d75490196a9d15eff6ac471e9584101a5697afe (diff)
downloadpardes-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')
-rw-r--r--core/CHANGELOG.md6
-rw-r--r--core/Core.zig2
-rw-r--r--core/Handover.zig14
-rw-r--r--core/Pipe.zig36
-rw-r--r--core/Query.zig18
-rw-r--r--core/Store.zig8
-rw-r--r--core/builtins.zig4
-rw-r--r--core/colors.zig7
-rw-r--r--core/echo.zig2
-rw-r--r--core/layout.zig90
-rw-r--r--core/lsp/Ask.zig39
-rw-r--r--core/panes.zig8
-rw-r--r--core/replica.zig40
13 files changed, 137 insertions, 137 deletions
diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md
index e5d592bb..49bc105f 100644
--- a/core/CHANGELOG.md
+++ b/core/CHANGELOG.md
@@ -249,9 +249,9 @@
editor has them, for a program that draws source text itself. Every
dependency but tree-sitter's runtime is lazy in the manifest, so such a
package fetches the runtime and the grammars of its `grammars` set
- and nothing else; `zig build lib-test`, which `unit-test` runs, builds
- one (`test/consumer`). The markdown grammar is pinned by its commit: its
- branch has moved, and a fresh checkout could not fetch it.
+ and nothing else; `zig build consumer-test`, which `unit-test` runs,
+ builds one (`test/consumer`). The markdown grammar is pinned by its
+ commit: its branch has moved, and a fresh checkout could not fetch it.
- Enter, `o` and `O` give the new line helix's indent where the file's
grammar has an indent query (bash, C, C#, C++, Clojure, CSS, Elixir,
diff --git a/core/Core.zig b/core/Core.zig
index 98e2e407..55b3682f 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -300,7 +300,7 @@ theme_file_path: config.Settings.Text(limits.host_path_cap) = .{},
/// what a failed ThemeFile goes back to (colors.revertThemeFile).
theme_file_loaded: config.Settings.Text(limits.host_path_cap) = .{},
theme_file_generation: u32 = 0,
-theme_file_pane: u8 = 0,
+theme_file_pane: Pane.Id = .at(0),
chrome: colors.ChromeTheme = colors.initial_chrome,
/// Every drawn frame's timings (FrameStats: the Debug box, PARDES_FRAMES):
/// its runner's (`Options.frames`), which its frontend writes as it draws
diff --git a/core/Handover.zig b/core/Handover.zig
index dde31f8b..6f7340b2 100644
--- a/core/Handover.zig
+++ b/core/Handover.zig
@@ -33,7 +33,7 @@ const MAX_PANES = pardes.MAX_PANES;
/// libc: fork and exec of a window, and file calls in the cancelable carry task that must not see its cancel (its defer's unlink).
const libc = std.c;
-/// What a grip carries out of its window: one pane with the panes attached
+/// What a grip carries out of its window: one pane with the panes docked
/// to it, or a whole column.
pub const Kind = enum { pane, column };
@@ -46,7 +46,7 @@ const Carried = struct {
/// Each pane as dump.savePane makes it, top to bottom.
panes: []const []const u8,
weights: []const f32,
- /// Which of them each one is attached to (layout.zig, "Attached panes").
+ /// Which of them each one is docked to (layout.zig, "Docked panes").
owners: []const ?u32,
};
pub const carried_magic = "pardes-carried\n";
@@ -84,8 +84,8 @@ pub fn deinit(h: *Handover, gpa: std.mem.Allocator) void {
h.bytes = null;
}
-/// Pane slot `at` (with what is attached to it, or alone when it is itself
-/// an attachment), or column `at`, released past the window's edge: dumped,
+/// Pane slot `at` (with what is docked to it, or alone when it is itself
+/// a docked pane), or column `at`, released past the window's edge: dumped,
/// and the host asked to carry it. Only text panes travel: a terminal's
/// shell is this process's child and would die with the pane here.
pub fn begin(h: *Handover, p: *Pardes, carried: Kind, at: usize) void {
@@ -273,7 +273,7 @@ pub fn adopt(p: *Pardes, bytes: []const u8) !usize {
n += 1;
if (pane.file == null) return error.NotText;
}
- // An attachment names its owner by its place in the dump.
+ // A docked pane names its owner by its place in the dump.
for (st.owners, 0..) |owner, k| {
const at = owner orelse continue;
if (at >= n) continue;
@@ -299,7 +299,7 @@ pub fn adopt(p: *Pardes, bytes: []const u8) !usize {
for (0..p.view().ncol) |c| for (p.view().cols[c].panes[0..p.view().cols[c].n]) |id| {
heights[id] = p.view().rects[id].h;
};
- // The group under the pointer (a pane with what is attached to it): the
+ // The group under the pointer (a pane with what is docked to it): the
// new panes go under all of it, out of its owner's rows.
var after: usize = p.view().cols[tc].n;
var root: ?usize = null;
@@ -315,7 +315,7 @@ pub fn adopt(p: *Pardes, bytes: []const u8) !usize {
}
if (root) |owner| {
const r = p.view().rects[owner];
- // Down to the pointer's row; let go over one of its attachments,
+ // Down to the pointer's row; let go over one of its docked panes,
// half of it.
const keeps = @max(layout.minRows(p, owner), if (y >= r.y and y < r.y + r.h) (y - r.y) + 1 else r.h / 2);
const give = heights[owner] -| keeps;
diff --git a/core/Pipe.zig b/core/Pipe.zig
index cf61b78f..012ce689 100644
--- a/core/Pipe.zig
+++ b/core/Pipe.zig
@@ -52,7 +52,7 @@ pub const PendingPipe = struct {
/// The digest's walk (core/walk.zig) of the ranges, as far as they go.
pub const replica = .{ .len = .{.{ "ranges", "nranges" }} };
id: u32,
- pane: usize,
+ pane: Pane.Id,
serial: u32,
/// The text piped: the pane's body or tag, or a header (`column`
/// names which).
@@ -133,7 +133,7 @@ pub fn submitPipe(p: *Pardes, id: usize) void {
if (p.pipe.wait) |*old| old.deinit();
p.pipe.wait = .{
.id = p.pipe.seq,
- .pane = id,
+ .pane = .at(id),
.serial = pane.serial,
.what = t.what,
.column = p.headerColumn() orelse 0,
@@ -166,16 +166,16 @@ fn pipeFailed(p: *Pardes, wait: *const PendingPipe, failure: ?selection_pipe.Fai
var out: std.Io.Writer.Allocating = .init(p.gpa);
defer out.deinit();
const w = &out.writer;
- w.print("| {s}\n\n", .{wait.command}) catch |err| return p.reportError(.at(wait.pane), "pipe", err);
+ w.print("| {s}\n\n", .{wait.command}) catch |err| return p.reportError(wait.pane, "pipe", err);
if (wait.inputs.len > 1) if (failure) |fail|
- w.print("selection {d} of {d}: ", .{ fail.index + 1, wait.inputs.len }) catch |err| return p.reportError(.at(wait.pane), "pipe", err);
- writeFailure(w, failure) catch |err| return p.reportError(.at(wait.pane), "pipe", err);
- const content = out.toOwnedSlice() catch |err| return p.reportError(.at(wait.pane), "pipe", err);
+ w.print("selection {d} of {d}: ", .{ fail.index + 1, wait.inputs.len }) catch |err| return p.reportError(wait.pane, "pipe", err);
+ writeFailure(w, failure) catch |err| return p.reportError(wait.pane, "pipe", err);
+ const content = out.toOwnedSlice() catch |err| return p.reportError(wait.pane, "pipe", err);
const was = p.view().active;
- panes.Output.openErrors(p, wait.pane, content) catch |err| {
+ panes.Output.openErrors(p, wait.pane.index(), content) catch |err| {
p.gpa.free(content);
// Nowhere to put the report is itself worth one line.
- p.reportError(.at(wait.pane), "pipe", err);
+ p.reportError(wait.pane, "pipe", err);
return;
};
if (p.panes[was] != null) p.view().active = was;
@@ -250,7 +250,7 @@ pub fn pipeResponse(
if (!success or outputs.len != wait.inputs.len) return pipeFailed(p, &wait, failure);
- const pane = p.panes[wait.pane] orelse return;
+ const pane = p.panes[wait.pane.index()] orelse return;
if (pane.serial != wait.serial) return;
const t: *Text = switch (wait.what) {
.body => &pane.body,
@@ -259,13 +259,13 @@ pub fn pipeResponse(
.workspace => &p.global_tag,
.input => return,
};
- const content = edit.flatSurface(p.editor(), t) catch |err| return p.reportError(.at(wait.pane), "pipe", err);
+ const content = edit.flatSurface(p.editor(), t) catch |err| return p.reportError(wait.pane, "pipe", err);
const changed = if (t.what == .body) changed: {
const f = pane.file orelse return;
if (!panes.Output.fileTraits(f.output).saves) return;
break :changed f.revision != wait.revision;
} else std.hash.Wyhash.hash(0, content) != wait.sum;
- if (changed) return p.reportError(.at(wait.pane), "pipe", error.FileChangedWhileFiltering);
+ if (changed) return p.reportError(wait.pane, "pipe", error.FileChangedWhileFiltering);
if (wait.how == .ignore) return;
if (wait.how == .keep) {
@@ -296,14 +296,14 @@ pub fn pipeResponse(
const cut = pipeCut(&wait, content, i) orelse return;
const output = pipeOutput(&wait, outputs, content, i);
if (output.len > selection_pipe.max_stdout_bytes)
- return p.setMessage(.at(wait.pane), std.fmt.bufPrint(&said, "pipe: an output of {d} bytes, past {d}: the text is left as it was", .{ output.len, selection_pipe.max_stdout_bytes }) catch unreachable); // two numbers fit 128
+ return p.setMessage(wait.pane, std.fmt.bufPrint(&said, "pipe: an output of {d} bytes, past {d}: the text is left as it was", .{ output.len, selection_pipe.max_stdout_bytes }) catch unreachable); // two numbers fit 128
total_output += output.len; // each under 1 MiB, at most max_selections of them
if (total_output > selection_pipe.max_total_stdout_bytes)
- return p.setMessage(.at(wait.pane), std.fmt.bufPrint(&said, "pipe: {d} bytes of output in all, past {d}: the text is left as it was", .{ total_output, selection_pipe.max_total_stdout_bytes }) catch unreachable); // two numbers fit 128
- if (i > 0 and cut.lo < ops[i - 1].q1) return p.setMessage(.at(wait.pane), "pipe: the selections overlap: the text is left as it was");
+ return p.setMessage(wait.pane, std.fmt.bufPrint(&said, "pipe: {d} bytes of output in all, past {d}: the text is left as it was", .{ total_output, selection_pipe.max_total_stdout_bytes }) catch unreachable); // two numbers fit 128
+ if (i > 0 and cut.lo < ops[i - 1].q1) return p.setMessage(wait.pane, "pipe: the selections overlap: the text is left as it was");
ops[i] = .{ .q0 = @intCast(cut.lo), .q1 = @intCast(cut.hi), .text = output };
}
- const replacement = sam.apply(p.gpa, content, ops[0..n]) catch |err| return p.reportError(.at(wait.pane), "pipe", err);
+ const replacement = sam.apply(p.gpa, content, ops[0..n]) catch |err| return p.reportError(wait.pane, "pipe", err);
var new_ranges: [panes.Text.max_selections]modal.Selection = undefined;
var delta: isize = 0;
for (ops[0..n], wait.ranges[0..n], new_ranges[0..n]) |op, range, *moved| {
@@ -316,10 +316,10 @@ pub fn pipeResponse(
// One async request is one history transaction, even at 64 cursors.
edit.pushUndo(p.editor(), t) catch |err| {
p.gpa.free(replacement);
- return p.reportError(.at(wait.pane), "pipe", err);
+ return p.reportError(wait.pane, "pipe", err);
};
- edit.setEditText(p.editor(), t, replacement) catch |err| return p.reportError(.at(wait.pane), "pipe", err);
- const now = edit.flatSurface(p.editor(), t) catch |err| return p.reportError(.at(wait.pane), "pipe", err);
+ edit.setEditText(p.editor(), t, replacement) catch |err| return p.reportError(wait.pane, "pipe", err);
+ const now = edit.flatSurface(p.editor(), t) catch |err| return p.reportError(wait.pane, "pipe", err);
t.setRanges(p.settings.tab, now, new_ranges[0..n], &.{}, wait.primary, wait.explicit);
t.select = false;
t.show(p.settings.tab);
diff --git a/core/Query.zig b/core/Query.zig
index 663095b0..3a5aa5f8 100644
--- a/core/Query.zig
+++ b/core/Query.zig
@@ -1,5 +1,5 @@
-//! The query pane: the one pane search is. A +Search attached under the
-//! pane that asked (its owner, layout.zig "Attached panes"), born at a
+//! The query pane: the one pane search is. A +Search docked under the
+//! pane that asked (its owner, layout.zig "Docked panes"), born at a
//! fixed height, whose body's line 1 is the query, editable text, and
//! whose rows below are made live from a source, read-only while live.
//! Line 1's first word names the source: `/pat` the owner's text (smart-
@@ -18,7 +18,7 @@
//! text: B3 on one looks, B2 on line 1 runs it again. Wherever a row points into
//! an open pane's text, that pane's places (Places.zig) show the set:
//! tints, rail ticks, the current one selected. A row pointing at a file
-//! no pane shows is shown in the +Preview attached under this pane; Enter
+//! no pane shows is shown in the +Preview docked under this pane; Enter
//! promotes the preview to the file's pane where it stands.
//!
//! Nothing moves while you type: the pane never closes, resizes or
@@ -319,7 +319,7 @@ fn create(p: *Pardes, owner_id: usize, line: []const u8, source: Source) ?usize
preview_rows = spare -| want;
}
}
- if (!layout.attachFrom(p, owner_id, free, want, owner_id)) {
+ if (!layout.dockFrom(p, owner_id, free, want, owner_id)) {
// An owner too short to give a query pane its rows: placed as any
// new pane is, the one place a search moves another pane.
layout.placeNew(p, owner_id, owner_id, free, .doc);
@@ -1635,7 +1635,7 @@ fn makePreview(p: *Pardes, qid: usize, rows: u16, giver: usize) ?usize {
return null;
};
layout.compute(p);
- if (!layout.attachFrom(p, qid, free, rows, giver)) {
+ if (!layout.dockFrom(p, qid, free, rows, giver)) {
p.removePane(free, qid) catch |err| p.reportError(.at(qid), "query", err);
return null;
}
@@ -1723,7 +1723,7 @@ fn displayPreview(p: *Pardes, qid: usize, path: []const u8, at: look.Spot) void
/// The +Preview becomes the file's pane where it stands: same slot, same
/// serial, same rect, its scroll and selection as the preview left them.
/// It is a file pane from here: an empty undo history, the Recent entry,
-/// the watch, a file's tag; and a pane of its own, no longer attached (it
+/// the watch, a file's tag; and a pane of its own, no longer docked (it
/// stays when its query pane goes).
fn promote(p: *Pardes, qid: usize, id: usize) void {
const pane = p.panes[id] orelse return;
@@ -1902,10 +1902,10 @@ pub fn cancel(p: *Pardes, id: usize) void {
if (owner_id) |oid| p.view().active = oid;
return;
}
- // Attached, its rows go back to its owner; else to its own column's.
- const attached = layout.ownerOf(p, id) != null;
+ // Docked, its rows go back to its owner; else to its own column's.
+ const docked = layout.ownerOf(p, id) != null;
if (owner_id) |oid| {
- p.removePane(id, if (attached) oid else null) catch |err| p.reportError(.at(id), "query", err);
+ p.removePane(id, if (docked) oid else null) catch |err| p.reportError(.at(id), "query", err);
p.view().active = oid;
if (layout.findPane(p, oid)) |at| p.setActiveColumn(at.col);
} else p.removePane(id, null) catch |err| p.reportError(.at(id), "query", err);
diff --git a/core/Store.zig b/core/Store.zig
index 82e3c5bf..ac9387cb 100644
--- a/core/Store.zig
+++ b/core/Store.zig
@@ -28,7 +28,7 @@ pub const Closed = struct {
/// brought back, it takes them from that pane alone.
gainer: u32,
below: bool,
- /// The pane it was attached to, by serial (0 none).
+ /// The pane it was docked to, by serial (0 none).
owner: u32,
rows: u16,
/// What its Panes row shows: its file, command or directory.
@@ -78,7 +78,7 @@ pub fn clone(s: *const Store, gpa: std.mem.Allocator) Store {
// ---- the closed panes ----
/// Pane `id`, about to close, kept: what it was (a one-pane Dump) and
-/// where (its column, its rows, what it was attached to). Null for a pane
+/// where (its column, its rows, what it was docked to). Null for a pane
/// that is no pane of the user's: a query pane, a preview, one carried to
/// another window (`away`), one made and refused in the same step (never
/// announced), or one whose dump fails or is too big. `close` finishes it
@@ -186,7 +186,7 @@ pub fn closedBySerial(s: *const Store, serial: u32) ?*Closed {
}
/// Closed pane `serial` of this session made again, where it was: beside
-/// the pane its rows went to, taking them from that pane alone (attached
+/// the pane its rows went to, taking them from that pane alone (docked
/// again to its owner when that is still open), else placed as a new pane
/// from `from`. False when it is not this session's, or its dump will not
/// load; the keyboard on it otherwise.
@@ -204,7 +204,7 @@ pub fn reopen(s: *Store, p: *Pardes, serial: u32, from: usize) bool {
const owner = if (place.owner != 0) p.paneBySerial(place.owner) else null;
const gainer = if (place.gainer != 0) p.paneBySerial(place.gainer) else null;
const placed = if (owner) |o|
- layout.attachFrom(p, o, free, place.rows, o)
+ layout.dockFrom(p, o, free, place.rows, o)
else if (gainer) |g|
layout.giveBack(p, free, g, place.below, place.rows)
else
diff --git a/core/builtins.zig b/core/builtins.zig
index 894478fd..7ad70e7c 100644
--- a/core/builtins.zig
+++ b/core/builtins.zig
@@ -1017,11 +1017,11 @@ pub const Del = struct {
// acme's Del asks winclean first (exec.c del): unsaved text is warned
// about once, and the same Del again, nothing edited since, closes.
if (warnModifiedIn(c, .Del, .{ .pane = c.id })) return;
- // An attachment's rows go back to its owner: nothing to ask.
+ // A docked pane's rows go back to its owner: nothing to ask.
if (layout.ownerOf(c.p, c.id)) |owner| return c.p.removePane(c.id, owner) catch |err| c.p.reportError(.at(c.id), "close", err);
const at = layout.findPane(c.p, c.id);
const above = if (at) |f| layout.expandedNeighbor(c.p, f.col, f.idx, .above) else null;
- // An owner's attachments close with it: below is past them.
+ // An owner's docked panes close with it: below is past them.
const below = if (at) |f| layout.expandedNeighbor(c.p, f.col, layout.groupEnd(c.p, f.col, f.idx) - 1, .below) else null;
const to: ?usize = if (std.mem.eql(u8, side, "k"))
above orelse below
diff --git a/core/colors.zig b/core/colors.zig
index 4825ea3f..7e692fe5 100644
--- a/core/colors.zig
+++ b/core/colors.zig
@@ -8,7 +8,6 @@ const Color = @import("surface.zig").Color;
const FontRole = @import("surface.zig").FontRole;
const config = @import("config.zig");
const platform = pardes.platform;
-const MAX_PANES = pardes.MAX_PANES;
const BOX_H = pardes.BOX_H;
const Pardes = pardes.Pardes;
@@ -630,7 +629,7 @@ pub fn requestThemeFile(p: *Pardes, id: usize, argument: []const u8) void {
p.reportError(.at(id), "theme file", error.PathTooLong);
return;
}
- p.theme_file_pane = @intCast(@min(id, MAX_PANES - 1));
+ p.theme_file_pane = .at(id);
const generation = nextThemeFileGeneration(p);
p.emit(.{ .theme_file = .{ .generation = generation, .on = true } });
}
@@ -645,7 +644,7 @@ pub fn loadedThemeFile(p: *const Pardes) ?[]const u8 {
pub const ThemeFileRequest = struct {
path: []const u8,
- pane: u8,
+ pane: pardes.Pane.Id,
};
/// Borrow the current request while a native host performs its synchronous
@@ -673,7 +672,7 @@ fn themeFileFailure(p: *Pardes, request: ThemeFileRequest, why: []const u8) void
var said: pardes.Kind.Buf(520) = .{};
var cut: [200]u8 = undefined;
const path = @import("ninep/tree.zig").fitErr(request.path, &cut);
- p.reportFailure(request.pane, said.print("theme file {s}: {s}", .{ path, why }));
+ p.reportFailure(request.pane.index(), said.print("theme file {s}: {s}", .{ path, why }));
revertThemeFile(p);
}
diff --git a/core/echo.zig b/core/echo.zig
index 40200696..f35c9f9d 100644
--- a/core/echo.zig
+++ b/core/echo.zig
@@ -614,7 +614,7 @@ const Rig = struct {
for (msgs.items) |m| gpa.free(m);
msgs.deinit(gpa);
}
- try g.screens.flush(g.a.core, g.peer, g.r.view, &msgs);
+ try g.screens.flush(g.a.core, g.peer, &msgs);
for (msgs.items) |m| if (g.r.screen(m)) |reply| {
_ = try g.screens.take(g.a.core, g.peer, reply);
};
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);
diff --git a/core/lsp/Ask.zig b/core/lsp/Ask.zig
index 376b093d..500f02b5 100644
--- a/core/lsp/Ask.zig
+++ b/core/lsp/Ask.zig
@@ -29,7 +29,7 @@ last: ?struct { kind: lsp.Kind, arg: Effect.Buf(128), serial: u32, offset: u32 }
wait: ?struct {
id: u32,
kind: lsp.Kind,
- pane: usize,
+ pane: Pane.Id,
serial: u32,
revision: u32,
arg: Effect.Buf(128),
@@ -103,7 +103,7 @@ pub fn lspRequest(p: *Pardes, asked: usize, kind: lsp.Kind, arg_in: []const u8)
p.lsp_ask.wait = .{
.id = p.lsp_ask.seq,
.kind = kind,
- .pane = id,
+ .pane = .at(id),
.serial = pane.serial,
.revision = if (pane.file) |f| f.revision else 0,
.arg = .from(arg),
@@ -270,24 +270,25 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void {
const w = p.lsp_ask.wait orelse return;
if (w.id != id) return; // superseded by a newer press, or the pane died
p.lsp_ask.wait = null;
- const pane = p.panes[w.pane] orelse return;
+ const asked = w.pane.index();
+ const pane = p.panes[asked] orelse return;
if (pane.serial != w.serial) return;
// Whatever fails from here -- no answer, nothing found, no room for
// its pane -- fails a 9P write that asked it too.
const failures = p.fs.failures;
- defer if (p.fs.failures != failures) p.noteLateFailure(.at(w.pane));
+ defer if (p.fs.failures != failures) p.noteLateFailure(w.pane);
var said: pardes.Kind.Buf(256) = .{};
const rows = response orelse
- return p.reportFailure(w.pane, said.print("{s}: the language server did not answer", .{lspWord(w.kind)}));
+ return p.reportFailure(asked, said.print("{s}: the language server did not answer", .{lspWord(w.kind)}));
// A backend that cannot answer it says why (`@none <why>`).
if (std.mem.startsWith(u8, rows, "@none ")) {
const why = std.mem.trimEnd(u8, rows["@none ".len..], "\n");
- return p.reportFailure(w.pane, said.print("{s}: {s}", .{ lspWord(w.kind), why }));
+ return p.reportFailure(asked, said.print("{s}: {s}", .{ lspWord(w.kind), why }));
}
// Index's answer is its indexer's command line, run in a command
// pane (lsp_client.indexCommand).
if (w.kind == .index) {
- if (std.mem.startsWith(u8, rows, "@run ")) _ = exec.execute(p, w.pane, std.mem.trimEnd(u8, rows["@run ".len..], "\n"));
+ if (std.mem.startsWith(u8, rows, "@run ")) _ = exec.execute(p, asked, std.mem.trimEnd(u8, rows["@run ".len..], "\n"));
return;
}
if (w.kind == .rename or w.kind == .format) {
@@ -296,7 +297,7 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void {
if (applyLspEdits(p, pane, w.revision, edits)) {
var buf: pardes.Kind.Buf(64) = .{};
const verb: []const u8 = if (w.kind == .rename) "renamed" else "formatted";
- p.setMessage(.at(w.pane), buf.print("{s} {d} range(s)", .{ verb, edits.len }));
+ p.setMessage(w.pane, buf.print("{s} {d} range(s)", .{ verb, edits.len }));
}
return;
}
@@ -308,19 +309,19 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void {
}
if (rows.len == 0) {
if (w.kind == .completion and pane.body.mode == .insert and pane.body.nsel == 0 and
- pane.body.cur_row == w.row and pane.body.cur_col == w.col) edit.insertTab(p.editor(), &pane.body) catch |err| return p.reportError(.at(w.pane), "complete", err);
+ pane.body.cur_row == w.row and pane.body.cur_col == w.col) edit.insertTab(p.editor(), &pane.body) catch |err| return p.reportError(w.pane, "complete", err);
// Nothing found fails, but for a file with no diagnostics,
// which is no failure, and a completion's Tab.
const none: ?[]const u8 = switch (w.kind) {
.completion, .format => null,
.rename => "nothing here to rename",
- .diagnostics, .workspace_diagnostics => return p.setMessage(.at(w.pane), said.print("{s}: none", .{lspWord(w.kind)})),
+ .diagnostics, .workspace_diagnostics => return p.setMessage(w.pane, said.print("{s}: none", .{lspWord(w.kind)})),
.incoming_calls => "callers not found",
.outgoing_calls => "callees not found",
.hover => "nothing to show: not found",
else => "not found",
};
- if (none) |text| p.reportFailure(w.pane, said.print("{s}: {s}", .{ lspWord(w.kind), text }));
+ if (none) |text| p.reportFailure(asked, said.print("{s}: {s}", .{ lspWord(w.kind), text }));
return;
}
@@ -330,7 +331,7 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void {
const ln = std.mem.trimEnd(u8, rows, "\n");
const place = ln[0..panes.Output.location(ln).end];
p.look_missed = false;
- look.lookAt(p, w.pane, place);
+ look.lookAt(p, asked, place);
// The one place is the text's places, as a list's would be: tinted,
// and n and N step it.
const spot = look.parsePathLine(place);
@@ -367,16 +368,16 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void {
};
if (listed) |source| if (pane.file != null and pane.query == null and !p.exec_header) {
p.fs.refilled = null;
- panes.Query.fillList(p, w.pane, source, rows);
+ panes.Query.fillList(p, asked, source, rows);
p.fs.lsp_result = if (panes.Query.ofOwner(p, pane.serial)) |qid| p.panes[qid].?.serial else null;
return;
};
const dir = if (pane.file) |f| panes.Dir.ofName(f.path) else pane.cwdSlice();
- const content = p.gpa.dupe(u8, rows) catch |err| return p.reportError(.at(w.pane), lspWord(w.kind), err);
+ const content = p.gpa.dupe(u8, rows) catch |err| return p.reportError(w.pane, lspWord(w.kind), err);
const serial_before = p.next_serial;
p.fs.refilled = null;
- panes.Output.fillResults(p, w.pane, dir, from, w.arg.slice(), content, null) catch |err| {
- p.reportError(.at(w.pane), "language response", err);
+ panes.Output.fillResults(p, asked, dir, from, w.arg.slice(), content, null) catch |err| {
+ p.reportError(w.pane, "language response", err);
return;
};
if (rows.len >= 1 << 20) memory.trim();
@@ -390,7 +391,7 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void {
if (p.next_serial != serial_before) {
const report_rows = std.mem.count(u8, result_pane.file.?.content, "\n");
const wanted: u16 = @intCast(@min(v.screen_h, report_rows + result_pane.tag_rows));
- layout.givePaneRows(p, result_id, wanted, w.pane);
+ layout.givePaneRows(p, result_id, wanted, asked);
}
look.focusPaneLine(p, result_id, .{ .line = 1, .col = 1 }, .keep);
break;
@@ -401,7 +402,7 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void {
// Rows that only name a file the server left alone (lsp_client
// renameEdits) are no edits.
const unrenamed = std.mem.count(u8, rows, ", which the server did not rename\n");
- p.setMessage(.at(w.pane), if (unrenamed > 0)
+ p.setMessage(w.pane, if (unrenamed > 0)
said_buf.print("Rename: previewed, not applied: the server renamed in this file only, and {d} other open file(s) say the name", .{unrenamed})
else
said_buf.print("Rename: {d} edit(s) across files, previewed, not applied", .{nrows}));
@@ -413,7 +414,7 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void {
.line = @as(usize, @intCast(@max(0, w.row))) + 1,
.col = @as(usize, @intCast(@max(0, w.col))) + 1,
});
- _ = look.jumpResult(p, w.pane, row);
+ _ = look.jumpResult(p, asked, row);
}
}
diff --git a/core/panes.zig b/core/panes.zig
index 68304437..174af241 100644
--- a/core/panes.zig
+++ b/core/panes.zig
@@ -147,10 +147,10 @@ pub const Pane = struct {
vweight: f32 = 1,
/// A folded pane keeps its expansion weight, but occupies only its tag row.
collapsed: bool = false,
- /// The serial of the pane this one is attached to, its owner: a query
+ /// The serial of the pane this one is docked to, its owner: a query
/// pane or its +Preview sits right under its owner in the owner's
/// column, takes its rows from the owner alone, and moves, folds and
- /// closes with it (layout.zig, "Attached panes"). An owner that is
+ /// closes with it (layout.zig, "Docked panes"). An owner that is
/// gone, or a pane no longer right under its owner's group, leaves it
/// an ordinary pane (layout.keepGroups).
docked_to: ?u32 = null,
@@ -1476,14 +1476,14 @@ pub fn paneDir(pane: *const Pane) []const u8 {
pub fn removePane(p: *Pardes, id: usize, to: ?usize) error{OutOfMemory}!void {
const v = p.view();
const pane = p.panes[id] orelse return;
- // What is attached to it closes with it, first, each giving its rows
+ // What is docked to it closes with it, first, each giving its rows
// back to it: then its rows, theirs among them, go where a pane's go.
for (0..p.panes.len) |k| if (p.panes[k]) |other| if (k != id and other.docked_to == pane.serial) {
if (layout.ownerOf(p, k) != id) continue;
try p.removePane(k, id);
layout.compute(p);
};
- // An attachment's rows go back to its owner and nobody else.
+ // A docked pane's rows go back to its owner and nobody else.
const owner = layout.ownerOf(p, id);
const place = layout.findPane(p, id);
const emptied = if (place) |f| (if (v.cols[f.col].n == 1) f.col else null) else null;
diff --git a/core/replica.zig b/core/replica.zig
index 0b554ed5..de58da94 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -157,7 +157,7 @@ pub const Authority = struct {
seq: u32 = 0,
/// Each client's view (core/views.zig): its own layout, focus and
/// cursors over the session's text. The first client has the session's.
- view_of: [64]u8 = @splat(0),
+ view_of: [64]Pardes.View.Id = @splat(.at(0)),
/// Steps of its own taken since the last unit (`output`): one unit,
/// `pending`, sent before the next input it steps and at a frame.
batched: u32 = 0,
@@ -279,7 +279,7 @@ pub const Authority = struct {
};
a.core.pump(a.host) catch {};
was.end();
- a.view_of[client] = k.index();
+ a.view_of[client] = k;
a.seq += 1;
return .{ .view = k.index(), .unit = try a.unit(0, a.seq) };
}
@@ -296,7 +296,7 @@ pub const Authority = struct {
const again = if (back) |v| a.core.rejoinView(.at(v)) else false;
const k = (if (again) back else if (a.core.openView()) |o| o.index() else null) orelse return null;
a.core.undrawn |= @as(u8, 1) << @intCast(k);
- a.view_of[client] = k;
+ a.view_of[client] = .at(k);
a.seq += 1;
const u = try a.unit(0, a.seq);
var blobs: std.ArrayListUnmanaged(walk.Deferred) = .empty;
@@ -322,8 +322,8 @@ pub const Authority = struct {
std.debug.assert(a.batched == 0);
const was = Stepping.begin(&a.t, null);
const k = a.view_of[client];
- a.core.undrawn &= ~(@as(u8, 1) << @intCast(k));
- if (again) a.core.awayView(.at(k)) else a.core.closeView(.at(k));
+ a.core.undrawn &= ~(@as(u8, 1) << @intCast(k.index()));
+ if (again) a.core.awayView(k) else a.core.closeView(k);
was.end();
a.seq += 1;
return a.unit(0, a.seq);
@@ -333,7 +333,7 @@ pub const Authority = struct {
pub fn closeView(a: *Authority, client: u16) ![]const u8 {
std.debug.assert(a.batched == 0);
const was = Stepping.begin(&a.t, null);
- a.core.closeView(.at(a.view_of[client]));
+ a.core.closeView(a.view_of[client]);
was.end();
a.seq += 1;
return a.unit(0, a.seq);
@@ -345,7 +345,7 @@ pub const Authority = struct {
std.debug.assert(a.batched == 0);
const in = parseInput(msg) orelse return error.BadInput;
const was = Stepping.begin(&a.t, null);
- a.core.toView(.at(a.view_of[in.client]));
+ a.core.toView(a.view_of[in.client]);
a.t.stamp = stampOf(in);
a.core.update(in.event);
a.core.step();
@@ -450,7 +450,7 @@ pub const Screens = struct {
/// What `peer` is owed of every terminal, each a message onto `out`
/// (owned): nothing for one it has as it is, or with `bound` in flight.
- pub fn flush(s: *Screens, core: *Pardes, peer: u16, _: u8, out: *std.ArrayListUnmanaged([]u8)) !void {
+ pub fn flush(s: *Screens, core: *Pardes, peer: u16, out: *std.ArrayListUnmanaged([]u8)) !void {
const t0 = nowNs();
defer s.encode_ns += nowNs() - t0;
for (core.panes, 0..) |slot, id| {
@@ -1667,7 +1667,7 @@ pub const Peer = struct {
peers: *Peers,
fd: c_int,
id: u16,
- view: u8,
+ view: Pardes.View.Id,
/// Its process (its socket's peer), for `--ps`; 0 not known.
pid: libc.pid_t = 0,
/// Its bye said it joins again for its view (a divergence's rejoin):
@@ -2201,7 +2201,7 @@ pub const Peers = struct {
// The terminals as this step reads them, then the step, the rows
// it read, its unit (part B terminal notes' order).
ps.screensOut(core, .flush);
- core.toView(.at(peer.view));
+ core.toView(peer.view);
ps.t.stamp = stampOf(in);
core.update(in.event);
core.step();
@@ -2239,7 +2239,7 @@ pub const Peers = struct {
ps.msgs.clearRetainingCapacity();
}
(switch (what) {
- .flush => ps.screens.flush(core, peer.sid, peer.view, &ps.msgs),
+ .flush => ps.screens.flush(core, peer.sid, &ps.msgs),
.fill => ps.screens.fill(core, peer.sid, &ps.msgs),
}) catch return;
if (what == .flush) if (ps.flushed) |h| h.f(h.ctx, core, &ps.screens);
@@ -2325,12 +2325,12 @@ pub const Peers = struct {
core.gpa.free(bytes);
return daemon.refuseReplica(fd, "out of memory");
};
- peer.* = .{ .peers = ps, .fd = fd, .id = ps.next_id, .view = k, .limit = lag_max, .dump = bytes, .blobs = blobs, .dump_gpa = core.gpa };
+ peer.* = .{ .peers = ps, .fd = fd, .id = ps.next_id, .view = .at(k), .limit = lag_max, .dump = bytes, .blobs = blobs, .dump_gpa = core.gpa };
ps.next_id +%= 1;
if (ps.next_id == 0) ps.next_id = 1;
// The session's digest as dumped, for the joiner to check its load by.
const digest = tape.digestOf(core);
- peer.welcome_len = (wire.encodeServer(&peer.welcome, .{ .welcome = .{ .pid = @intCast(libc.getpid()), .session = ps.name[0..@min(ps.name.len, wire.max_name)], .client = peer.id, .view = .at(k), .dump_len = whole, .gmtoff = gmtoff(), .digest = digest, .semantics = wire.semantics, .blobs = @intCast(blobs.items.len) } }) catch unreachable).len;
+ peer.welcome_len = (wire.encodeServer(&peer.welcome, .{ .welcome = .{ .pid = @intCast(libc.getpid()), .session = ps.name[0..@min(ps.name.len, wire.max_name)], .client = peer.id, .view = peer.view, .dump_len = whole, .gmtoff = gmtoff(), .digest = digest, .semantics = wire.semantics, .blobs = @intCast(blobs.items.len) } }) catch unreachable).len;
if (ps.threads) peer.writer = std.Thread.spawn(.{}, Peer.writeLoop, .{peer}) catch null;
if (ps.threads) peer.reader = std.Thread.spawn(.{}, Peer.readLoop, .{peer}) catch null;
if (ps.threads and (peer.writer == null or peer.reader == null)) {
@@ -2359,7 +2359,7 @@ pub const Peers = struct {
log.info("client {d} left '{s}'", .{ peer.id, ps.name });
ps.tellClients();
ps.screens.dropPeer(peer.sid);
- core.undrawn &= ~(@as(u8, 1) << @intCast(peer.view));
+ core.undrawn &= ~(@as(u8, 1) << @intCast(peer.view.index()));
ps.closeViewOf(core, peer, peer.again);
if (ps.count() == 0) core.unattended = ps.detached;
if (ps.count() == 0 and peer.close and daemon.sessionState() == .pair) ps.closed = true;
@@ -2374,7 +2374,7 @@ pub const Peers = struct {
/// session no one else watches leaves the session its layout, for a
/// client that comes after to find.
fn closeViewOf(ps: *Peers, core: *Pardes, peer: *Peer, again: bool) void {
- if (again) core.awayView(.at(peer.view)) else if (ps.count() == 0 and ps.detached) core.leaveView(.at(peer.view)) else core.closeView(.at(peer.view));
+ if (again) core.awayView(peer.view) else if (ps.count() == 0 and ps.detached) core.leaveView(peer.view) else core.closeView(peer.view);
}
/// Its threads ended and joined, its link closed.
@@ -2466,7 +2466,7 @@ pub const Peers = struct {
/// Detach typed in client view `k`'s: told it left the session running
/// (`left`), its last word; the client goes, and its reader says so.
pub fn detach(ps: *Peers, k: u8) bool {
- for (ps.list) |slot| if (slot) |peer| if (peer.view == k) {
+ for (ps.list) |slot| if (slot) |peer| if (peer.view.index() == k) {
daemon.keepSession();
var out: [wire.max_name + 8]u8 = undefined;
peer.last(wire.encodeServer(&out, .{ .left = ps.name[0..@min(ps.name.len, wire.max_name)] }) catch unreachable);
@@ -2504,7 +2504,7 @@ pub const Peers = struct {
fn drop(ps: *Peers, core: *Pardes, again: bool) void {
for (&ps.list) |*slot| if (slot.*) |peer| {
slot.* = null;
- core.undrawn &= ~(@as(u8, 1) << @intCast(peer.view));
+ core.undrawn &= ~(@as(u8, 1) << @intCast(peer.view.index()));
ps.closeViewOf(core, peer, again);
ps.screens.dropPeer(peer.sid);
ps.letGo(peer);
@@ -3470,7 +3470,7 @@ fn deliver(a: *Authority, screens: *Screens, peer: u16, r: *Replica, comptime wh
msgs.deinit(gpa);
}
switch (what) {
- .flush => try screens.flush(a.core, peer, r.view, &msgs),
+ .flush => try screens.flush(a.core, peer, &msgs),
.fill => {
try screens.fill(a.core, peer, &msgs);
screens.filled(a.core);
@@ -3503,7 +3503,7 @@ fn farJoinOnce(ps: *Peers, core: *Pardes, have: ?*Have) !Joined {
var whole = state.len;
for (blobs.items) |b| whole += b.bytes.len;
const peer = try ps.gpa.create(Peer);
- peer.* = .{ .peers = ps, .fd = fds[0], .id = 1, .view = 0, .dump = state, .blobs = blobs, .dump_gpa = core.gpa };
+ peer.* = .{ .peers = ps, .fd = fds[0], .id = 1, .view = .at(0), .dump = state, .blobs = blobs, .dump_gpa = core.gpa };
peer.welcome_len = (wire.encodeServer(&peer.welcome, .{ .welcome = .{ .pid = 1, .session = "t", .dump_len = whole, .blobs = @intCast(blobs.items.len) } }) catch unreachable).len;
const Serve = struct {
fn run(p: *Peer) void {
@@ -5159,7 +5159,7 @@ test "a client that diverged joins again for its view: kept for it meanwhile, it
const back = try joinedNow(a, 3, opened.view);
defer back.deinit();
try std.testing.expectEqual(digestOf(a), back.digest());
- a.view_of[3] = opened.view;
+ a.view_of[3] = .at(opened.view);
const u = try gpa.dupe(u8, try a.take(try back.input(.{ .key = .{ .cp = 'l', .text = "l" } })));
defer gpa.free(u);
old.confirm(u);