summaryrefslogtreecommitdiff
path: root/src/addon_test.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 15:58:05 -0300
committerGabriel Schneider <[email protected]>2026-11-06 17:53:43 -0300
commit75e4787be773c8cbfd2e60e59d409b9556898365 (patch)
tree7426b4184644e794c2abb2d7012461270b3ee43f /src/addon_test.zig
parent31c77aa3f259e99a9723e188b77b651e5cd31621 (diff)
downloadpardes-75e4787be773c8cbfd2e60e59d409b9556898365.tar.gz
pardes-75e4787be773c8cbfd2e60e59d409b9556898365.zip
kinds #35, the core's seam for ABI 3 (Kind.zig): each pane of a kind with view told each open view's facts by id when they change (the slot's view table, a hash a view, a stopped view told cols 0, and a step woken for a view a frame's layout changed) and ticked after, the tick's pa_tick and its prefix (placed and retag gone: the art words go on every pane of a PA_PICTURES kind from the first frame, the same bytes whichever view's step lays the tag out, by the session's first view, which was the 30 ms soak's rollbacks), found's rows the search's or appended to its +Search after, cancel's tokens dropped on every core (on the tape), a picture over PA_RASTER_MAX dropped and said once, a record of at most PA_RECORD_MAX, a Debug call over 16 ms of the kind's own (its allocations and job copies the core's) said once a site and failing --addon-test (which gains view N on|off and prints the tag the core makes), and the record §17.5's: a Restore, an Addon load and a reload read the pane's file as a Look does, a file not there a placeholder saying <path> is not here, record kept, opened by the next Look or watch of it
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/addon_test.zig')
-rw-r--r--src/addon_test.zig42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/addon_test.zig b/src/addon_test.zig
index 7b151ee6..7c9950d7 100644
--- a/src/addon_test.zig
+++ b/src/addon_test.zig
@@ -2,9 +2,11 @@
//! The addon is loaded into a session of its own (80x24, no terminal, no
//! disk, its jobs run at once, its clock virtual, starting at 1 s and moved
//! by `tick` and `settle` alone), a pane of it opened, and the script's
-//! lines run in turn, each printed with the pane's tag (the kind's own
-//! prefix), cells and placements after it; a script compares the output
-//! with what it wants as a snapshot script does (`diff`).
+//! lines run in turn, each printed with the start of the pane's tag (the
+//! kind's prefix, the core's art words, the path), cells and placements
+//! after it; a script compares the output with what it wants as a snapshot
+//! script does (`diff`). A call into the kind over its budget (16 ms in a
+//! Debug pardes) is said, and fails the script.
//!
//! open [path] a pane of the kind (the first step opens one bare)
//! key hjkl<up> keys, a character or <up> <down> <left> <right>
@@ -16,9 +18,11 @@
//! (`window CxR` says what the kind paints)
//! seed 7 what every pane's seed is made from (before open)
//! click 3 1 a left click at the body's column 3, row 1
-//! focus, blur the window takes the keyboard, or loses it
-//! graphics on|off a frontend that shows pictures, or one without
-//! them (glyph art, the start's)
+//! focus, blur the view's window takes the keyboard, or loses it
+//! graphics on|off the view's frontend shows pictures, or not
+//! (glyph art, the start's)
+//! view 2 on|off into view 2 (1 is the start's; one opened as the
+//! first is), its frontend with pictures or not
//! dump the pane's record (its length) loaded into a
//! fresh pane, which the script goes on with
//! body, ctl the pane's body, or its ctl file's read
@@ -64,6 +68,7 @@ fn run(io: std.Io, gpa: std.mem.Allocator, lib: []const u8, script_path: ?[]cons
var now: u64 = std.time.ns_per_s;
p.advance(now);
var id: ?usize = null;
+ var said = false;
var lines = std.mem.splitScalar(u8, script, '\n');
while (lines.next()) |raw| {
const line = std.mem.trim(u8, raw, " \t\r");
@@ -110,9 +115,15 @@ fn run(io: std.Io, gpa: std.mem.Allocator, lib: []const u8, script_path: ?[]cons
p.update(.{ .mouse = .{ .button = .left, .kind = mk, .col = body.x + col, .row = body.y + row } });
} else if (is(verb, "focus") or is(verb, "blur")) {
p.update(.{ .focus = is(verb, "focus") });
- } else if (is(verb, "graphics")) {
- // A frontend that shows pictures (`graphics on`), or glyph art.
- p.update(.{ .frontend = .{ .windowed = false, .native_images = std.mem.eql(u8, arg, "on") } });
+ } else if (is(verb, "graphics") or is(verb, "view")) {
+ // Into view N (another client's), then its frontend: with
+ // pictures (`on`), or glyph art.
+ if (is(verb, "view")) {
+ const n = std.fmt.parseInt(u8, arg[0..@min(1, arg.len)], 10) catch 1;
+ while (n > 1 and !pardes.views.isOpen(p, n - 1)) _ = p.openView() orelse break;
+ if (pardes.views.isOpen(p, n -| 1)) p.toView(n -| 1);
+ }
+ p.update(.{ .frontend = .{ .windowed = false, .native_images = std.mem.endsWith(u8, arg, "on") } });
} else if (is(verb, "dump")) {
id = try reloaded(p, gpa, at, out);
} else if (is(verb, "body") or is(verb, "ctl")) {
@@ -127,8 +138,18 @@ fn run(io: std.Io, gpa: std.mem.Allocator, lib: []const u8, script_path: ?[]cons
if (!p.executeBuiltinLine(at, line)) try out.print("not a word here: {s}\n", .{verb});
}
drain(p);
+ // A tick owed (a pane opened or loaded here, outside a step) and a
+ // view whose facts a frame's layout changed (its tag wrapped), as
+ // a host steps for them.
+ if (p.panes[id.?]) |pane| if (window(p, id.?) != null and (pane.addon.?.next_tick == 1 or Kind.viewOwed(p, pane.addon.?, id.?))) {
+ p.update(.tick);
+ drain(p);
+ };
try show(p, gpa, id.?, out, opened or is(verb, "size"));
+ if (Kind.breach.len > 0 and !said) try out.print("addon-test: {s}\n", .{Kind.breach.slice()});
+ said = Kind.breach.len > 0;
}
+ if (said) return error.OverBudget;
}
fn open(p: *Pardes, k: u8, path: ?[]const u8) !usize {
@@ -212,9 +233,8 @@ fn show(p: *Pardes, gpa: std.mem.Allocator, id: usize, out: *std.Io.Writer, size
defer arena.deinit();
const s = try p.render(arena.allocator());
const pane = p.panes[id] orelse return out.writeAll("(the pane is gone)\n");
- const slot = pane.addon.?;
if (size) if (window(p, id)) |w| try out.print("window {d}x{d}\n", .{ w.w, w.h });
- try out.print("tag {s}\n", .{if (slot.prefix.len > 0) slot.prefix.slice() else slot.nameOf()});
+ try out.print("tag {s}\n", .{try Kind.prefix(p, arena.allocator(), pane)});
const r = (s.region(.body, id) orelse return).rect;
for (r.y..r.y + r.h) |y| {
var row: std.ArrayList(u8) = .empty;