summaryrefslogtreecommitdiff
path: root/examples/live/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 07:58:27 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit4350e6840940da0b7af800faf5a1455a1de1908e (patch)
tree29f0109de63fbee2a8146c620c0f5e83065ea8d1 /examples/live/test
parent610ffe373f0f5dd5ccb59bf575f5479ad1ecdbaf (diff)
downloadsketchbook-4350e6840940da0b7af800faf5a1455a1de1908e.tar.gz
sketchbook-4350e6840940da0b7af800faf5a1455a1de1908e.zip
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 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'examples/live/test')
-rw-r--r--examples/live/test/live.script13
1 files changed, 13 insertions, 0 deletions
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