AtlatestRepositorysigil-vt
1
# sigil-vt3
The native VT/ANSI terminal core for the Sigil ecosystem — a VT100/xterm-subset4
terminal emulator in C: an incremental byte stream → a damage-tracked5
`int32[4]`-per-cell grid, with scrollback, cursor-report / device-attribute6
replies, an out-of-band event queue (title / bell / OSC-52 clipboard), mouse-mode7
flags, and native style-merged **row-run** extraction (the render seam).9
It is the shared native foundation for terminal handling across the ecosystem:10
slate's `(slate term)` rides it as a thin façade (byte-identical `take-frame`),11
and `(sigil tui grid)` will ride it in M3. See the design note12
`topics/sigil-terminal-handling-design`.14
The parser supports VT100 G0/G1 ASCII and DEC Special Graphics designation,15
SI/SO selection, and saved-cursor restoration of those character sets. This16
renders tmux/ncurses line drawing as Unicode in the grid, scrollback and row17
runs. Ordinary Unicode output is preserved.19
This is the native reimplementation of slate's `(slate term)` emulator — **the20
Sigil emulator is the spec**; `native/vt.c` reproduces its semantics cell-for-cell,21
proven by `test/vt-test.sgl` (a faithful port of slate's `test/term-test.sgl`).23
## Layout25
- `native/vt.c` — the C core (parser state machine + grid + damage/scrollback/26
replies/events + row-runs). Registered as `%vt-*` builtins in module `(sigil vt)`.27
- `src/sigil/vt.sgl` — the `(sigil vt)` Scheme surface (thin wrappers + the28
public API, shaping damage into a dict etc.).29
- `test/vt-test.sgl` — the conformance suite.31
## Cell model33
Flat `int32_t` buffer, cell `(row,col)` at `((row*cols+col)*4)`:34
`[codepoint, attrs, fg, bg]`. Attr bits: bold 1, dim 2, italic 4, underline 8,35
blink 16, inverse 32, hidden 64, strike 128; high bits reserved for36
wide/continuation (wcwidth deferred). Colors: `-1` default, `0..255` indexed,37
`#x1000000 + #xRRGGBB` truecolor.39
## Trust boundary41
Terminal bytes are UNTRUSTED program output. The parser converts arbitrary bytes42
into a CLOSED vocabulary of grid operations — no escape sequence executes43
anything, reaches an eval, or emits markup. Params/sub-params/OSC accumulators44
are fixed-capacity; no allocation is sized by input params. The core never calls45
back into Scheme. Fuzzed + ASan/UBSan-clean on `vt-feed-bytes!` (see `spike/`).47
## Build / test (development, against a local monorepo checkout)49
```50
sigil deps install --redirects dev-redirects.sgl51
sigil build --redirects dev-redirects.sgl52
sigil test --redirects dev-redirects.sgl53
```55
## Not here57
No `vt-diff` (the grid-diff ANSI emitter) — deferred to M3 (the sigil-tui58
revival). The cell repr is designed to account for it.