aboutsummaryrefslogtreecommitdiffstats
path: root/examples/scores.aup
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-09-25 15:24:05 +0100
committereunhhu <[email protected]>2026-09-25 15:24:05 +0100
commit12c377ea70c8928f96d02d0885744bd6818c10c6 (patch)
treee2ba24cb2cd61394ff84f605daa54d8c8e36a0d1 /examples/scores.aup
parentd9dbe8a1dbdd30f3e336dc1445d852ede3de3930 (diff)
downloadvega-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/scores.aup')
-rw-r--r--examples/scores.aup35
1 files changed, 35 insertions, 0 deletions
diff --git a/examples/scores.aup b/examples/scores.aup
new file mode 100644
index 0000000..14620e9
--- /dev/null
+++ b/examples/scores.aup
@@ -0,0 +1,35 @@
+# A table: a table view without a label column. Every column shows; a tone
+# column colors a row.
+use vega
+
+record Player {
+ name: text
+ score = 0
+}
+
+state players: list of Player
+state at: index of players
+
+input join = text
+input up = key ArrowUp
+input down = key ArrowDown
+input win = key KeyW
+input lose = key KeyL
+
+on join {
+ players.append(Player { name: join })
+ at = players.last
+}
+on up.down { at = at - 1 }
+on down.down { at = at + 1 }
+on win.down { at.score = at.score + 1 }
+on lose.down { at.score = at.score - 1 }
+
+view title = "Scores"
+view board = each p in players {
+ name = p.name
+ score = p.score
+ rank = if p.score > 2 { "gold" } else if p.score > 0 { "silver" } else { "-" }
+ tone = if p.score < 0 { vega.danger } else { vega.when(p.score > 2, vega.good) }
+}
+view board_focus = at.position