ludic/tools/ui-preview/input_keys.ludic
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

28 lines
1.3 KiB
Text

# input_keys.ludic - the names `input key` and `input pad` take, and a frame's presses cleared
function pv_key(i: PvIn, k: string) -> string {
let o = i.once
if k == "tab" { o.tab = true } else if k == "backtab" {
o.tab = true
o.shift = true
} else if k == "up" { o.up = true } else if k == "down" { o.down_key = true } else if k == "left" { o.left = true } else if k == "right" { o.right = true } else if k == "enter" { o.enter = true } else if k == "space" { o.space = true } else if k == "escape" { o.escape = true } else if k == "backspace" { o.backspace = true } else if len(k) > 0 and k[0] >= 48 and k[0] <= 57 { o.key = pv_int_of(k) } else { return `input key {k}: not a key` }
return ""
}
function pv_pad(i: PvIn, b: string, on: bool) -> string {
if b == "a" { i.pad_a = on } else if b == "b" { i.pad_b = on } else if b == "up" { i.hold_up = on } else if b == "down" { i.hold_down = on } else if b == "left" { i.hold_left = on } else if b == "right" { i.hold_right = on } else if b == "enter" { i.hold_enter = on } else { return `input pad {b}: not a button` }
return ""
}
function pv_in_blank(o: UiInput) -> void {
o.wheel = 0.0
o.tab = false
o.shift = false
o.up = false
o.down_key = false
o.left = false
o.right = false
o.enter = false
o.space = false
o.escape = false
o.backspace = false
o.typed = ""
o.key = 0
}