Learn

Contents

Programs in a window

elucid8 window shows a program's values in a window on your screen and sends what you do in it back to the program: you can draw, type, press buttons and play games, and every frame is a value of the program. This page builds four small programs for it, one idea at a time, then points to six full apps you can run and read. It is in the elucid8 command from 0.23.0.

You need what the Tutorial teaches; Interactive programs shows the same idea with a terminal and the Player, and is worth reading first.

elucid8 window opens a window on macOS and Windows with the command from the Download page, and on Linux with its desktop build, which needs WebKitGTK 4.1 (Where it runs).

The window draws; the program decides

The window does two things only. It draws values of the program: a picture, labels, controls, text. And it sends what you do, a press, a key, a click on a button, as rows of an input, one turn of that input per event. Everything else is the program's: which cell a press paints, what a key means, where a game's ball goes. Nothing in the program waits, reads or prints. A value such as canvas is defined over the turns (canvas[t = 3] is the canvas after event 3; events count from 0), and the window shows it at the last turn, redrawing only what changed. So the same events always give the same frames, and the program can read any earlier turn: an undo is the canvas at an earlier turn.

Run the apps first

Six full programs show what a window can be. Run one before reading on; each section below then builds a small piece of the same thing. They are in the folder window/ of the examples' download on the Download page. Each is one program.el8 with its deploy.json, and each is checked against a Python program written the usual way for the same thing (with pygame, and NumPy for the drawing): the two are given the same events, and what they hold is compared after every event.

Each runs the same way, from its folder:

cd window/lander
elucid8 window program.el8

The first time you open an app, its About panel says how to use it; the ? button (F1, or ⌘? on a Mac) opens it again.

The editor and Markdown to HTML read and write files in the folder the window was started from, or in its subfolders.

The four programs on this page

Each program below is a folder of window/ in the same download (window/paint, window/dot, window/dot-panel, window/line): program.el8 and deploy.json. An input the window sends its events to needs no file: the window starts with no events. Run the command from inside the folder; to write one yourself, make a folder with the same files. The lines starting -- table and -- expect are comments: they give the playground a short session to replay and say what it should give. elucid8 check runs them: it replays the session and fails, naming the line, when an expectation does not hold. The window ignores them.

One picture

A program that paints the cells you drag over. paint/program.el8:

-- Paint the cells you drag over. Each pointer event is a turn t of
-- the input "pen": a row for "x", "y" (the cell) and "kind"
-- (1 press, 2 a move while pressed, 3 release).
pen = input("pen", t : inf, f : {"x", "y", "kind"})
px = pen[f = "x"]
py = pen[f = "y"]
kind = pen[f = "kind"]

-- The canvas after event t: the canvas before it, and the cell under
-- the pointer if the event was a press or a move.
before = 0 fby.t canvas
hit = (kind == "press" or kind == "move") and #x == px and #y == py
canvas = restrict if before == 1 or hit then 1 else 0 to (x : 64, y : 48) end
-- table pen = t,f,value; 0,x,12; 0,y,12; 0,kind,press; 1,x,13; 1,y,12; 1,kind,move; 2,x,14; 2,y,12; 2,kind,move; 3,x,14; 3,y,12; 3,kind,release
-- fill pen = 0
-- expect canvas[t = 3, x = 12, y = 12] = 1
-- expect canvas[t = 3, x = 14, y = 12] = 1
-- expect canvas[t = 3, x = 15, y = 12] = 0
-- expect canvas[t = 0, x = 13, y = 12] = 0

Open in playground

paint/deploy.json says where the events go and what the window shows: a column holding one part, a plot (the node that draws a value as cells) of canvas, which grows to take the window's room:

{
  "format": "elucid8-deploy/2",
  "inputs": { "pen": { "fill": {"missing": 0} } },
  "window": {
    "title": "paint", "input": "pen",
    "column": [
      { "plot": "{canvas}", "grow": 1,
        "colors": { "0": "#fafaf7", "1": "#203478" } }
    ]
  }
}

The window sends pen its events, so pen needs no file: its entry gives no from and says only what a missing point reads (fill; an entry with no from takes only fill, kinds, ragged and time), and the window starts with no events. In the folder window/paint:

elucid8 window program.el8

The window shows canvas at its last turn, its first dimension across and its second up from the bottom, as the Player lays a picture out, with the cells fitted to the window. (A text, below, runs the other way: its first line is at the top.) Press and drag across it: a short stroke to the right sends these rows to pen, a turn for each event, a row for each field the input lists (each row also ends with its event's time, in milliseconds since the window opened, left out here):

0,"x",12
0,"y",12
0,"kind","press"
1,"x",13
1,"y",12
1,"kind","move"
2,"x",14
2,"y",12
2,"kind","move"
3,"x",14
3,"y",12
3,"kind","release"

A press (kind "press") at cell (12, 12), moves (kind "move") to the next two cells, and a release (kind "release"). A move is sent only when the pointer reaches another cell. The fields are named after the picture's dimensions (x and y), and kind says what happened. So, over these rows, canvas[t = 3] has cells 12, 13 and 14 of row 12 painted: the -- table line gives the same rows, and Open in playground shows every turn of it. A fast stroke skips cells; the full drawing app joins each move to the one before with a line.

What a turn with no event reads. Every event the window sends gives every field its input lists. Before the first event the input has no row at all, so its points there are eod (no data yet, past the last row along t), and so is the canvas computed from them: the window shows eod in its own colour until the first event. A program that should start from paper reads the input through default, which gives a value where it is eod: kind = default(pen[f = "kind"], "").

Colours. "colors" gives each value of the picture its colour: here 0 the paper and 1 the ink. A value it does not list keeps the window's own colours (numbers from pale to strong, booleans, eod and errors in colours of their own). For smooth amounts it can be a gradient, and "colorsDark" gives the dark theme's. For a picture of amounts, "palette" picks a whole scale by name instead: {"plot": "{heat}", "scale": "fit", "palette": "viridis"}; "classic", "viridis" and "diverging" (around 0) are the playground's and the Player's, "single" the window's own (Command reference). A plot's "top" is the value its set has, drawn black as the playground draws it: {"plot": "{n_steps}", "palette": "classic", "top": "{steps}"} (a value in braces, or a number); without it classic is black only at the greatest value shown. A plot's "scroll" and "left" are the first row and column it shows, when it shows part of its value ("width" and "height" in cells).

Light and dark. The window follows the computer's light or dark appearance, also when it changes while the window is open: controls, labels, texts, the About panel and every picture are drawn again in the other theme, each picture in its "colorsDark" (or "colors"). On macOS the View menu's Appearance chooses Automatic (follow the computer), Light or Dark (the View menu also has Enter Full Screen, as does the window's green button, and the Window menu Minimize, ⌘M, Zoom and Bring All to Front); on Windows and Linux the same three choices are in the About panel (F1). The choice is remembered for every window you open. The program is sent nothing: light or dark is the window's, never a key.

The "title" names the window, and "input" the input its events go to. A column can hold more parts than one: labels, buttons and other plots beside the canvas (A window of several parts).

Keys and time

An input that lists the field key is also sent the keys you press: each key is one more turn, with kind "key" and key the key's name, as a browser names it ("c", "C", "ArrowLeft", "Enter", " " for the space bar). A program that also wants to move by itself takes ticks: "tick": "100ms" in the "window" section sends the input a turn every 100 ms with kind "tick", from the moment the window opens (--tick 100ms on the command line does the same, and overrides it). A dot that runs along a track, dot/program.el8:

-- A dot that runs along a track. Each tick moves it one cell; the
-- arrow keys turn it round; Space stops it and starts it again.
ev = input("ev", t : inf, f : {"kind", "key"})
kind = ev[f = "kind"]
key = ev[f = "key"]
fun pressed(k) = kind == "key" and key == k

-- The state after event t, each from the state before it.
dir = if pressed("ArrowLeft") then -1
      else if pressed("ArrowRight") then 1
      else (1 fby.t dir)
running = if pressed(" ") then not (true fby.t running)
          else (true fby.t running)
pos = if kind == "tick" and running then mod((0 fby.t pos) + dir, 40)
      else (0 fby.t pos)

track = restrict if #y == 2 and #x == pos then 1 else 0 to (x : 40, y : 5) end
-- table ev = t,f,value; 0,kind,tick; 0,key,""; 1,kind,tick; 1,key,""; 2,kind,tick; 2,key,""; 3,kind,key; 3,key,ArrowLeft; 4,kind,tick; 4,key,""; 5,kind,key; 5,key," "; 6,kind,tick; 6,key,""; 7,kind,tick; 7,key,""
-- expect pos[t = 2] = 3
-- expect pos[t = 4] = 2
-- expect running[t = 5] = false
-- expect pos[t = 7] = 2
-- expect track[t = 7, x = 2, y = 2] = 1

Open in playground

dot/deploy.json: a column holding the plot of track, as paint's holds canvas, and the ticks:

{
  "format": "elucid8-deploy/2",
  "inputs": { "ev": { "fill": {"missing": { "kind": "", "key": "" }} } },
  "window": {
    "title": "dot", "input": "ev", "tick": "100ms",
    "column": [
      { "plot": "{track}", "grow": 1, "colors": { "0": "#e8ecf4", "1": "#d0452a" } }
    ]
  }
}
elucid8 window program.el8

The dot moves as soon as the window opens. The table in the program is a short session: three ticks (the dot moves to 3), ← (it turns round), a tick (back to 2), Space (it stops), and two ticks that leave it where it is.

Three things to see in the program:

Modifiers and text typed. An input may also list shift, alt, ctrl, meta and cmd (Command on macOS, Ctrl elsewhere), sent as true or false with every event; cmd and key == "z" is then undo on every system. "chars": "chars" in the "window" section (or --chars chars) sends text typed as kind "typed", with the characters' code points as rows of a second input, chars = input("chars", t : inf, i : inf), at the same turn; in a window of several parts, a text part's "chars" does the same (below). Which keys are the window's own (Ctrl-C, Cmd-Q and Cmd-W end it) and every field an event can carry are in the Command reference.

A window of several parts

With a "window" section that names a container (row, column, grid, overlay, scroll), the window lays out a tree of parts: plots, labels, buttons, radios, checkboxes, sliders, choices and texts. Every property is a constant or a value of the program written in braces, "{name}"; any other string is literal text. A value is shown at its last turn. The dot, with controls beside it:

┌──────────────────────────────┐
│                              │
│  ■                           │
│                              │
└──────────────────────────────┘
  Dot
  position 1 · running
  ○ left
  ● right
  Speed
  ●─────────┼─────────┼
  ☑ Running
  [         Reset         ]

The window puts the panel beside the track; it is drawn below it here to fit a narrow screen.

dot-panel/program.el8:

-- The dot, with controls beside it. Every event is a turn of "ev",
-- with "node" the part it happened on.
ev = input("ev", t : inf, f : {"node", "kind", "key", "item", "value",
  "shift", "next", "prev", "takes"})
kind = ev[f = "kind"]
node = ev[f = "node"]
key = ev[f = "key"]
fun activated(n) = kind == "activate" and node == n
fun pressed(k) = kind == "key" and node == "track" and key == k

dir = if activated("dir") then ev[f = "item"]
      else if pressed("ArrowLeft") then -1
      else if pressed("ArrowRight") then 1
      else (1 fby.t dir)
speed = if node == "speed" and (kind == "press" or kind == "move" or kind == "release")
        then ev[f = "value"] else (1 fby.t speed)
running = if activated("running") or pressed(" ")
          then not (true fby.t running) else (true fby.t running)
pos = if activated("reset") then 0
      else if kind == "tick" and running then mod((0 fby.t pos) + dir * speed, 40)
      else (0 fby.t pos)
state = if running then "running" else "stopped"
focus = tab_focus(kind, key, ev[f = "shift"], node, ev[f = "next"],
  ev[f = "prev"], ev[f = "takes"], "track" fby.t focus)

track = restrict if #y == 2 and #x == pos then 1 else 0 to (x : 40, y : 5) end
-- table ev = t,f,value; 0,node,track; 0,kind,tick; 0,key,""; 0,item,0; 0,value,0; 0,shift,false; 0,next,""; 0,prev,""; 0,takes,false; 1,node,track; 1,kind,tick; 1,key,""; 1,item,0; 1,value,0; 1,shift,false; 1,next,""; 1,prev,""; 1,takes,false; 2,node,dir; 2,kind,activate; 2,key,""; 2,item,-1; 2,value,0; 2,shift,false; 2,next,""; 2,prev,""; 2,takes,false; 3,node,track; 3,kind,tick; 3,key,""; 3,item,0; 3,value,0; 3,shift,false; 3,next,""; 3,prev,""; 3,takes,false; 4,node,track; 4,kind,key; 4,key,Tab; 4,item,0; 4,value,0; 4,shift,false; 4,next,dir; 4,prev,reset; 4,takes,false
-- expect pos[t = 1] = 2
-- expect dir[t = 2] = -1
-- expect pos[t = 3] = 1
-- expect focus[t = 3] = "track"
-- expect focus[t = 4] = "dir"
-- expect state[t = 4] = "running"

Open in playground

dot-panel/deploy.json:

{
  "format": "elucid8-deploy/2",
  "inputs": {
    "ev": { "fill": {"missing": { "node": "", "kind": "", "key": "", "item": 0,
      "value": 0, "shift": false, "next": "", "prev": "", "takes": false }} }
  },
  "window": {
    "title": "dot", "input": "ev", "focus": "{focus}", "tick": "100ms",
    "row": [
      { "plot": "{track}", "grow": 1, "colors": { "0": "#e8ecf4", "1": "#d0452a" } },
      { "column": [
          { "label": "Dot", "style": "heading" },
          { "label": "position {pos} · {state}" },
          { "radio": "{dir}", "items": [["left", -1], ["right", 1]] },
          { "label": "Speed", "style": "heading" },
          { "slider": "{speed}", "min": 1, "max": 3, "step": 1 },
          { "checkbox": "{running}", "label": "Running" },
          { "button": "Reset", "id": "reset" }
        ], "width": "160px" }
    ]
  }
}
elucid8 window program.el8

The ticks come from the section's "tick", as the dot's did, and start when the window opens. A tick sent before the pointer has been over the track gives node as "".

Every event gives every field the input lists. A field the event does not concern comes as 0 for numbers, "" for names, keys and texts, and false for flags; a cell (x, y) as the one sent last, or the picture's first cell before the pointer has been over it. Before the first event the input has no row, so every field is eod there (no data yet); a program reads it through default where its first frame needs a value.

What each part shows. A plot shows the value it names in braces ("plot": "{track}"); any string not in braces is literal text. A label is a template: {pos} is replaced by pos at its last turn. A radio, a slider and a checkbox show the value they name: the radio marks the item whose number equals dir, the slider sits at speed, the checkbox is ticked while running is true. Pressing a control does not change it: it sends an event, and the program decides what the value becomes. That is why the checkbox and the Space key are one rule in the program.

Where each event goes. Every event is a turn of the section's input, with node the part it happened on: a part's id, else the value it shows ("track", "dir", "speed", "running", "reset").

youthe turn's rows
press, drag and release on the plotkind "press", "move", "release" (with the cell when the input lists the plot's dimensions)
a key while the plot has the focuskind "key", key
click a button or the checkboxkind "activate"
click a radio's itemkind "activate", item the item's number (here -1 or 1)
press, drag and release the sliderkind "press", "move", "release", value the value under the pointer
Tab or Shift-Tabkind "key", key "Tab", shift, and next and prev: the ids of the parts after and before the one with the focus
a tickkind "tick", node the plot the pointer was over last (none before it has been over one)

Focus. Keys go to the part with the focus, and the program says which part that is: the section's "focus" names a value, here focus, and the standard library's tab_focus computes it. On Tab it gives next, on Shift-Tab prev, on a press on a part that takes focus (the event's takes is true) that part, and otherwise the focus before. The table in the program is a session of three ticks, a click on "left" and a Tab: the focus moves from the track to the radio. Space and Enter on a focused button, checkbox or radio item click it.

Text size. Cmd-+ and Cmd-− (Ctrl-+ and Ctrl-− on Windows and Linux) make a window's text, controls and layout larger or smaller, from 80% to 250%, and Cmd-0 goes back to 100%. The window keeps its size, its layout fitting the window it has; a fitted picture is at most the size it has at 100% in that window, and smaller only so that the controls beside or below it stay in the window (never below its minWidth and minHeight, in the window's pixels whatever the text size); what still does not fit scrolls. The window remembers the size for your next window, which opens at a size that holds it, all of it on the screen. Only you resize a window. A program can offer the size in its own settings: the section's "textSize" names a value in percent, which the window takes whenever it changes, and an input that lists the field textSize is told the size with every event.

The window in its own file. A long section reads better on its own: "window": "window.json" in deploy.json names a file beside it whose first field is "format": "elucid8-window/1", then the section exactly as it would be written inline:

{
  "format": "elucid8-window/1",
  "title": "dot", "input": "ev", "focus": "{focus}", "tick": "100ms",
  "row": [ … ]
}

Both forms are read the same way; the four programs on this page keep their sections inline.

What check says. elucid8 check program.el8 says how it read each property, a line for the window and one per part, so you can see that every value in braces is the one you meant and every other string the words you meant. For the dot with controls:

window: focus from value focus; title "dot"
window plot track: shows from value track
window label (node 3): text "Dot"
window label (node 4): text "position {pos} · {state}" with values pos, state
window radio dir: shows from value dir
window slider speed: shows from value speed
window checkbox running: shows from value running; text "Running"
window button reset: text "Reset"

A window read from its own file adds window: read from window.json (format elucid8-window/1). A plain name where a value is meant is refused with the braces to write: window.column[1] (button).show: "shown" is literal text: a program value is written in braces, "{shown}".

How each field reads a string, as check reads it:

fieldsread
a leaf's own (plot, text, radio, checkbox, slider, choice), show, enabled, width, height, minWidth, maxWidth, minHeight, maxHeight, grow, x, y, top, scroll, position, left, scale, lines, min, max, step, selected, copy, wrap, hideComments, open, save, file, lengths, direction, a grid's columns and rows, marks, changed, cursor, anchor; the window's focus, textSize, appearance, addKey, removeKey; the sound's notes, stop, volume; an ask's texts, cancela value, "{name}", or a constant in its place (3, true, "160px", "fit")
title, label, buttonwords, with values in braces filled in: "fuel {fuel} of 150"
input, view, chars, fileLines, document; an ask's request, reply, replyTexts, replyCellsa channel's name, plain: "input": "ev"
id, undera node's id, plain
every other field (style, align, items, colors, tick, fontSize, …)a constant

Every kind of event, as the field kind names it (a text; a number is refused, with the name to write):

kindsent when
"press", "move", "release"the pointer on a plot, a text or a slider: a press, a move to another cell (or along the slider) while pressed, the release
"key"a key pressed, key its name
"typed"text typed into a text with chars (length, and the characters' code points in chars)
"paste"the paste key, with the clipboard's text attached the same way
"activate"a button, a checkbox, or a radio's or choice's item activated (item its number)
"tick"a tick (the section's tick, or --tick)
"file-opened", "file-saved"a file read into a text or written from it, or refused (error)
"sound"the sound started, or cannot (error; Sound)
"edit", "cursor"an editor's document changed (from, removed, length, by); its cursor and selection's anchor moved
"start", "close", "reply", "allow"a window with asks: its first turn, its last turn, an ask's reply, the Allow panel's answer
"api-key"Settings > Add key… or Remove (on Windows, Add key… has no dialog in this release: it says to give the key in a terminal with elucid8 key set, and sends nothing)
"wheel", "resize"on the section's view input only: the wheel over a text or plot, a text's or part's size changed
"key-release"reserved for key releases, and not sent in this release: a held key is one "key" event, so a program ends a note a set time after its press

A fill by field gives kind the empty text, "fill": {"missing": {"kind": ""}}, never a number. Before the first event the input has no row, so every field is eod there; past the session's last turn every field is eod too, so a query of a later turn answers eod.

Every property a part can take (sizes, grow, gap, show, enabled, headings and muted labels, panels) is in the Command reference.

Text

A text part shows a value of code points over lines and columns, in the window's monospaced font, and sends what is typed into it. A one-line field, line/program.el8:

-- A line you type into. Text typed (kind "typed") or pasted ("paste") comes
-- with its characters as code points in "chars" at the same turn.
ev = input("ev", t : inf, f : {"kind", "key", "length"})
chars = input("chars", t : inf, i : inf)
kind = ev[f = "kind"]
added = kind == "typed" or kind == "paste"
erased = kind == "key" and ev[f = "key"] == "Backspace"

-- The line's length after event t, and its characters.
len_before = 0 fby.t len
len = if added then len_before + ev[f = "length"]
      else if erased then max(len_before - 1, 0)
      else len_before
line_before = eod fby.t line
line = restrict if added and #col >= len_before and #col < len
                then chars[i = #col - len_before]
                else if #col < len then line_before else eod
       to (col : 60) end
-- table ev = t,f,value; 0,kind,press; 0,key,""; 0,length,0; 1,kind,release; 1,key,""; 1,length,0; 2,kind,typed; 2,key,""; 2,length,1; 3,kind,typed; 3,key,""; 3,length,1; 4,kind,typed; 4,key,""; 4,length,1; 5,kind,typed; 5,key,""; 5,length,1; 6,kind,key; 6,key,Backspace; 6,length,0; 7,kind,paste; 7,key,v; 7,length,5
-- table chars = t,i,value; 2,0,72; 3,0,105; 4,0,32; 5,0,120; 7,0,116; 7,1,104; 7,2,101; 7,3,114; 7,4,101
-- expect len[t = 5] = 4
-- expect len[t = 7] = 8
-- expect line[t = 7, col = 0] = 72
-- expect line[t = 7, col = 7] = 101
-- expect line[t = 7, col = 8] = eod

Open in playground

line/deploy.json (chars, which the window also sends its rows, needs no entry):

{
  "format": "elucid8-deploy/2",
  "inputs": {
    "ev": { "fill": {"missing": { "kind": "", "key": "", "length": 0 }} }
  },
  "window": {
    "title": "a line", "input": "ev",
    "column": [
      { "text": "{line}", "lines": 1, "width": 40, "chars": "chars", "cursor": [0, "{len}"] },
      { "label": "{len} characters", "style": "muted" }
    ]
  }
}
elucid8 window program.el8

Click the field and type. The table in the program is a click, H, i, a space, x, Backspace, and a paste of there: the line then reads Hi there, with 8 characters. A key that types text is a turn of kind "typed" with length its number of characters, and the characters are rows of chars at that turn (2,0,72 is turn 2's first character, code point 72, H). A paste (Cmd-V on macOS, Ctrl-V elsewhere) is kind "paste" with the clipboard's text the same way, so added takes both. Backspace is a key like any other, kind "key".

line keeps the characters it had and puts each new one at the end: column len_before + i takes the turn's character i. Columns from len on are eod, so Backspace only shortens len.

"lines": 1 makes the text a one-line field; its value may be over columns alone, as line is. "cursor" gives the caret's line and column (a pair of constants or values); "width": 40 is its width in characters.

A whole editor. The editor app above is a text of many lines with everything a text part offers. Its text part, from its deploy.json:

{ "text": "{doc}", "id": "editor", "chars": "chars", "cursor": ["{cl}", "{cc}"], "anchor": ["{al}", "{ac}"],
  "scroll": "{top}", "left": "{left}", "lines": "{nlines}", "copy": "{copy_now}",
  "file": "{file_name}", "open": "{open_now}", "save": "{save_now}", "editor": true, "wrap": true,
  "lengths": "{len}", "changed": ["{ch_from}", "{ch_removed}", "{ch_length}"],
  "grow": 1 }

"editor": true makes it a code editor. The window keeps the editor's document, and the program reads it as an input, by default the one named after the editor's id:

editor = input("editor", t : inf, line : inf, col : inf)

At each turn the input holds the whole document after that turn, one code point a cell, eod past the end of a line and below the last line ("document" names another input for it). Every change of the document is a turn of the window's input of kind "edit", with from (the first line replaced), removed (how many lines) and length (how many lines took their place), and by, who made it:

The code editor also says where its cursor and the selection's anchor are, as a turn of kind "cursor" with line, col, anchorLine and anchorCol, so the program can show the cursor's place (the editor's status line does).

The Command reference gives every role of a text, and what a refused open or save sends.

Sound

A window can play notes. The program computes note events, never sound waves, and the window plays them on the computer's audio. In "window":

"sound": { "notes": "{notes}", "stop": "{stop_tune}", "volume": "{volume}" }

notes names a value that is, at each turn of the window's input, the list of that turn's note events, each a record {by, ms, note, on, velocity}:

press = if kind == "key" and key == "a" then [{by: "you", ms: time(ev[f = "kind"]), note: 60, on: true, velocity: 96}] else []

The window reads notes at every turn, so no note is lost when several events arrive together. Each (by, note) pair is one voice: a note started again restarts it, a note stopped releases it, and at most 32 voices sound at once (a new one takes the oldest one's place). Among a turn's events a stop comes before a start at the same time. A note whose time has passed sounds at once; one more than 100 ms late is left out (and counted). Each note is a computed piano-like tone that fades over a few seconds.

stop (true, false, or a value in braces, "{stop_tune}") stops every note of by "tune" at the turns it is true, including those scheduled ahead; "stop": {"value": "{stop_song}", "by": "song"} stops another source's. volume is 0 to 100, a number or a value in braces (100 without it).

When the sound has started, or cannot, the window sends its input a turn with kind "sound" and the field error: "" when the sound is ready, or "no audio device", "not allowed" or "failed", so the program can say so (Sound is off: no audio device was found). elucid8 check prints what the section plays and refuses a value it cannot read at each turn.

Reading the apps' programs

Each app's program.el8 is written with what the sections above teach, and its comments say what each part does:

Testing an app without a screen

An app runs with no window at all, for tests, continuous integration and AI assistants that cannot see a screen. --headless opens nothing, --tree-script gives the steps a person would take, and --record keeps every row the window sent, so that elucid8 run can check any answer afterwards. In the dot app's folder (above), three ticks, the left arrow and one more tick, then the dot's place after them:

elucid8 window program.el8 --headless --tree-script "tick; tick; tick; key ArrowLeft; tick" --record session
elucid8 run program.el8 --session session --query "pos[t = 4]"

run prints the answer the window showed at turn 4: the dot at cell 2, timestamped with that event's time:

{"name":"pos","context":{"t":4},"outcome":{"kind":"value","value":2,"ts":50}}

The steps are played in order, separated by ;, then the run ends. Each step is one event, sent to the program as the window sends it; nodes are named by their id. In a scripted run the k-th event's time (what time(…) reads) is k × 10 ms.

stepthe event
click ID, click ID FX,FYa press and a release on node ID: at its middle, or at fractions FX, FY of its width and height (a button, a checkbox, a choice, a picture's cell)
down ID FX,FY, move ID FX,FY, upthe pointer pressed, moved while pressed, released
item ID Kthe item of a radio or a choice whose number (in its items pair) is K, chosen
slide ID down V, slide ID move V, slide ID up Va slider pressed, dragged and released at value V
key NAMEa key, named as a browser names it (a, Enter, Escape, ArrowLeft); shift+, ctrl+, alt+ or cmd+ before the name holds that modifier (key cmd+s); key followed by a space is the space bar
paste TEXTTEXT pasted into the focused text
focus IDthe keyboard focus given to node ID
wheel ID DYthe wheel over node ID, DY lines down
ticka tick, as the window sends one every tick (the window section needs a tick, or give --tick)
resize W,Hthe window resized to W × H logical pixels
sound readythe window's report that its sound started; sound no audio device, sound not allowed and sound failed report that it did not
aboutthe About panel opened

A headless or scripted run never reads or writes your settings (appearance, text size, panels seen) and never opens the About panel by itself.

The session. --record DIR makes the folder DIR (or takes an empty one, or replaces the session an earlier run kept there; a folder holding other files is refused) and writes, as the window runs:

--record works the same in a window on your screen: it keeps what you did, to replay and check later. elucid8 run --session DIR and elucid8 check --session DIR read each input the window feeds from the session's file for it, so every answer is the one the window showed at that turn, and the turns after the session's last are eod.

Sound. With the variable ELUCID8_WINDOW_SOUND_LOG set to a file name, the window writes what it decided to play as JSON lines: a line saying the sound's settings ({"sound": "notes", "lateMs": 100, "voices": 32}), a line for each note event (turn, by, note, action: start, restart, stop, late, refused or ignored, and at, its time on the events' clock), a line for each voice cancelled or stopped, and the counts when the window ends. A headless run plays no sound, but its log is the same, so a test can check that a key starts its note and a Stop stops the tune.

Where it runs

elucid8 window opens a window on macOS and on Windows with the command from the Download page. On Linux the Download page offers two builds: the desktop build opens the window, and needs glibc 2.35 or later (Ubuntu 22.04, Debian 12, Fedora 36 and newer) and WebKitGTK 4.1 (sudo apt install libwebkit2gtk-4.1-0 on Debian and Ubuntu, webkit2gtk4.1 on Fedora, webkit2gtk-4.1 on Arch); the static build runs on any distribution (servers, Docker, Alpine) with every other command, and there elucid8 window says how to get the desktop build. The install command installs the desktop build where it finds glibc 2.35 and WebKitGTK 4.1, and the static build elsewhere. With no display (a server, an SSH session), the desktop build runs every other command as the static build does, and elucid8 window says what is missing. The window is drawn by the system's web view: WebKit on macOS and on Linux's desktop build, Microsoft's WebView2 Runtime on Windows (part of Windows 11; where it is missing, elucid8 window prints one line saying so, with the address of Microsoft's page for it).