- `popover`: a top layer that keeps the pointer and the keyboard, closed by a press outside or Esc. - `title` tooltips after half a second's rest, styled by .ui-tooltip. - `<progress>` and `<meter>`. - Atlases take rows and number cells, and importing ludic.ui/render3d.ludic is enough to draw with render3d. - The compiler reports two declarations of one name before it type-checks, so a package global clashing with a program's reads as that, not as 29 type errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
50 lines
2 KiB
Text
50 lines
2 KiB
Text
# link.ludic - each tag in a file that is not an element names a component: the file's own, an
|
|
# unnamed import's exported one, or `as:Name` from the import called `as`
|
|
const LK_OWN: string = " row button input select textarea progress meter spacer scroll img hr if else each slot state style component screen import let fragment template provide #text "
|
|
function lib_link(f: UiFile, t: UiTpl) -> void {
|
|
t.sheet = f.sheet
|
|
if not lk_element(t.tag) {
|
|
t.comp = lk_find(f, t.tag, false)
|
|
if t.comp == null { t.cls = uc_find(t.tag) }
|
|
if t.cls != null {
|
|
lk_kids(f, t)
|
|
return
|
|
}
|
|
if t.comp == null and lk_find(f, t.tag, true) != null { ui_err(`{t.where}: <{t.tag}>: that component is not exported - export="true" on it lets other files use it`) } else if t.comp == null { ui_err(`{t.where}: <{t.tag}>: there is no such element, and no component of that name here or exported by an import`) }
|
|
}
|
|
lk_kids(f, t)
|
|
}
|
|
function lk_kids(f: UiFile, t: UiTpl) -> void {
|
|
for i in 0 .. len(t.kids) { lib_link(f, t.kids[i]) }
|
|
}
|
|
function lk_element(tag: string) -> bool { return lk_in(LK_OWN, tag) or lk_in(EL_BOXES, tag) or lk_in(EL_TEXTS, tag) or nt_find(tag) != null }
|
|
# a word in a list of words written " a b c "
|
|
function lk_in(words: string, w: string) -> bool {
|
|
let pat = ` {w} `
|
|
let n = len(pat)
|
|
for i in 0 .. len(words) - n + 1 {
|
|
if words[i..i + n] == pat { return true }
|
|
}
|
|
return false
|
|
}
|
|
# `any` finds an unexported one too, to say why it cannot be used
|
|
function lk_find(f: UiFile, tag: string, any: bool) -> UiTpl {
|
|
var colon = -1
|
|
for i in 0 .. len(tag) {
|
|
if tag[i] == 58 { colon = i }
|
|
}
|
|
if colon < 0 {
|
|
let own = lib_find(f.names, tag)
|
|
if own >= 0 { return f.comps[own] }
|
|
}
|
|
for i in 0 .. len(f.imp) {
|
|
var want = tag
|
|
if colon >= 0 {
|
|
if f.imp_as[i] != tag[0..colon] { continue }
|
|
want = tag[colon + 1..len(tag)]
|
|
} else if f.imp_as[i] != "" { continue }
|
|
let at = lib_find(f.imp[i].names, want)
|
|
if at >= 0 and (any or f.imp[i].exported[at]) { return f.imp[i].comps[at] }
|
|
}
|
|
return null
|
|
}
|