summaryrefslogtreecommitdiff
path: root/core/replica.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/replica.zig')
-rw-r--r--core/replica.zig103
1 files changed, 52 insertions, 51 deletions
diff --git a/core/replica.zig b/core/replica.zig
index e2775da8..c68848f2 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -233,7 +233,7 @@ pub const Authority = struct {
pub fn own(a: *Authority, ev: pardes.Event) ![]const u8 {
std.debug.assert(a.batched == 0);
const was = Stepping.begin(&a.t, null);
- a.core.toView(0);
+ a.core.toView(.at(0));
was.end();
return a.local(ev);
}
@@ -276,9 +276,9 @@ pub const Authority = struct {
};
a.core.pump(a.host) catch {};
was.end();
- a.view_of[client] = k;
+ a.view_of[client] = k.index();
a.seq += 1;
- return .{ .view = k, .unit = try a.unit(0, a.seq) };
+ return .{ .view = k.index(), .unit = try a.unit(0, a.seq) };
}
/// A client joining as `Peers.join` takes one: its view kept for it
@@ -290,8 +290,8 @@ pub const Authority = struct {
std.debug.assert(a.batched == 0);
const was = Stepping.begin(&a.t, null);
defer was.end();
- const again = if (back) |v| a.core.rejoinView(v) else false;
- const k = (if (again) back else a.core.openView()) orelse return null;
+ 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.seq += 1;
@@ -320,7 +320,7 @@ pub const Authority = struct {
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(k) else a.core.closeView(k);
+ if (again) a.core.awayView(.at(k)) else a.core.closeView(.at(k));
was.end();
a.seq += 1;
return a.unit(0, a.seq);
@@ -330,7 +330,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(a.view_of[client]);
+ a.core.closeView(.at(a.view_of[client]));
was.end();
a.seq += 1;
return a.unit(0, a.seq);
@@ -342,7 +342,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(a.view_of[in.client]);
+ a.core.toView(.at(a.view_of[in.client]));
a.t.stamp = stampOf(in);
a.core.update(in.event);
a.core.step();
@@ -1127,7 +1127,7 @@ pub const Replica = struct {
tape.beginSpeculation(&r.t);
// The time it was sent with, every time it is applied.
r.t.guess = p.guess;
- c.toView(r.view);
+ c.toView(.at(r.view));
// Input into a terminal: what reaches its program (a key in tty
// mode, a paste, a mouse report) is a pty write, the authority's,
// and stops here (phase 6 predicts its echo). The rest (pardes's
@@ -2162,7 +2162,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(peer.view);
+ core.toView(.at(peer.view));
ps.t.stamp = stampOf(in);
core.update(in.event);
core.step();
@@ -2234,8 +2234,8 @@ pub const Peers = struct {
// link's end (posted by that link's reader, microseconds after the
// bye; the redial is a dial and the daemon's hand-over later) finds
// its view not kept yet, and takes a new one.
- const back = if (joining.view) |v| core.rejoinView(v) else false;
- const k = (if (back) joining.view else core.openView()) orelse {
+ const back = if (joining.view) |v| core.rejoinView(.at(v)) else false;
+ const k = (if (back) joining.view else if (core.openView()) |o| o.index() else null) orelse {
core.unattended = ps.count() == 0 and ps.detached;
if (ps.count() == 0) ps.stop(core);
return daemon.refuseReplica(fd, "that session has as many views as it takes");
@@ -2251,7 +2251,7 @@ pub const Peers = struct {
const bytes = pardes.dump.dumpJoin(core, &blobs) catch |err| {
blobs.deinit(core.gpa);
core.undrawn &= ~(@as(u8, 1) << @intCast(k));
- core.closeView(k);
+ core.closeView(.at(k));
ps.unit(0, ps.seq);
if (ps.count() == 0) ps.stop(core);
var why: [96]u8 = undefined;
@@ -2278,13 +2278,13 @@ pub const Peers = struct {
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 = 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 = .at(k), .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)) {
ps.letGo(peer);
core.undrawn &= ~(@as(u8, 1) << @intCast(k));
- core.closeView(k);
+ core.closeView(.at(k));
ps.unit(0, ps.seq);
return;
}
@@ -2321,7 +2321,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(peer.view) else if (ps.count() == 0 and ps.detached) core.leaveView(peer.view) else core.closeView(peer.view);
+ 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));
}
/// Its threads ended and joined, its link closed.
@@ -2591,7 +2591,7 @@ fn joinOn(gpa: Allocator, fd: c_int, session: []const u8, why: []u8, have: ?*Hav
.welcome => |w| {
r.j.pid = w.pid;
r.j.client = w.client;
- r.j.view = w.view;
+ r.j.view = w.view.index();
r.j.gmtoff = w.gmtoff;
r.j.digest = w.digest;
r.j.semantics = w.semantics;
@@ -3299,7 +3299,7 @@ const TestHost = struct {
/// A host with ptys whose pump polls for a frame, as a client's does.
const PtyHost = struct {
- fn resized(_: ?*anyopaque, _: u8, _: u16, _: u16) void {}
+ fn resized(_: ?*anyopaque, _: pardes.Pane.Id, _: u16, _: u16) void {}
fn poll(_: ?*anyopaque) void {}
const vtable: pardes.Host.VTable = .{ .watched = TestHost.watched, .pty_resize = resized, .poll_frame = poll };
fn host() pardes.Host {
@@ -3736,7 +3736,7 @@ test "a delta applied under a speculation outlives its rollback: the terminal st
for (0..3) |round| {
// The shell prints: its unit rolls the replica back and applies the
// key again; then its delta lands, under the new copy.
- for (0..40) |i| a.output(.{ .output = .{ .pane = shell, .bytes = try std.fmt.bufPrint(&line, "round {d} line {d}\r\n", .{ round, i }) } });
+ for (0..40) |i| a.output(.{ .output = .{ .pane = .at(shell), .bytes = try std.fmt.bufPrint(&line, "round {d} line {d}\r\n", .{ round, i }) } });
r.confirm((try a.pending()).?);
r.settle();
try std.testing.expect(r.copy.held);
@@ -3758,7 +3758,7 @@ test "a delta applied under a speculation outlives its rollback: the terminal st
r.confirm(try a.local(.{ .focus = false }));
_ = try pardes.edit.shellRows(r.core(), r.core().panes[shell].?);
try key(r, 'x', &sent);
- for (0..40) |i| a.output(.{ .output = .{ .pane = shell, .bytes = try std.fmt.bufPrint(&line, "last line {d}\r\n", .{i}) } });
+ for (0..40) |i| a.output(.{ .output = .{ .pane = .at(shell), .bytes = try std.fmt.bufPrint(&line, "last line {d}\r\n", .{i}) } });
r.confirm((try a.pending()).?);
r.settle();
try deliver(a, &screens, peer, r, .flush);
@@ -3882,7 +3882,7 @@ test "a terminal sized again by a client's key: the step reads the grid it had,
// History the replica holds as holes, of lines a narrow grid wraps in
// two, which a wider one unwraps.
var line: [96]u8 = undefined;
- for (0..60) |i| a.output(.{ .output = .{ .pane = shell, .bytes = try std.fmt.bufPrint(&line, "{d:0>4} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n", .{i}) } });
+ for (0..60) |i| a.output(.{ .output = .{ .pane = .at(shell), .bytes = try std.fmt.bufPrint(&line, "{d:0>4} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n", .{i}) } });
r.confirm((try a.pending()).?);
// Out of terminal mode in the session's view, which sizes it; then a
// client's own view (a copy of it), wider: its first key sizes the
@@ -3923,7 +3923,7 @@ test "a terminal sized again by a client's key: the step reads the grid it had,
try deliver(a, &screens, peer, r, .flush);
{
const was = Stepping.begin(&a.t, null);
- a.core.toView(0);
+ a.core.toView(.at(0));
a.core.update(.{ .key = .{ .cp = 'k', .text = "k" } });
a.core.step();
was.end();
@@ -3961,7 +3961,7 @@ test "pardes's own keys over a terminal's history apply at once: its view moves
a.core.view().active = shell;
r.confirm(try a.local(.{ .focus = true }));
var line: [64]u8 = undefined;
- for (0..200) |i| a.output(.{ .output = .{ .pane = shell, .bytes = try std.fmt.bufPrint(&line, "history line {d}\r\n", .{i}) } });
+ for (0..200) |i| a.output(.{ .output = .{ .pane = .at(shell), .bytes = try std.fmt.bufPrint(&line, "history line {d}\r\n", .{i}) } });
r.confirm((try a.pending()).?);
try deliver(a, &screens, peer, r, .flush);
r.settle();
@@ -3984,7 +3984,7 @@ test "pardes's own keys over a terminal's history apply at once: its view moves
// The shell prints while they wait: its unit, then its delta, which
// sets the view the authority's (at the bottom still): what was applied
// goes on top of it again.
- for (0..5) |i| a.output(.{ .output = .{ .pane = shell, .bytes = try std.fmt.bufPrint(&line, "late line {d}\r\n", .{i}) } });
+ for (0..5) |i| a.output(.{ .output = .{ .pane = .at(shell), .bytes = try std.fmt.bufPrint(&line, "late line {d}\r\n", .{i}) } });
r.confirm((try a.pending()).?);
r.settle();
try deliver(a, &screens, peer, r, .flush);
@@ -4050,7 +4050,7 @@ test "a unit kept over a copy taken ahead is never replayed over a delta that ca
a.core.view().active = shell;
r.confirm(try a.local(.{ .focus = true }));
var line: [96]u8 = undefined;
- for (0..30) |i| a.output(.{ .output = .{ .pane = shell, .bytes = try std.fmt.bufPrint(&line, "line {d} {s}\r\n", .{ i, "words of a length its own"[0 .. i % 20 + 4] }) } });
+ for (0..30) |i| a.output(.{ .output = .{ .pane = .at(shell), .bytes = try std.fmt.bufPrint(&line, "line {d} {s}\r\n", .{ i, "words of a length its own"[0 .. i % 20 + 4] }) } });
r.confirm((try a.pending()).?);
try deliver(a, &screens, peer, r, .flush);
// Out of the shell's tty mode, in the session's view: keys over its text.
@@ -4068,8 +4068,8 @@ test "a unit kept over a copy taken ahead is never replayed over a delta that ca
r.settle();
}
// The program redraws the screen: other rows where those keys read.
- a.output(.{ .output = .{ .pane = shell, .bytes = "\x1b[H\x1b[2J" } });
- for (0..30) |i| a.output(.{ .output = .{ .pane = shell, .bytes = try std.fmt.bufPrint(&line, "{d}\r\n", .{i}) } });
+ a.output(.{ .output = .{ .pane = .at(shell), .bytes = "\x1b[H\x1b[2J" } });
+ for (0..30) |i| a.output(.{ .output = .{ .pane = .at(shell), .bytes = try std.fmt.bufPrint(&line, "{d}\r\n", .{i}) } });
r.confirm((try a.pending()).?);
r.settle();
try deliver(a, &screens, peer, r, .flush);
@@ -4181,7 +4181,7 @@ test "a replica joined from a dump replays a step that opens a file's pane and s
defer a.deinit();
var words: [64]pardes.Kind.LoadedWord = undefined;
const zon = pardes.Kind.loadedOf(&Zon.ops, "/x/zon.so", @splat(9), &words);
- _ = try a.local(.{ .addon = .{ .op = .load, .pane = 0, .kind = &zon } });
+ _ = try a.local(.{ .addon = .{ .op = .load, .pane = .at(0), .kind = &zon } });
const r = try joinedNow(a, 1, 0);
defer r.deinit();
try std.testing.expectEqual(digestOf(a), r.digest());
@@ -4256,9 +4256,9 @@ test "a host's Adopt and a terminal reader's failure are inputs: a replica makes
// What tui.zig's and gui.zig's adoptShell and a failed reader do between
// steps: they wrote the core straight, and every client joined again.
const host = Stepping.begin(&a.t, null);
- const id = a.core.adoptShell().?;
+ const id = a.core.adoptShell().?.index();
try std.testing.expect(a.core.panes[id].?.isTerminal() and !a.core.panes[id].?.greet);
- a.core.readerFailed(id, error.InputOutput);
+ a.core.readerFailed(.at(id), error.InputOutput);
a.core.pump(a.host) catch {};
host.end();
a.seq += 1;
@@ -4577,7 +4577,7 @@ test "a client leaves, and one joins: what the leave queued (a terminal's resize
// It leaves: the terminal is the first view's size again, its pty's
// resize queued for the next pump; and a client joins at that boundary.
var was = Stepping.begin(&a.t, null);
- a.core.closeView(opened.view);
+ a.core.closeView(.at(opened.view));
was.end();
old.confirm(try a.unit(0, 100));
// The client left idle takes its copy ahead (Replica.ready): of a core
@@ -4587,7 +4587,7 @@ test "a client leaves, and one joins: what the leave queued (a terminal's resize
const k = a.core.openView() orelse return error.NoView;
was.end();
old.confirm(try a.unit(0, 101));
- const joiner = try joinedNow(a, 3, k);
+ const joiner = try joinedNow(a, 3, k.index());
defer joiner.deinit();
try std.testing.expectEqual(digestOf(a), joiner.digest());
// The next pump's unit, every client's.
@@ -4614,13 +4614,13 @@ test "a client that diverged joins again for its view: kept for it meanwhile, it
const made = a.core.view().active;
// Its bye says it joins again: its view is kept, as every replica keeps it.
var was = Stepping.begin(&a.t, null);
- a.core.awayView(opened.view);
+ a.core.awayView(.at(opened.view));
was.end();
old.confirm(try a.unit(0, 100));
try agrees(a, old);
// Back for it: its own, its pane in it, in the dump it loads.
was = Stepping.begin(&a.t, null);
- try std.testing.expect(a.core.rejoinView(opened.view));
+ try std.testing.expect(a.core.rejoinView(.at(opened.view)));
was.end();
old.confirm(try a.unit(0, 101));
const back = try joinedNow(a, 3, opened.view);
@@ -4710,7 +4710,7 @@ test "a step that reads a terminal's rows as the core keeps them sends a new cli
} else return error.NoShell;
a.core.view().active = shell;
var line: [64]u8 = undefined;
- for (0..60) |i| a.output(.{ .output = .{ .pane = shell, .bytes = try std.fmt.bufPrint(&line, "line {d} of the shell's history\r\n", .{i}) } });
+ for (0..60) |i| a.output(.{ .output = .{ .pane = .at(shell), .bytes = try std.fmt.bufPrint(&line, "line {d} of the shell's history\r\n", .{i}) } });
const out = try gpa.dupe(u8, (try a.pending()).?);
defer gpa.free(out);
for ([_]*Replica{ r1, r2 }) |r| r.confirm(out);
@@ -4740,7 +4740,7 @@ test "a replica with no code for a kind whose state is not plain shows its pane
// replica's core takes the kind's words, never its code.
var words: [64]pardes.Kind.LoadedWord = undefined;
const counter = pardes.Kind.loadedOf(&Counter.ops, "/x/counter.so", @splat(7), &words);
- r.confirm(try a.local(.{ .addon = .{ .op = .load, .pane = 0, .kind = &counter } }));
+ r.confirm(try a.local(.{ .addon = .{ .op = .load, .pane = .at(0), .kind = &counter } }));
r.confirm(try a.local(.{ .command = "Counter" }));
try std.testing.expect(r.core().kinds.ops[r.core().kinds.n - 1] == null);
try std.testing.expect(try shows(r.core(), "addon counter 1 does not run in this client"));
@@ -4798,7 +4798,7 @@ test "a kind's place moved in a step of another view's: a replica's key that rea
defer r.deinit();
var words: [64]pardes.Kind.LoadedWord = undefined;
const placed = pardes.Kind.loadedOf(&Placed.ops, "/x/placed.so", @splat(7), &words);
- r.confirm(try a.local(.{ .addon = .{ .op = .load, .pane = 0, .kind = &placed } }));
+ r.confirm(try a.local(.{ .addon = .{ .op = .load, .pane = .at(0), .kind = &placed } }));
// The replica's view opens the kind's pane, and an Esc goes back to
// the file (Last): view 0 has the file.
const own = try a.openView(1);
@@ -4852,7 +4852,7 @@ test "a client joined from a dump numbers a kind's next job as the session does"
defer a.deinit();
var words: [64]pardes.Kind.LoadedWord = undefined;
const jobber = pardes.Kind.loadedOf(&Jobber.ops, "/x/jobber.so", @splat(7), &words);
- _ = try a.local(.{ .addon = .{ .op = .load, .pane = 0, .kind = &jobber } });
+ _ = try a.local(.{ .addon = .{ .op = .load, .pane = .at(0), .kind = &jobber } });
_ = try a.local(.{ .command = "Jobber" });
for (0..3) |_| _ = try a.local(.{ .key = .{ .cp = 'x', .text = "x" } });
const id = a.core.view().active;
@@ -4871,7 +4871,7 @@ test "a replica's word that opens a kind's pane with no file waits for the autho
defer r.deinit();
var words: [64]pardes.Kind.LoadedWord = undefined;
const placed = pardes.Kind.loadedOf(&Placed.ops, "/x/placed.so", @splat(7), &words);
- r.confirm(try a.local(.{ .addon = .{ .op = .load, .pane = 0, .kind = &placed } }));
+ r.confirm(try a.local(.{ .addon = .{ .op = .load, .pane = .at(0), .kind = &placed } }));
// Its replica has no code for the kind: the open's outcome (its place,
// `1:0 0`) is the authority's to say.
const msg = try gpa.dupe(u8, try r.input(.{ .command = "Placed" }));
@@ -4890,7 +4890,7 @@ test "a client joined from a dump tells a kind each view's facts as the session
defer a.deinit();
var words: [64]pardes.Kind.LoadedWord = undefined;
const placed = pardes.Kind.loadedOf(&Placed.ops, "/x/placed.so", @splat(7), &words);
- _ = try a.local(.{ .addon = .{ .op = .load, .pane = 0, .kind = &placed } });
+ _ = try a.local(.{ .addon = .{ .op = .load, .pane = .at(0), .kind = &placed } });
_ = try a.local(.{ .command = "Placed" });
// A message in its pane: a band over its body, in each view.
_ = try a.local(.{ .command = "Placed x" });
@@ -4944,7 +4944,8 @@ const Asker = struct {
const BusyHost = struct {
var core: ?*Pardes = null;
var tasks: @import("selection_pipe.zig").Tasks = .{ .len = @import("selection_pipe.zig").Tasks.capacity };
- fn job(_: ?*anyopaque, pane: u8, serial: u32, token: u32) void {
+ fn job(_: ?*anyopaque, id: pardes.Pane.Id, serial: u32, token: u32) void {
+ const pane = id.index();
pardes.host_io.KindJob.start(std.testing.io, core.?, &tasks, pane, serial, token, null, never);
}
fn never(_: ?*anyopaque, j: *pardes.host_io.KindJob) void {
@@ -4962,7 +4963,7 @@ test "a kind's job answered at once inside its host's call (no worker free) is t
defer r.deinit();
var words: [64]pardes.Kind.LoadedWord = undefined;
const asker = pardes.Kind.loadedOf(&Asker.ops, "/x/asker.so", @splat(7), &words);
- r.confirm(try a.local(.{ .addon = .{ .op = .load, .pane = 0, .kind = &asker } }));
+ r.confirm(try a.local(.{ .addon = .{ .op = .load, .pane = .at(0), .kind = &asker } }));
// The client has its code (as a library of its own found by its scan).
r.core().kinds.ops[r.core().kinds.byName("asker").?] = &Asker.ops;
r.confirm(try a.local(.{ .command = "Asker" }));
@@ -4988,7 +4989,7 @@ test "a closed terminal with a kitty image brought back on a client: its image d
} else return error.NoShell;
// A 2x2 picture in RGB (f=24): drawn, the emulator keeps it as RGBA
// of its own (TerminalImages.converted).
- a.output(.{ .output = .{ .pane = shell, .bytes = "\x1b_Ga=T,i=7,f=24,s=2,v=2;ESIzESIzESIzESIz\x1b\\" } });
+ a.output(.{ .output = .{ .pane = .at(shell), .bytes = "\x1b_Ga=T,i=7,f=24,s=2,v=2;ESIzESIzESIzESIz\x1b\\" } });
r.confirm((try a.pending()).?);
// Closed and brought back: the client loads the session's dump of it,
// its image with it.
@@ -5041,7 +5042,7 @@ test "a far client's own Del of a pane whose kind's state is not plain, rolled b
defer a.deinit();
var words: [64]pardes.Kind.LoadedWord = undefined;
const counter = pardes.Kind.loadedOf(&Counter.ops, "/x/counter.so", @splat(7), &words);
- _ = try a.local(.{ .addon = .{ .op = .load, .pane = 0, .kind = &counter } });
+ _ = try a.local(.{ .addon = .{ .op = .load, .pane = .at(0), .kind = &counter } });
_ = try a.local(.{ .command = "Counter" });
// Joined from the dump: the kind's pane is a line here (no code), its
// slot the dump's.
@@ -5099,7 +5100,7 @@ const SeenHost = struct {
fn setClipboard(ctx: ?*anyopaque, _: []const u8) void {
const h = of(ctx);
h.yanked += 1;
- if (h.tell) h.core.?.setMessage(h.core.?.view().active, "yanked");
+ if (h.tell) h.core.?.setMessage(.at(h.core.?.view().active), "yanked");
}
fn readClipboard(ctx: ?*anyopaque) void {
of(ctx).asked += 1;
@@ -5108,7 +5109,7 @@ const SeenHost = struct {
of(ctx).linked += 1;
}
fn watchTheme(_: ?*anyopaque, _: u32, _: bool) void {}
- fn watchFile(_: ?*anyopaque, _: u8, _: []const u8, _: bool, _: pardes.WatchMode) void {}
+ fn watchFile(_: ?*anyopaque, _: pardes.Pane.Id, _: []const u8, _: bool, _: pardes.WatchMode) void {}
const vtable: pardes.Host.VTable = .{ .watched = TestHost.watched, .set_clipboard = setClipboard, .read_clipboard = readClipboard, .open_link = openLink, .watch_theme = watchTheme, .watch_file = watchFile };
fn host(h: *SeenHost) pardes.Host {
return .{ .ctx = h, .vtable = &vtable };
@@ -5263,7 +5264,7 @@ test "a client's n in a kind's pane is a motion: it steps to the next place a re
const dir = std.mem.span(@as([*:0]u8, @ptrCast(std.c.getcwd(&cwd, cwd.len) orelse return error.NoCwd)));
var words: [64]pardes.Kind.LoadedWord = undefined;
const still = pardes.Kind.loadedOf(&Still.ops, "/x/still.so", @splat(7), &words);
- _ = try a.local(.{ .addon = .{ .op = .load, .pane = 0, .kind = &still } });
+ _ = try a.local(.{ .addon = .{ .op = .load, .pane = .at(0), .kind = &still } });
// The kind's pane, its +Search (a place a row, as a kind's `/` leaves
// it), and a scratch whose words name files in the session's directory
// (as a command's output would).
@@ -5570,14 +5571,14 @@ test "a far client's every word and key, on a file's pane, a kind's and a shell'
if (slot) |pane| if (pane.isTerminal()) break id;
} else null;
if (shell) |id| {
- a.output(.{ .output = .{ .pane = @intCast(id), .bytes = "\x1b[?1004h$ " } });
+ a.output(.{ .output = .{ .pane = .at(id), .bytes = "\x1b[?1004h$ " } });
_ = (try a.pending()).?;
}
_ = try a.local(.{ .command = try std.fmt.bufPrint(&line, "Look {s}/mise.toml", .{dir}) });
const file = a.core.view().active;
var words: [64]pardes.Kind.LoadedWord = undefined;
const still = pardes.Kind.loadedOf(&Still.ops, "/x/still.so", @splat(7), &words);
- _ = try a.local(.{ .addon = .{ .op = .load, .pane = 0, .kind = &still } });
+ _ = try a.local(.{ .addon = .{ .op = .load, .pane = .at(0), .kind = &still } });
_ = try a.local(.{ .command = "Still" });
const kind = a.core.view().active;
try std.testing.expect(file != kind and a.core.panes[file].?.file != null and a.core.panes[kind].?.addon != null);
@@ -5677,7 +5678,7 @@ test "a far client's click into a shell whose program asked for focus events is
const Told = struct {
var bytes: [64]u8 = undefined;
var len: usize = 0;
- fn write(_: ?*anyopaque, _: u8, b: []const u8) void {
+ fn write(_: ?*anyopaque, _: pardes.Pane.Id, b: []const u8) void {
@memcpy(bytes[len..][0..b.len], b);
len += b.len;
}
@@ -5689,7 +5690,7 @@ test "a far client's click into a shell whose program asked for focus events is
const shell: u8 = for (a.core.panes, 0..) |slot, id| {
if (slot) |pane| if (pane.isTerminal()) break @intCast(id);
} else return error.NoShell;
- a.output(.{ .output = .{ .pane = shell, .bytes = "\x1b[?1004h$ " } });
+ a.output(.{ .output = .{ .pane = .at(shell), .bytes = "\x1b[?1004h$ " } });
_ = (try a.pending()).?;
_ = try a.local(.{ .command = "New" });
var screens: Screens = .init(gpa);