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
This is the native reimplementation of slate's `(slate term)` emulator — **the15
Sigil emulator is the spec**; `native/vt.c` reproduces its semantics cell-for-cell,16
proven by `test/vt-test.sgl` (a faithful port of slate's `test/term-test.sgl`).18
## Layout20
- `native/vt.c` — the C core (parser state machine + grid + damage/scrollback/21
replies/events + row-runs). Registered as `%vt-*` builtins in module `(sigil vt)`.22
- `src/sigil/vt.sgl` — the `(sigil vt)` Scheme surface (thin wrappers + the23
public API, shaping damage into a dict etc.).24
- `test/vt-test.sgl` — the conformance suite.26
## Cell model28
Flat `int32_t` buffer, cell `(row,col)` at `((row*cols+col)*4)`:29
`[codepoint, attrs, fg, bg]`. Attr bits: bold 1, dim 2, italic 4, underline 8,30
blink 16, inverse 32, hidden 64, strike 128; high bits reserved for31
wide/continuation (wcwidth deferred). Colors: `-1` default, `0..255` indexed,32
`#x1000000 + #xRRGGBB` truecolor.34
## Trust boundary36
Terminal bytes are UNTRUSTED program output. The parser converts arbitrary bytes37
into a CLOSED vocabulary of grid operations — no escape sequence executes38
anything, reaches an eval, or emits markup. Params/sub-params/OSC accumulators39
are fixed-capacity; no allocation is sized by input params. The core never calls40
back into Scheme. Fuzzed + ASan/UBSan-clean on `vt-feed-bytes!` (see `spike/`).42
## Build / test (development, against a local monorepo checkout)44
```45
sigil deps install --redirects dev-redirects.sgl46
sigil build --redirects dev-redirects.sgl47
sigil test --redirects dev-redirects.sgl48
```50
## Not here52
No `vt-diff` (the grid-diff ANSI emitter) — deferred to M3 (the sigil-tui53
revival). The cell repr is designed to account for it.