Skip to content
Beskid Platform specification

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

Design model

Spec standingStandard

Owner
Piotr Mikstacki
Submitter
Piotr Mikstacki

Normative ESC / CSI / OSC taxonomy and sequence tables used by corelib_console Ansi.* builders, aligned with repository ANSI.md.

The ANSI escape model describes how bytes on a terminal byte stream are interpreted as control functions versus printable text. corelib_console maps this model to composable builders.

All standard escape codes are introduced by ESC (U+001B). Equivalent literal forms include \x1B, \033, and decimal 27.

FamilyIntroducerRole
ESCESC + final byteSingle-byte controls (e.g. DEC save ESC 7)
CSIESC [ or byte 0x9BParameterized controls (cursor, erase, SGR, modes)
DCSESC P or 0x90Device control strings (not used in v1 corelib)
OSCESC ] or 0x9DOperating-system commands (title, hyperlinks subset)

CSI parameters are semicolon-separated. Example: \x1b[1;31m sets bold red foreground (SGR 1 + color 31, final byte m).

NameDecHexC-escapeDescription
BEL70x07\aTerminal bell
BS80x08\bBackspace
HT90x09\tHorizontal tab
LF100x0A\nLine feed
VT110x0B\vVertical tab
FF120x0C\fForm feed
CR130x0D\rCarriage return
ESC270x1B(no portable \e)Escape
DEL1270x7FDelete

Stream helpers in Console I/O streams write UTF-8 string bytes; control characters above are ordinary string contents at the syscall boundary.

SequenceDescription
ESC[HCursor home (1,1)
ESC[{line};{column}H or fCursor to line, column
ESC[#AUp # lines
ESC[#BDown # lines
ESC[#CRight # columns
ESC[#DLeft # columns
ESC[#ECursor to beginning of next line, # lines down
ESC[#FCursor to beginning of previous line, # lines up
ESC[#GCursor to column #
ESC[6nRequest cursor position (reply ESC[row;colR)
ESC MReverse index (scroll if needed)
ESC 7 / ESC 8DEC save / restore cursor
ESC[s / ESC[uSCO save / restore (non-normative for Beskid builders)

Ansi.Cursor fluent steps map to the CSI rows above; save/restore uses DEC per hub decision D-TC-001.

SequenceDescription
ESC[J / ESC[0JErase from cursor to end of display
ESC[1JErase from cursor to start of display
ESC[2JErase entire display
ESC[3JErase saved lines (scrollback)
ESC[K / ESC[0KErase from cursor to end of line
ESC[1KErase from start of line to cursor
ESC[2KErase entire line

Erasing a line does not move the cursor; callers should emit \r when the cursor must return to column 1.

SequenceResetDescription
ESC[0mReset all attributes
ESC[1mESC[22mBold
ESC[2mESC[22mDim
ESC[3mESC[23mItalic
ESC[4mESC[24mUnderline
ESC[5mESC[25mBlink
ESC[7mESC[27mInverse
ESC[8mESC[28mHidden
ESC[9mESC[29mStrikethrough

Ansi.Sgr builds semicolon-joined parameter lists and wraps them in EmitCsi(..., "m").

ColorForegroundBackground
Black3040
Red3141
Green3242
Yellow3343
Blue3444
Magenta3545
Cyan3646
White3747
Default3949

Bright variants use codes 90–97 (foreground) and 100–107 (background), or bold+base (1;31) on terminals without aixterm bright codes.

SequenceRole
ESC[38;5;{n}mForeground palette index 0–255
ESC[48;5;{n}mBackground palette index 0–255
ESC[38;2;{r};{g};{b}mForeground truecolor
ESC[48;2;{r};{g};{b}mBackground truecolor

Index bands: 0–7 standard, 8–15 bright, 16–231 6×6×6 cube (16 + 36r + 6g + b), 232–255 grayscale steps.

Common private CSI modes (final h / l):

SequenceDescription
ESC[?25l / ESC[?25hHide / show cursor
ESC[?47l / ESC[?47hRestore / save screen
ESC[?1049l / ESC[?1049hDisable / enable alternate buffer

Ansi.Screen and Ansi.Escape.PrivateMode cover the subset used by corelib tests; legacy VGA resolution ESC[={n}h modes are documented in ANSI.md only.

ModuleResponsibility
Ansi.EscapeFraming, WhenEnabled, DEC/OSC helpers
Ansi.CursorMovement builder → gated sequence
Ansi.EraseDisplay/line erase builder
Ansi.SgrAttribute and color builder with downgrade
Ansi.ScreenScroll region and alt-screen helpers
Ansi.OscOSC payloads (BEL-terminated)
Ansi.StyleChainMarkup attribute chain used by Console.Format

Golden tests: AnsiEscapeTests.bd, AnsiSgrGoldenTests.bd — see verification and traceability.