Authors need portable cursor stacking without SCO-specific CSI variants in typed builders.
Examples
Platform spec article
Examples
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).
Purpose
Section titled “Purpose”Document examples for the Ansi Escape Model feature: role-specific normative detail beyond the feature hub.
Canonical references
Section titled “Canonical references”- Feature hub: Ansi Escape Model
- Sibling articles in this bundle (design model, contracts, flow, examples, verification)
Detailed behavior
Section titled “Detailed behavior”Bold red foreground (CSI m)
Section titled “Bold red foreground (CSI m)”string esc = Ansi.Escape.Esc();string seq = Ansi.Escape.EmitCsi("1;31", "m");System.Output.Write("${seq}Hello${Ansi.Sgr.ResetSuffix()}");Ungated framing for tests:
string raw = Ansi.Escape.CsiSequence("1;31", "m");// raw == "\x1b[1;31m" when Esc() is U+001BCursor home and clear display
Section titled “Cursor home and clear display”string moves = Ansi.Cursor.IntoSequence( Ansi.Cursor.Home(Ansi.Cursor.Start()));string clear = Ansi.Erase.IntoSequence( Ansi.Erase.DisplayAll(Ansi.Erase.Start()));System.Output.Write("${moves}${clear}");When ShouldEmitAnsi() is false, IntoSequence returns "" for both builders.
Alternate screen buffer
Section titled “Alternate screen buffer”string on = Ansi.Escape.WhenEnabled(Ansi.Escape.PrivateMode("1049", true));string off = Ansi.Escape.WhenEnabled(Ansi.Escape.PrivateMode("1049", false));Golden tests call PrivateMode without gating to assert framing bytes.
Fluent SGR with automatic reset
Section titled “Fluent SGR with automatic reset”string line = Ansi.Sgr.Start() .Bold() .FgBasic(31) .ApplyTo("error");System.Output.WriteLine(line);ApplyTo appends gated ESC[0m when attributes were applied.
DEC save / restore around progress render
Section titled “DEC save / restore around progress render”string save = Ansi.Escape.EmitDec("7");string restore = Ansi.Escape.EmitDec("8");System.Output.Write("${save}");// draw status lineSystem.Output.Write("${restore}");Prefer DEC sequences over SCO ESC[s / ESC[u per decision D-TC-001.
Verification
Section titled “Verification”See the verification and traceability article in this bundle and compiler/corelib/beskid_corelib/tests/corelib_tests/src/console/.
Related topics
Section titled “Related topics”- Parent feature hub and Terminal and console area