# ui_reload.ludic — a template read from disk, changed there, and read again by ui_reload: the new # text shows at once, and the screen's state (a counter pressed before the change) is kept. import "ludic.ui" program UiReload { numbers float view Note { title = "note" } const PATH: string = "build/ui_reload_example.xml" const V1: string = "" const V2: string = "

{title} again {n}

" function shown(ui_st: mut UiState) -> string { let root: UiNode = ui_nodes(ui_st, "note", view_note()) let first = root.children[0] if len(first.children) > 0 { return first.children[0].text } return first.text } entry (ui_st: mut UiState) { Fs.write_text(PATH, V1) ui_load(ui_st, PATH) let root: UiNode = ui_nodes(ui_st, "note", view_note()) ui_press(ui_st, root.children[0]) let before = shown(ui_st) let same = ui_reload(ui_st) Fs.write_text(PATH, V2) let changed = ui_reload(ui_st) print(`{before} | reloaded {same} then {changed} | {shown(ui_st)}`) } }