ludic/tools/ui-preview/smoke.txt
Orkuncakilkaya 49b5e80af5 ludic ui-preview: ludic.ui components previewed for a studio over stdio (R5)
A prebuilt tool, bin/ludic-ui-preview (built by ludic-dev build, shipped beside ludic-lsp, run as
`ludic ui-preview [--font DIR]`): ludic.ui with a backend that records every draw call as a line,
and mock component classes the studio describes (load / model / calls). frame t runs ui_show at
interface time t; text is measured on the CPU with the game's font.json metrics; locale goes
through ludic.i18n; tree / box / rules inspect the frame. No game code, no GPU, no network. The wire
protocol is frozen as tools/ui-preview/protocol-v1.md; smoke.txt is a transcript to run.

ludic.ui gains, all additive: UiClass.make_of, UiBackend.said / emitted, UiRule.text / at (with
comment line breaks kept so rule lines count true, and a class's styles read under its .lss path),
and ui_root, ui_find, ui_rules_of, ui_rule_value, ui_building, ui_class, ui_class_load,
ui_file_forget, ui_errors_clear; ui_nine_cuts_into exported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 19:53:26 +03:00

152 lines
2.6 KiB
Text

# smoke.txt - a scripted session for ludic ui-preview (protocol-v1.md), to be run by hand or by a
# small driver: `bin/ludic-ui-preview < requests` where the requests are the `> ` lines below, in order.
#
# > LINE a request, sent as it stands (without the "> ")
# < TEXT some reply line of that request contains TEXT (in order within the reply)
# <= LINE the request's terminal line is exactly LINE
# <! TEXT no reply line of that request contains TEXT
#
# No font is loaded, so a character measures half the font size, and the viewport is 1920 x 1080, so
# a design pixel is a screen pixel and the default text is 16 px (a 4-letter word is 32 wide).
> hello
<= ok ui-preview 1 "" ""
> viewport 1920 1080
<= ok
> native "dial" 40 40
<= ok
> load "Pill" "<row id=\"root\" class=\"pill\">\n <p id=\"label\">{label}</p>\n <p id=\"pct\">{pct(0)}</p>\n <button id=\"go\" on-press=\"pick(3)\">Go</button>\n <button id=\"set\" on-press=\"set n = 2\">Set</button>\n <button id=\"close\" on-press=\"emit close\">Shut</button>\n <dial id=\"d\"/>\n <Badge id=\"badge\"/>\n</row>" ".pill {\n background: #203040;\n padding: 8;\n gap: 4;\n}\np { color: #ff0000; }"
<! err
<= ok
> model "Pill" {"label": "Food", "n": 0}
<= ok
> show Pill
<= ok
> frame 0
< frame 0
< rect
< #203040 1
< text
< 16 32 #ff0000 1 "Food"
< round
< #3a3f46 1
< "Go"
< native "dial"
< end
< miss "Pill" "pct"
<= ok
> calls "Pill" {"pct": [80, 20], "pick": true}
<= ok
> frame 0.5
< frame 0.5
< "80"
< end
<! miss
<= ok
> input key tab
<= ok
> frame 1
< end
<= ok
> input key enter
<= ok
> frame 1.1
< end
< call "Pill" "pick" [3]
<= ok
> input key tab
<= ok
> frame 1.2
<= ok
> input key enter
<= ok
> frame 1.3
< set "Pill" "n" 2
<= ok
> input key tab
<= ok
> frame 1.4
<= ok
> input key enter
<= ok
> frame 1.5
< emit "close"
<= ok
> load "Badge" "<span class=\"b\">new</span>" ".b { color: #00ff00; }"
<= ok
> frame 2
< #00ff00 1 "new"
<= ok
> tree
< node 0
< "root"
< "go"
< "Food"
<= ok
> box label
< box "
< style font-size 16
< style color #ff0000 1
<= ok
> rules label
< rule "Pill.lss" 6
< "p"
< decl "color" "#ff0000"
<= ok
> box nosuch
<= fail "box nosuch: no element has that id or key"
> load "Bad" "<row>\n <nosuch/>\n</row>" ""
< err "Bad.xml" 2 0 "<nosuch>: there is no such element
<= ok
> atlas "icon" "icons" 4 2 ["tent", "fish"]
<= ok
> load "Pic" "<row><img src=\"icon:fish\"/><img src=\"photo.png\"/></row>" ""
<= ok
> show Pic
<= ok
> frame 3
< image atlas "icons" 1
< 0.25 0 0.5 0.5
< image path "photo.png"
< 0 0 1 1 #ffffff 1
<= ok
> frobnicate
<= fail "unknown request frobnicate"
>
<= ok
> quit
<= ok