Authors need portable cursor stacking without SCO-specific CSI variants in typed builders.
ANSI escape model
Platform spec feature
ANSI escape model
Spec standingStandard
-
Normative cursor save/restore uses DEC sequences, not SCO.
Context
Decision
Rule Detail Save/restore DEC ESC 7/ESC 8is the normative pairSCO CSI s/CSI uare not required in v1 typed buildersConsequences
Typed
Ansi.Cursorhelpers emit DEC only; rawCsimay still be used in tests.Verification anchors
AnsiEscapeTests.bd;ANSI.mdtables. -
Styled emission must respect ShouldEmitAnsi and non-TTY hosts.
Context
Programs must not leak escapes to pipes, log files, or NO_COLOR environments.
Decision
Rule Detail Gating User-visible styled output must pass Ansi.Escape.WhenEnabledTests Ungated Csiremains for golden testsConsequences
When
ShouldEmitAnsi()is false, gated builders return empty strings.Verification anchors
AnsiEscapeTests.bd; console capability integration. -
Truecolor sequences downgrade via EffectiveColorModel.
Context
Terminals differ in color depth; emitting unsupported
38;2breaks dumb hosts.Decision
Rule Detail Ladder truecolor → 256 → basic per EffectiveColorModelPolicy Callers do not pick per-sequence models manually Consequences
SGR builders consult capability probes before emitting RGB CSI.
Verification anchors
AnsiSgrGoldenTests.bd;CapabilitiesTests.bd. -
OSC payloads terminate with BEL, not ST.
Context
OSC framing varies across terminals; v1 picks one terminator for golden tests.
Decision
Rule Detail Terminator BEL ( 0x07) in v1ST ESCtermination is not requiredConsequences
OSC helpers emit BEL-terminated sequences only until a future ADR extends ST.
Verification anchors
AnsiEscapeTests.bd;Ansi.Oscsources.
- Contracts and edge cases MUST/SHOULD rules for escape emission and supported sequence subsets.
- Design model ESC/CSI/OSC taxonomy and normative control-character tables for terminal output.
- Examples Representative escape composition and gated emission patterns.
- Flow and algorithm How escape bytes are composed, gated, and written to stdout.
- Verification and traceability Golden tests and source anchors for ANSI escape framing.
0 revisions (git unavailable at build; counts may be empty)
No commits recorded for this path.
| Section id | Required | Found |
|---|---|---|
what-this-feature-specifies | yes | yes |
implementation-anchors | yes | yes |
Full tree: run pnpm verify:platform-spec-layout (writes src/generated/platform-spec-layout-report.json).
What this feature specifies
Normative terminal escape framing for corelib_console: how Ansi.Escape, Ansi.Cursor, Ansi.Erase, Ansi.Sgr, Ansi.Screen, and Ansi.Osc compose bytes that terminals interpret. Tables in the design model article match repository ANSI.md; this hub states package boundaries and emission rules shared with Console capabilities.
Contract statement
- ESC is ASCII U+001B (decimal 27). Implementations must use a single-byte ESC; language-specific
\eescapes are informative only. - CSI sequences must use the form
ESC [+ parameter bytes + final byte (semicolon-separated numeric parameters; optional spaces may appear between parameters and are ignored when parsing). - Private CSI modes use
?before parameters and final byteh(set) orl(reset). - DEC single-character sequences (
ESC 7/ESC 8save/restore cursor) are the preferred save/restore form; SCOESC[s/ESC[uare not required in v1. - User-visible emission must pass through
Ansi.Escape.WhenEnabled(or builders that call it) so non-TTY andNO_COLORhosts receive empty styled output, not raw escapes. - Sequences marked de-facto in
ANSI.mdbut not implemented in corelib may be emitted only via rawCsi/OscSequencehelpers; they are not conformance-tested until listed in contracts and edge cases.
Implementation anchors
compiler/corelib/packages/console/src/Ansi/- Informative aggregate reference: repository root
ANSI.md - Golden tests:
compiler/corelib/beskid_corelib/tests/corelib_tests/src/console/AnsiEscapeTests.bd,AnsiSgrGoldenTests.bd
Decisions
Section titled “Decisions”No open decisions. Closed choices are normative ADRs under adr/ (D-CORE-TERM-0001 … D-CORE-TERM-0004); use the reader ADRs tab for expandable detail.
Articles
- DEC save/restore cursor pairNormative cursor save/restore uses DEC sequences, not SCO.
- Contracts and edge casesMUST/SHOULD rules for escape emission and supported sequence subsets.
- Design modelESC/CSI/OSC taxonomy and normative control-character tables for terminal output.
- ExamplesRepresentative escape composition and gated emission patterns.
- Flow and algorithmHow escape bytes are composed, gated, and written to stdout.
- Verification and traceabilityGolden tests and source anchors for ANSI escape framing.