aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/design/001-first-component.md2
-rw-r--r--examples/tally.aup38
2 files changed, 39 insertions, 1 deletions
diff --git a/docs/design/001-first-component.md b/docs/design/001-first-component.md
index 0a747fc..1da0fdf 100644
--- a/docs/design/001-first-component.md
+++ b/docs/design/001-first-component.md
@@ -155,7 +155,7 @@ CLI나 문장 표면이 그대로 이어받는다. Vega에도 앱에도 저장 �
- 가상 터미널에서 대화형 TUI를 실제로 띄워 입력·확정·키 모드·종료·터미널 복원을 확인한다.
- 한 저장소를 CLI와 문장 표면이 번갈아 이어 쓰며(시드마다 7번) 매번 모델과 같은 목록을 보이고, 대화형 세션에서 입력한
것이 다음 실행에 남는다.
-- aup와 Vega의 예제 11개를 세 표면에 무작위 입력으로 돌려 비정상 종료가 없다. sanitizer 빌드로도 같은 검사를 통과한다.
+- aup와 Vega의 예제 14개를 세 표면에 무작위 입력으로 돌려 비정상 종료가 없다. sanitizer 빌드로도 같은 검사를 통과한다.
- 규약을 여덟 가지로 어긴 명세에서 `vega check`가 아홉 곳을 모두 정확한 문장으로 알리고, 예제에서는 아무것도 알리지
않는다.
- 걸러진 두 목록(`examples/today.aup`)의 CLI 출력이 무작위 추가·이동·완료·양쪽 목록 가리키기 1,600단계에서 모델과
diff --git a/examples/tally.aup b/examples/tally.aup
new file mode 100644
index 0000000..5c3d9e9
--- /dev/null
+++ b/examples/tally.aup
@@ -0,0 +1,38 @@
+# Words typed, tallied. A list keyed by the word keeps each word once and in
+# order: the screen is sorted without a sort anywhere, and typing a word
+# again counts it and moves the focus to it.
+use vega
+
+record Tally {
+ word: text
+ times = 0
+}
+
+state tallies: list of Tally by word
+state at: index of tallies
+
+input add = text
+input up = key ArrowUp
+input down = key ArrowDown
+input drop = key Delete
+
+on add {
+ if !tallies.has(add) {
+ tallies.add(Tally { word: add })
+ }
+ tallies[add].times = tallies[add].times + 1
+ at = tallies[add]
+}
+on up.down { at = at - 1 }
+on down.down { at = at + 1 }
+on drop.down { tallies.remove(at) }
+
+view title = "Tally"
+view typed = "{sum(t.times for t in tallies)} typed, {tallies.count} different"
+
+view tallies_list = each t in tallies {
+ label = t.word
+ badge = "{t.times}"
+ tone = vega.when(t.times > 1, vega.accent)
+}
+view tallies_list_focus = at.position