wip(0.S3): packages and examples migrated again from their pre-0.S sources in one run

ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic
  1804 vars into 126 states, 64 into lets; 23498 edits in 460 files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 15:31:34 +03:00
parent 5ffe50ed02
commit 19fcf60599
459 changed files with 17862 additions and 17603 deletions

View file

@ -1,20 +1,13 @@
# life.ludic - on-mount and on-unmount: an element or component that appears in a frame it was not
# in last frame is mounted, and one that is gone is unmounted, each once, after the frame is drawn
var lc_keys: []string = new []string
var lc_mounts: []UiAct = new []UiAct
var lc_unmounts: []UiAct = new []UiAct
var lc_envs: []UiEnv = new []UiEnv
var lc_prev_keys: []string = new []string
var lc_prev_unmounts: []UiAct = new []UiAct
var lc_prev_envs: []UiEnv = new []UiEnv
# a build starts its own records: a screen built twice keeps only the last build's
function lc_begin() -> void {
lc_keys = new []string
lc_mounts = new []UiAct
lc_unmounts = new []UiAct
lc_envs = new []UiEnv
function lc_begin(ui_st: mut UiState) -> void {
ui_st.lc_keys = new []string
ui_st.lc_mounts = new []UiAct
ui_st.lc_unmounts = new []UiAct
ui_st.lc_envs = new []UiEnv
}
function lc_note(key: string, names: []string, acts: []UiAct, e: UiEnv) -> void {
function lc_note(ui_st: mut UiState, key: string, names: []string, acts: []UiAct, e: UiEnv) -> void {
var m: UiAct = null
var u: UiAct = null
for i in 0 .. len(names) {
@ -22,43 +15,43 @@ function lc_note(key: string, names: []string, acts: []UiAct, e: UiEnv) -> void
if names[i] == "unmount" { u = acts[i] }
}
if m == null and u == null { return }
push(lc_keys, key)
push(lc_mounts, m)
push(lc_unmounts, u)
push(lc_envs, e)
push(ui_st.lc_keys, key)
push(ui_st.lc_mounts, m)
push(ui_st.lc_unmounts, u)
push(ui_st.lc_envs, e)
}
function lc_mine(key: string, screen: string) -> bool {
let n = len(screen)
return key == screen or (len(key) > n and key[0..n] == screen and key[n] == 47)
}
# the screen's mounts and unmounts since its last frame; other screens' records are kept
function lc_run(screen: string) -> void {
for i in 0 .. len(lc_keys) {
if lc_mounts[i] != null and not sel_has(lc_prev_keys, lc_keys[i]) { act_run(lc_mounts[i], lc_envs[i]) }
function lc_run(ui_st: mut UiState, screen: string) -> void {
for i in 0 .. len(ui_st.lc_keys) {
if ui_st.lc_mounts[i] != null and not sel_has(ui_st.lc_prev_keys, ui_st.lc_keys[i]) { act_run(ui_st, ui_st.lc_mounts[i], ui_st.lc_envs[i]) }
}
let keys = new []string
let unmounts = new []UiAct
let envs = new []UiEnv
for i in 0 .. len(lc_prev_keys) {
let k = lc_prev_keys[i]
for i in 0 .. len(ui_st.lc_prev_keys) {
let k = ui_st.lc_prev_keys[i]
if lc_mine(k, screen) {
if lc_prev_unmounts[i] != null and not sel_has(lc_keys, k) { act_run(lc_prev_unmounts[i], lc_prev_envs[i]) }
if ui_st.lc_prev_unmounts[i] != null and not sel_has(ui_st.lc_keys, k) { act_run(ui_st, ui_st.lc_prev_unmounts[i], ui_st.lc_prev_envs[i]) }
} else {
push(keys, k)
push(unmounts, lc_prev_unmounts[i])
push(envs, lc_prev_envs[i])
push(unmounts, ui_st.lc_prev_unmounts[i])
push(envs, ui_st.lc_prev_envs[i])
}
}
for i in 0 .. len(lc_keys) {
push(keys, lc_keys[i])
push(unmounts, lc_unmounts[i])
push(envs, lc_envs[i])
for i in 0 .. len(ui_st.lc_keys) {
push(keys, ui_st.lc_keys[i])
push(unmounts, ui_st.lc_unmounts[i])
push(envs, ui_st.lc_envs[i])
}
lc_prev_keys = keys
lc_prev_unmounts = unmounts
lc_prev_envs = envs
lc_keys = new []string
lc_mounts = new []UiAct
lc_unmounts = new []UiAct
lc_envs = new []UiEnv
ui_st.lc_prev_keys = keys
ui_st.lc_prev_unmounts = unmounts
ui_st.lc_prev_envs = envs
ui_st.lc_keys = new []string
ui_st.lc_mounts = new []UiAct
ui_st.lc_unmounts = new []UiAct
ui_st.lc_envs = new []UiEnv
}