From 2eb8860b2ca05c426f3962661441aaee13d3be44 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 29 Oct 2026 19:09:26 -0300 Subject: web: the browser shell builds again and loads a dump of a native build: a theme by its name, a field compiled out passed over, no disk asked; touch.dump replaces the hand-written ZON fixture Fixed for wasm32-freestanding: counts as usize, no threads, stb_image, tape or host stat there. touch.mjs follows the renderer's 13 tag-layer fields, helix's retuned colours and the tag column. Co-Authored-By: Claude Opus 5.5 --- test/web-snapshots/README.md | 2 +- test/web-snapshots/touch-fixture.zig | 58 ++++++++++++++++++++++++++++ test/web-snapshots/touch.dump | Bin 0 -> 96576 bytes test/web-snapshots/touch.dump.zon | 73 ----------------------------------- test/web-snapshots/touch.mjs | 21 ++++++---- 5 files changed, 72 insertions(+), 82 deletions(-) create mode 100644 test/web-snapshots/touch-fixture.zig create mode 100644 test/web-snapshots/touch.dump delete mode 100644 test/web-snapshots/touch.dump.zon (limited to 'test/web-snapshots') diff --git a/test/web-snapshots/README.md b/test/web-snapshots/README.md index a7cd865e..999e8fad 100644 --- a/test/web-snapshots/README.md +++ b/test/web-snapshots/README.md @@ -1,6 +1,6 @@ # Browser interaction tests -`zig build web-snap` loads `touch.dump.zon` and runs `touch.mjs` in Chromium. +`zig build web-snap` loads `touch.dump` (`python3 -B tools/web_fixture.py test/web-snapshots/touch.dump` makes it: a native session on `touch-fixture.zig` at 100x30, theme helix, Verbose off) and runs `touch.mjs` in Chromium. The fixed source fixture exercises complete keyword styles, touch Look through the self filesystem, separator resizing, and scrolling without another Look. Assertions locate current pane geometry; no live project source or author paths diff --git a/test/web-snapshots/touch-fixture.zig b/test/web-snapshots/touch-fixture.zig new file mode 100644 index 00000000..b1d5d81e --- /dev/null +++ b/test/web-snapshots/touch-fixture.zig @@ -0,0 +1,58 @@ +pub fn choose(value: u32) []const u8 { + if (value == 42) return "touch fixture"; + return "/virtual/pane/1/body"; +} + +pub const rows = [_]u32{ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, +}; \ No newline at end of file diff --git a/test/web-snapshots/touch.dump b/test/web-snapshots/touch.dump new file mode 100644 index 00000000..bcc58352 Binary files /dev/null and b/test/web-snapshots/touch.dump differ diff --git a/test/web-snapshots/touch.dump.zon b/test/web-snapshots/touch.dump.zon deleted file mode 100644 index 230d29e7..00000000 --- a/test/web-snapshots/touch.dump.zon +++ /dev/null @@ -1,73 +0,0 @@ -.{ - .screen = .{ .cols = 100, .rows = 30 }, - .theme = "helix", - .columns = .{.{ .panes = .{0} }}, - .panes = .{.{ - .kind = .file, - .tag = "touch-fixture.zig", - .body = "", - .file = .{ - .path = "touch-fixture.zig", - .content = - \\pub fn choose(value: u32) []const u8 { - \\ if (value == 42) return "touch fixture"; - \\ return "/virtual/pane/1/body"; - \\} - \\ - \\pub const rows = [_]u32{ - \\ 0, - \\ 1, - \\ 2, - \\ 3, - \\ 4, - \\ 5, - \\ 6, - \\ 7, - \\ 8, - \\ 9, - \\ 10, - \\ 11, - \\ 12, - \\ 13, - \\ 14, - \\ 15, - \\ 16, - \\ 17, - \\ 18, - \\ 19, - \\ 20, - \\ 21, - \\ 22, - \\ 23, - \\ 24, - \\ 25, - \\ 26, - \\ 27, - \\ 28, - \\ 29, - \\ 30, - \\ 31, - \\ 32, - \\ 33, - \\ 34, - \\ 35, - \\ 36, - \\ 37, - \\ 38, - \\ 39, - \\ 40, - \\ 41, - \\ 42, - \\ 43, - \\ 44, - \\ 45, - \\ 46, - \\ 47, - \\ 48, - \\ 49, - \\ 50, - \\}; - , - }, - }}, -} diff --git a/test/web-snapshots/touch.mjs b/test/web-snapshots/touch.mjs index 69f8a4a5..3793c0f9 100644 --- a/test/web-snapshots/touch.mjs +++ b/test/web-snapshots/touch.mjs @@ -1,8 +1,9 @@ import assert from "node:assert/strict"; function tags(frame) { - // This fixture has workspace and column bars in its first two rows. - return frame.styleRows.flatMap((cells, y) => y > 1 && /^\s{3}\S/.test(frame.lines[y]) && cells.some((cell) => cell[2] & 128) ? [y] : []); + // This fixture has workspace and column bars in its first two rows; a + // pane's tag text starts after the two-cell marker gutter. + return frame.styleRows.flatMap((cells, y) => y > 1 && /^\s{2}\S/.test(frame.lines[y]) && cells.some((cell) => cell[2] & 128) ? [y] : []); } function pane(frame, name) { @@ -13,14 +14,17 @@ function pane(frame, name) { return { top, bottom, lines: frame.lines.slice(top + 1, bottom) }; } +// helix's keyword and string/number colours (src/themes/helix.zig). +const KW = 0xd776f9, STR = 0xf3cd7a; + function styled(frame) { const source = pane(frame, "touch-fixture.zig"); for (const [line, word, fg, bold] of [ - ["pub fn choose", "fn", 0xcf87e8, false], + ["pub fn choose", "fn", KW, false], ["pub fn choose", "choose", 0xbdbdbd, false], - ["if (value", "if", 0xcf87e8, false], - ["if (value", "42", 0xe3c78a, false], - ["if (value", '"touch fixture"', 0xe3c78a, false], + ["if (value", "if", KW, false], + ["if (value", "42", STR, false], + ["if (value", '"touch fixture"', STR, false], ]) { const row = source.lines.findIndex((text) => text.includes(line)); assert(row >= 0, `missing source line ${line}`); @@ -35,7 +39,7 @@ function styled(frame) { const number = /\b(\d+),/.exec(line); if (!number) continue; for (let x = number.index; x < number.index + number[1].length; x++) { - assert.equal(frame.styleRows[source.top + 1 + row][x][0], 0xe3c78a, `row ${row} number foreground`); + assert.equal(frame.styleRows[source.top + 1 + row][x][0], STR, `row ${row} number foreground`); } } } @@ -79,7 +83,8 @@ export default async function ({ grid, touch, wait, stable, delay, evaluate, mou renderer.render(); result.closedGapBorders=borders(); result.borderChangeInvalidates=renderer.layerRoot.firstChild!==withGap; - const tagValues=[2,2,0,42,1,0,1,1,1,1,0x334455]; + // The 13 fields of a tag layer: a one-line tag, its caret on line 0. + const tagValues=[2,2,0,42,1,0,1,1,1,1,0x334455,1,0]; wasm.pardes_tag_layer_limit=()=>1; wasm.pardes_tag_layer_value=(_,field)=>tagValues[field]; wasm.pardes_tag_layer_cells=()=>1024; -- cgit v1.3 From cc26fe74e092803ac2977801bf6510e05b394c29 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 29 Oct 2026 19:36:11 -0300 Subject: web: a dump is a .dump by name everywhere (the download, the embedded fixture, -l's help); the touch check resizes a pane by its grip, there being no rule between panes Co-Authored-By: Claude Opus 5.5 --- build.zig | 2 +- src/host_io.zig | 2 +- src/main.zig | 2 +- src/web.zig | 4 ++-- test/web-snapshots/touch.mjs | 9 +++++---- 5 files changed, 10 insertions(+), 9 deletions(-) (limited to 'test/web-snapshots') diff --git a/build.zig b/build.zig index 097fb1bf..c0235e41 100644 --- a/build.zig +++ b/build.zig @@ -1111,7 +1111,7 @@ pub fn build(b: *std.Build) void { if (is_web) { const dp = dump_path.?; - root_mod.addAnonymousImport("embedded.dump.zon", .{ + root_mod.addAnonymousImport("embedded.dump", .{ .root_source_file = if (std.fs.path.isAbsolute(dp)) .{ .cwd_relative = dp } else b.path(dp), }); } diff --git a/src/host_io.zig b/src/host_io.zig index 99ada59b..7b0fe9a2 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -70,7 +70,7 @@ pub fn testClock() ?u64 { } pub const Fallback = struct { - pub const dump_path = "pardes.dump.zon"; + pub const dump_path = "pardes.dump"; gpa: std.mem.Allocator, files: std.StringHashMapUnmanaged([]u8) = .empty, diff --git a/src/main.zig b/src/main.zig index 0708e9d7..ac2226ae 100644 --- a/src/main.zig +++ b/src/main.zig @@ -73,7 +73,7 @@ const help_text = \\ -n initial shell panes: 1 (default) or 3 (classic). \\ A FILE argument boots just that file instead. \\ --tty-toggle use Ctrl- to toggle tty/editor mode - \\ -l load a dump of another instance (see Dump) + \\ -l load a dump of another instance (see Dump) \\ -w, --wait inside a pardes pane, hand FILE to the outer \\ session and return only once the pane it opened \\ (or already had) is deleted: 0 then, 1 if the diff --git a/src/web.zig b/src/web.zig index fd6371c0..5e5a0d74 100644 --- a/src/web.zig +++ b/src/web.zig @@ -13,7 +13,7 @@ const pardes = @import("pardes.zig"); const mouse = @import("mouse.zig"); const gpa = std.heap.wasm_allocator; -const embedded_dump = @embedFile("embedded.dump.zon"); +const embedded_dump = @embedFile("embedded.dump"); const input_capacity = 64 * 1024; const attr_tagline: u16 = 1 << 7; @@ -484,7 +484,7 @@ fn writeFile(_: ?*anyopaque, _: u8, path: []const u8, bytes: []const u8) void { } fn writeDump(_: ?*anyopaque, bytes: []const u8) void { - const name = "pardes-dump.zon"; + const name = "pardes.dump"; host_download(name.ptr, name.len, bytes.ptr, bytes.len); } diff --git a/test/web-snapshots/touch.mjs b/test/web-snapshots/touch.mjs index 3793c0f9..6ced7a29 100644 --- a/test/web-snapshots/touch.mjs +++ b/test/web-snapshots/touch.mjs @@ -192,14 +192,15 @@ export default async function ({ grid, touch, wait, stable, delay, evaluate, mou assert.deepEqual(reflected.lines.slice(0, sharedRows), original.lines.slice(0, sharedRows), "Look must read the source pane body"); const center = Math.floor(frame.cols / 2); - const separator = Math.max(original.top, reflected.top) - 1; + // No rule between panes: the lower one's grip, its tag's gutter, moves it. + const separator = Math.max(original.top, reflected.top); const distance = original.top < reflected.top ? 4 : -4; - finger = await touch("down", 2, center, separator, null); + finger = await touch("down", 2, 0, separator, null); for (let step = 1; step <= 8; step++) { - finger = await touch("move", 2, center, separator + distance * step / 8, finger); + finger = await touch("move", 2, 0, separator + distance * step / 8, finger); await delay(20); } - await touch("up", 2, center, separator + distance, finger); + await touch("up", 2, 0, separator + distance, finger); await stable(100, 5000); frame = await grid(); assert.equal(tags(frame).length, 2); -- cgit v1.3