From c300a059850115a87a34456dfd60ac97c4a09890 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 06:03:15 -0300 Subject: examples/live: the picture, typed over itself The sketch: State holds the text (a plain 4 KiB buffer, typed characters appended, backspace deleting the last, return a newline: marked ponytail, the place pardes's editor takes in part 2), the last good out and color tapes, the problem and the time, summed from recorded ticks. `update` compiles the text at every keystroke; a program that parses replaces the tapes and clears the problem, one that does not sets the problem and changes nothing else, so the last good picture stays. `draw` runs picture.frag over the color tape into an image the size of the canvas, 1280x720, or half of it when the tape is longer than 64 instructions (the probe: 128 took 2.7 ms at full size, 0.85 at half), and scales it up. The text is drawn over it on a dark band with the library's text calls (the code face at 1.25, a column a fixed advance), the caret at the end, the problem as a red mark under its byte and its words under the text, and live/recording/replay/paused with the time in a corner. Test: test/live.script, the start of the scripted proof: a tone typed (its eight instructions asserted), a gradient (hsv over x and y, four), an edit (y to x: three, the picture different), a broken line (the problem at byte 52, the tape and the picture the same) and its mend. zig build test: 56 of 56 steps, 6 of 6 tests. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- examples/live/build.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'examples/live/build.zig') diff --git a/examples/live/build.zig b/examples/live/build.zig index 2ad85fb..2f76306 100644 --- a/examples/live/build.zig +++ b/examples/live/build.zig @@ -29,8 +29,10 @@ pub fn build(b: *std.Build) void { .{ .name = "shaders", .module = shaders.module }, }; + const app = sb.app(.{ .name = "live", .root_source_file = b.path("src/main.zig"), .imports = imports }); + const steps = app.addSteps(.{ .scripts = &.{b.path("test/live.script")} }); const lang_test = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("src/Lang.zig"), .target = target, .optimize = optimize }) }); - b.step("test", "Run the language's tests").dependOn(&b.addRunArtifact(lang_test).step); + steps.test_step.dependOn(&b.addRunArtifact(lang_test).step); // The interpreter's GPU time over made-up tapes (`--profile-gpu`). const probe = sb.app(.{ .name = "live-probe", .root_source_file = b.path("src/probe.zig"), .imports = imports }); -- cgit v1.3