diff options
| author | eunhhu <[email protected]> | 2026-09-25 15:24:05 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-25 15:24:05 +0100 |
| commit | 12c377ea70c8928f96d02d0885744bd6818c10c6 (patch) | |
| tree | e2ba24cb2cd61394ff84f605daa54d8c8e36a0d1 /examples/todo.aup | |
| parent | d9dbe8a1dbdd30f3e336dc1445d852ede3de3930 (diff) | |
| download | vega-12c377ea70c8928f96d02d0885744bd6818c10c6.tar.gz vega-12c377ea70c8928f96d02d0885744bd6818c10c6.zip | |
Add the first component and three surfaces
Vega reads a verified Pure module by convention: a table view with a
label column is a list (with optional badge, detail and tone), any other
table is a table, <table>_focus is its focused row, a title view is the
title and other views are fields. lib/vega.aup gives aup apps the tones,
which say what a row means; each surface decides how it looks or sounds.
vega tui draws the screen in a terminal, keeps the focused row in view
and evaluates only the cells on screen; vega cli prints plain lines for
pipes; vega say speaks the screen and each focus change as sentences.
Display width handles Hangul, CJK, emoji, combining marks and controls.
tests/check.py compares the CLI and NUI output with a reference model of
examples/todo.aup line for line, checks 9,600 TUI frames for scrolling,
focus, badge alignment and the number of cells evaluated, drives the
interactive TUI on a pseudo-terminal, and runs every aup example on every
surface.
Diffstat (limited to 'examples/todo.aup')
| -rw-r--r-- | examples/todo.aup | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/examples/todo.aup b/examples/todo.aup new file mode 100644 index 0000000..a5ee3b0 --- /dev/null +++ b/examples/todo.aup @@ -0,0 +1,40 @@ +# A to-do list as Vega reads it: one spec, shown by the terminal (vega tui), +# printed for pipes (vega cli) and spoken as sentences (vega say). +use vega + +record Task { + title: text + done = 0 + urgent = 0 +} + +state tasks: list of Task +state at: index of tasks + +input add = text +input up = key ArrowUp +input down = key ArrowDown +input toggle = key Space +input urgent = key KeyU +input drop = key Delete + +on add { + tasks.append(Task { title: add }) + at = tasks.last +} +on up.down { at = at - 1 } +on down.down { at = at + 1 } +on toggle.down { at.done = !at.done } +on urgent.down { at.urgent = !at.urgent } +on drop.down { tasks.remove(at) } + +view title = "To do" +view left = "{tasks.count} tasks" + +# A list: label, and optionally tone, badge and detail per row. +view tasks_list = each task in tasks { + label = task.title + badge = if task.done { "done" } else if task.urgent { "urgent" } else { "" } + tone = if task.done { vega.muted } else { vega.when(task.urgent, vega.danger) } +} +view tasks_list_focus = at.position |
