AtlatestRenderedmarkdown
Readme

sigil-vt

The native VT/ANSI terminal core for the Sigil ecosystem — a VT100/xterm-subset terminal emulator in C: an incremental byte stream → a damage-tracked int32[4]-per-cell grid, with scrollback, cursor-report / device-attribute replies, an out-of-band event queue (title / bell / OSC-52 clipboard), mouse-mode flags, and native style-merged row-run extraction (the render seam).

It is the shared native foundation for terminal handling across the ecosystem: slate's (slate term) rides it as a thin façade (byte-identical take-frame), and (sigil tui grid) will ride it in M3. See the design note topics/sigil-terminal-handling-design.

This is the native reimplementation of slate's (slate term) emulator — the Sigil emulator is the spec; native/vt.c reproduces its semantics cell-for-cell, proven by test/vt-test.sgl (a faithful port of slate's test/term-test.sgl).

Layout

  • native/vt.c — the C core (parser state machine + grid + damage/scrollback/ replies/events + row-runs). Registered as %vt-* builtins in module (sigil vt).
  • src/sigil/vt.sgl — the (sigil vt) Scheme surface (thin wrappers + the public API, shaping damage into a dict etc.).
  • test/vt-test.sgl — the conformance suite.

Cell model

Flat int32_t buffer, cell (row,col) at ((row*cols+col)*4): [codepoint, attrs, fg, bg]. Attr bits: bold 1, dim 2, italic 4, underline 8, blink 16, inverse 32, hidden 64, strike 128; high bits reserved for wide/continuation (wcwidth deferred). Colors: -1 default, 0..255 indexed, #x1000000 + #xRRGGBB truecolor.

Trust boundary

Terminal bytes are UNTRUSTED program output. The parser converts arbitrary bytes into a CLOSED vocabulary of grid operations — no escape sequence executes anything, reaches an eval, or emits markup. Params/sub-params/OSC accumulators are fixed-capacity; no allocation is sized by input params. The core never calls back into Scheme. Fuzzed + ASan/UBSan-clean on vt-feed-bytes! (see spike/).

Build / test (development, against a local monorepo checkout)

sigil deps install --redirects dev-redirects.sgl
sigil build        --redirects dev-redirects.sgl
sigil test         --redirects dev-redirects.sgl

Not here

No vt-diff (the grid-diff ANSI emitter) — deferred to M3 (the sigil-tui revival). The cell repr is designed to account for it.