diff options
| author | eunhhu <[email protected]> | 2026-09-25 13:01:12 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-25 13:01:12 +0100 |
| commit | 030048d39c8ce353cca8842a9ad0ab2765290e59 (patch) | |
| tree | f6ca81ab670705b9e3d505e5410fcf2a9cd9735d /examples/notes.aup | |
| parent | 3265bc65ef6d2e399be6141f678f4f299a2d7491 (diff) | |
| download | aup-030048d39c8ce353cca8842a9ad0ab2765290e59.tar.gz aup-030048d39c8ce353cca8842a9ad0ab2765290e59.zip | |
Compile text, cursors and strings to module v3
aup now emits Pure module v3 and adds text states with string initializers,
cursors bound to a text, text inputs, string literals with escapes and
{interpolation} of numbers and text, cursor distances in chars and lines,
.start/.end, insert/remove, name.line(cursor), .chars/.lines/.bytes on text,
.chars/.line on cursors, and text(bytes)/bytes(text). Replies and replace
accept text as its UTF-8 bytes. Views are numbers or text. Up to 32 inputs.
examples/notes.aup is a small editor. make check replays random typing
(ASCII, Korean, emoji, combining marks, NUL, newlines), moves and deletions
against a Python reference model: 4,800 snapshots of text, cursor, mark and
views match. It also checks escapes and number text, 16 new diagnostics, a
document loaded into text and saved back, and all earlier parity; the
compiler and the Pure executor each pass under ASan/UBSan.
Diffstat (limited to 'examples/notes.aup')
| -rw-r--r-- | examples/notes.aup | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/examples/notes.aup b/examples/notes.aup new file mode 100644 index 0000000..fdc91b8 --- /dev/null +++ b/examples/notes.aup @@ -0,0 +1,35 @@ +# A small text editor. The runtime owns the text: typing inserts at the +# cursor, the cursor and the mark always sit between characters and follow +# edits, and a failed event would leave everything as it was. +state title: text = "메모" +state note: text = "" +state at: cursor in note +state mark: cursor in note + +input typed = text +input left = key ArrowLeft +input right = key ArrowRight +input up = key ArrowUp +input down = key ArrowDown +input back = key Backspace +input forward = key Delete +input home = key Home +input finish = key End +input set_mark = key KeyM + +on typed { note.insert(at, typed) } +on left.down { at = at - 1 char } +on right.down { at = at + 1 char } +on up.down { at = at - 1 line } +on down.down { at = at + 1 line } +on back.down { note.remove(at - 1 char .. at) } +on forward.down { note.remove(at .. at + 1 char) } +on home.down { at = note.start } +on finish.down { at = note.end } +on set_mark.down { mark = at } + +view header = "{title} · {note.chars}자" +view current = note.line(at) +view position = "line {at.line}, char {at.chars}" +view size = note.bytes +view lines = note.lines |
