From 4350e6840940da0b7af800faf5a1455a1de1908e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 07:58:27 -0300 Subject: examples/live: drag a number, the program following as it moves The left button pressed on a number token (the grammar's `number` node at the byte under the pointer, found with the module's parse) starts a drag kept in State: the literal's bytes, the value, its precision. Each pointer move rewrites the literal through the editor's `replace`: a step for every 4 pixels right of where it was pressed (left, down), the step from the literal's own precision (`220` by ones, `0.25` by hundredths), printed with as many decimals. The first rewrite is a step to undo and the rest join it, so one `u` takes the whole drag back. The text changes, so the program is compiled and heard as it moves. A literal with an exponent is not dragged (marked ponytail). `update` finds the byte under the pointer as `code` lays the text out: a character is 10 by 22 pixels, measured once (the code face at 1.25, natively: ten M are 100) and now a constant both use, where `code` asked the host each frame. Test: test/live.script presses 220, drags 40 pixels right (230), back to 12 left of the press (217), lets go and undoes the drag in one step (220). zig build test: 85 of 85 steps. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- examples/live/test/live.script | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'examples/live/test/live.script') diff --git a/examples/live/test/live.script b/examples/live/test/live.script index a06ed97..bedcf83 100644 --- a/examples/live/test/live.script +++ b/examples/live/test/live.script @@ -81,3 +81,16 @@ expect probe.len 3 expect probe.code[2].op mul key escape expect probe.len 0 +# Drag a number: 220 (line 1, columns 16..18; a column 10 pixels from 16, +# a line 22 from 16) pressed and dragged 40 pixels right is 230, then 12 +# left of where it was pressed is 217; the program follows; the drag is one +# step to undo. +down 181 27 +move 201 27 +move 221 27 +expect out.code[1].a 1130758144 +move 169 27 +expect out.code[1].a 1129906176 +up 169 27 +type u +expect out.code[1].a 1130102784 -- cgit v1.3