ANSI Escape Sequence Reference
This page is the authoritative reference for the ANSI escape sequences used by
FrankenTUI. It feeds the Presenter, TerminalWriter, and terminal-model
tests.
Notation
ESC=\x1b(0x1B)CSI=ESC [(Control Sequence Introducer)OSC=ESC ](Operating System Command)ST=ESC \or\x07(String Terminator){n}= numeric parameter{r},{c}= row, column (1-indexed)
Direction Labels
Each sequence is annotated with its direction:
- Emit — ftui writes this sequence to the terminal.
- Parse — ftui reads and interprets this sequence from terminal input.
- Both — used in both directions.
Cursor
Cursor Movement (Emit)
Absolute Positioning
| Sequence | Name | Effect |
|---|---|---|
CSI {r};{c} H | CUP | Move cursor to row r, column c |
CSI {r};{c} f | HVP | Same as CUP |
CSI {c} G | CHA | Move cursor to column c |
CSI {r} d | VPA | Move cursor to row r |
Relative Movement
| Sequence | Name | Effect |
|---|---|---|
CSI {n} A | CUU | Move cursor up n rows |
CSI {n} B | CUD | Move cursor down n rows |
CSI {n} C | CUF | Move cursor forward n columns |
CSI {n} D | CUB | Move cursor back n columns |
CSI {n} E | CNL | Move to beginning of line n lines down |
CSI {n} F | CPL | Move to beginning of line n lines up |
Cursor Save/Restore (Emit)
| Sequence | Name | Effect |
|---|---|---|
ESC 7 | DECSC | Save cursor position + attributes (DEC) |
ESC 8 | DECRC | Restore cursor position + attributes (DEC) |
CSI s | SCOSC | Save cursor position (ANSI) |
CSI u | SCORC | Restore cursor position (ANSI) |
DEC save/restore (ESC 7/ESC 8) is preferred — it saves more state and has
wider support. See ADR-001.
Cursor Visibility (Emit)
| Sequence | Name | Effect |
|---|---|---|
CSI ? 25 h | DECTCEM | Show cursor |
CSI ? 25 l | DECTCEM | Hide cursor |
Cursor Style (Emit) — DECSCUSR
| Sequence | Effect |
|---|---|
CSI 0 SP q | Default cursor style |
CSI 1 SP q | Blinking block |
CSI 2 SP q | Steady block |
CSI 3 SP q | Blinking underline |
CSI 4 SP q | Steady underline |
CSI 5 SP q | Blinking bar (I-beam) |
CSI 6 SP q | Steady bar (I-beam) |
The SP in DECSCUSR is a literal space (0x20) before q.
Device Status Reports (Both)
| Sequence | Direction | Effect |
|---|---|---|
CSI 6 n | Emit | Request cursor position |
CSI {r};{c} R | Parse | Cursor position response |
CSI c | Emit | Request primary device attributes (DA1) |
CSI > c | Emit | Request secondary device attributes (DA2) |
CSI > 0 q | Emit | Request terminal version (XTVERSION) |