Skip to content
Beskid Platform specification

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

Examples

Spec standingStandard

Owner
Piotr Mikstacki
Submitter
Piotr Mikstacki

Document examples for the Ansi Escape Model feature: role-specific normative detail beyond the feature hub.

  • Feature hub: Ansi Escape Model
  • Sibling articles in this bundle (design model, contracts, flow, examples, verification)
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+001B
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.

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.

string line = Ansi.Sgr.Start()
.Bold()
.FgBasic(31)
.ApplyTo("error");
System.Output.WriteLine(line);

ApplyTo appends gated ESC[0m when attributes were applied.

string save = Ansi.Escape.EmitDec("7");
string restore = Ansi.Escape.EmitDec("8");
System.Output.Write("${save}");
// draw status line
System.Output.Write("${restore}");

Prefer DEC sequences over SCO ESC[s / ESC[u per decision D-TC-001.

See the verification and traceability article in this bundle and compiler/corelib/beskid_corelib/tests/corelib_tests/src/console/.