wip(0.S2): migrate - a var nothing writes becomes a let; a state is keyed by its module, directory or program, so every program's plan agrees; paths normalized; program states named SceneDemoState / scene_demo_st; the LSP reads state, mut and entry/handler parameters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3eda72e8c2
commit
5ffe50ed02
463 changed files with 72045 additions and 67421 deletions
|
|
@ -4,10 +4,8 @@
|
|||
import "ludic.ui"
|
||||
program UiTranslate {
|
||||
numbers float
|
||||
state UitranslateState {
|
||||
said: []string = new []string
|
||||
now: float = 0.0
|
||||
}
|
||||
var said: []string = new []string
|
||||
var now: float = 0.0
|
||||
const PAGE: string = "<ui><screen name='t'><p>Hello</p><p translate='no'>Hello</p><div translate='no'><p>Hello</p><p translate='yes'>Hello</p></div><p class='a' title='Save\\nQuit'>a</p><p class='b' title='Line one\\nLine two'>b</p><div translate='no'><p class='c' title='Line one\\nLine two'>c</p></div></screen></ui>"
|
||||
function tr(s: string) -> string {
|
||||
if s == "Hello" { return "Merhaba" }
|
||||
|
|
@ -16,31 +14,31 @@ program UiTranslate {
|
|||
if s == "Line two" { return "Satir iki" }
|
||||
return s
|
||||
}
|
||||
function rec_text(uitranslate_st: mut UitranslateState, x: float, y: float, s: string, size: float, c: int, a: float) -> void { push(uitranslate_st.said, s) }
|
||||
function clock(uitranslate_st: UitranslateState) -> float { return uitranslate_st.now }
|
||||
function tip(ui_st: mut UiState, uitranslate_st: mut UitranslateState, root: UiNode, k: int) -> string {
|
||||
function rec_text(x: float, y: float, s: string, size: float, c: int, a: float) -> void { push(said, s) }
|
||||
function clock() -> float { return now }
|
||||
function tip(root: UiNode, k: int) -> string {
|
||||
let n = root.children[k]
|
||||
let i = new UiInput
|
||||
i.x = n.x + 1.0
|
||||
i.y = n.y + 1.0
|
||||
ui_input(ui_st, i)
|
||||
ui_show(ui_st, "t", null, 0.0, 0.0, 400.0, 400.0)
|
||||
uitranslate_st.now = uitranslate_st.now + 1.0
|
||||
uitranslate_st.said = new []string
|
||||
ui_input(ui_st, i)
|
||||
ui_show(ui_st, "t", null, 0.0, 0.0, 400.0, 400.0)
|
||||
return `{uitranslate_st.said[len(uitranslate_st.said) - 2]}/{uitranslate_st.said[len(uitranslate_st.said) - 1]}`
|
||||
ui_input(i)
|
||||
ui_show("t", null, 0.0, 0.0, 400.0, 400.0)
|
||||
now = now + 1.0
|
||||
said = new []string
|
||||
ui_input(i)
|
||||
ui_show("t", null, 0.0, 0.0, 400.0, 400.0)
|
||||
return `{said[len(said) - 2]}/{said[len(said) - 1]}`
|
||||
}
|
||||
entry (ui_st: mut UiState, uitranslate_st: mut UitranslateState) {
|
||||
entry {
|
||||
let b = new UiBackend
|
||||
b.text = fn rec_text
|
||||
ui_backend(ui_st, b)
|
||||
ui_translator(ui_st, fn tr)
|
||||
ui_clock(ui_st, fn clock)
|
||||
ui_load_text(ui_st, PAGE, "t.xml")
|
||||
let root: UiNode = ui_nodes(ui_st, "t", null)
|
||||
ui_place(ui_st, root, 0.0, 0.0, 400.0, 400.0)
|
||||
ui_backend(b)
|
||||
ui_translator(fn tr)
|
||||
ui_clock(fn clock)
|
||||
ui_load_text(PAGE, "t.xml")
|
||||
let root: UiNode = ui_nodes("t", null)
|
||||
ui_place(root, 0.0, 0.0, 400.0, 400.0)
|
||||
let texts = `{root.children[0].text} {root.children[1].text} {root.children[2].children[0].text} {root.children[2].children[1].text}`
|
||||
print(`{texts} | {tip(ui_st, uitranslate_st, root, 3)} | {tip(ui_st, uitranslate_st, root, 4)} | {tip(ui_st, uitranslate_st, root, 5)}`)
|
||||
print(`{texts} | {tip(root, 3)} | {tip(root, 4)} | {tip(root, 5)}`)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue