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,13 +1,12 @@
# text_fit.ludic - text-fit: shrink 12px draws a line that does not fit its box smaller, down to that
# size, and cuts what still does not fit with an ellipsis; line-height (a multiple of the font size,
# px or em) spaces a text's lines. Both are inherited, as font properties are.
var tf_size: float = 0.0 # the size tf_fit drew at
function el_text_fit(n: UiNode, s: string) -> void {
function el_text_fit(ui_st: UiState, n: UiNode, s: string) -> void {
let parts = lss_split(tpl_words(s), 32)
nx(n).fit_min = 0.0
if len(parts) >= 2 and parts[0] == "shrink" { nx(n).fit_min = Math.max(el_unit(parts[1]), 1.0) }
if len(parts) >= 2 and parts[0] == "shrink" { nx(n).fit_min = Math.max(el_unit(ui_st, parts[1]), 1.0) }
}
function el_line_h(n: UiNode, s0: string) -> void {
function el_line_h(ui_st: UiState, n: UiNode, s0: string) -> void {
let s = tpl_words(s0)
let x = nx(n)
x.lh_kind = 0
@ -19,7 +18,7 @@ function el_line_h(n: UiNode, s0: string) -> void {
return
}
x.lh_kind = 2
x.lh_v = el_unit(s)
x.lh_v = el_unit(ui_st, s)
}
# the nearest element, out from this one, that says `what` (0 text-fit, 1 line-height), or null
function tf_up(n: UiNode, what: int) -> UiNodeX {
@ -39,14 +38,14 @@ function ly_line_h(n: UiNode) -> float {
}
# one line to fit its box: at its own size if it does, else smaller down to text-fit's least, then
# cut; tf_size says the size it is drawn at
function tf_fit(n: UiNode, s: string) -> string {
tf_size = n.rsize
function tf_fit(ui_st: mut UiState, n: UiNode, s: string) -> string {
ui_st.tf_size = n.rsize
let x = tf_up(n, 0)
let room = n.cw - ly_hin(n)
if x == null or room <= 0.0 { return s }
let w = ly_text_w(s, tf_size)
let w = ly_text_w(ui_st, s, ui_st.tf_size)
if w <= room { return s }
tf_size = Math.max(x.fit_min, n.rsize * room / w)
while tf_size > x.fit_min and ly_text_w(s, tf_size) > room { tf_size = Math.max(x.fit_min, tf_size - 0.5) }
return ly_ellipsis(s, tf_size, room)
ui_st.tf_size = Math.max(x.fit_min, n.rsize * room / w)
while ui_st.tf_size > x.fit_min and ly_text_w(ui_st, s, ui_st.tf_size) > room { ui_st.tf_size = Math.max(x.fit_min, ui_st.tf_size - 0.5) }
return ly_ellipsis(ui_st, s, ui_st.tf_size, room)
}