The kit
A view of kind lua is a script the terminal runs in a sandbox and draws itself, in its own font and its
own theme. The kit is what it is written with: elements and their layout, an editor of text, and a library of
components.
A page
A script returns the page: a table of the functions the terminal calls. render makes the elements when
the terminal draws, and handle answers what the person did. This one counts what a button is pressed;
the picture is of it after two presses.
local ui = require("@pencere/ui")
local u = ui.new()
local count = 0
return {
render = function(size, now, reduce_motion)
u:begin(size, now, reduce_motion)
local root = pencere.div():size_full():items_start():bg("background"):color("foreground"):child(
pencere.div():id("demo"):p(20):gap(12)
:child(pencere.text("Pressed " .. count .. " times"):text_size(16):weight(700))
:child(pencere.div():row():gap(8)
:child(u:button("add", { title = "Press", tone = "primary", keys = "cmd+enter" }))
:child(u:button("reset", { title = "Reset", disabled = count == 0 })))
)
return u:finish(root)
end,
settle = function()
return u:settle()
end,
handle = function(event)
local reply, actions = u:handle(event)
for _, action in actions do
if action.from == "add" then
count += 1
elseif action.from == "reset" then
count = 0
end
reply = pencere.merge(reply, true)
end
return reply
end,
}
What it is made of
8 elements
div, text, spark, image, rich, canvas, editor, spacer
24 components
Controls, Fields and choices, Layers, Lists and data, Layout, Editing
Where a part goes
The kit is made of four layers. Every part of it, and every part added to it later, takes its place by the rule of a layer, not by where its first user would like it to be.
- The appThe app's policy
require("./…") - The libraryWhat an app could have written itself on the page API. It comes with the kit, at the kit's version, with tests of its own
require("@pencere/<name>") - The preludeOnly what needs the bridge's inner places (the prelude's own, out of a script's reach), or must be there before the page starts
pencere.*, in every page - The hostWhat only a host can do. A change to it is a change to
SPEC.md, the one contract outside the kit; the interface between the host and the interpreter (wit/view.wit) is the kit's own link
The rule of each layer is in the kit's own document.
The library
require("@pencere/<name>") is a module of the kit's library: Luau that the kit writes on this page API alone (Sections 2.1 to 2.5, and nothing of the interpreter's besides), at the kit's version, for what every page would otherwise write again.
Its modules are listed in the library, and everything a page can do is said in full in the page API.