From 030048d39c8ce353cca8842a9ad0ab2765290e59 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Fri, 25 Sep 2026 13:01:12 +0100 Subject: 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. --- examples/notes.aup | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 examples/notes.aup (limited to 'examples') 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 -- cgit v1.2.3