ANSI sequences overview
Only the SGR sequence is supported. The other ANSI escape sequences are ignored.
Graphic sequence (SGR)
References: Wikipedia
The control sequence ESC [ n m
(where n
is one of the codes below) is named Select Graphic Rendition (SGR).
It sets display attributes. Several attributes can be set in the same sequence, separated by semicolons,
and (rarely) with options separated by colons.
Each display attribute remains in effect until a following occurrence of SGR explicitely resets it.
Supported SGR attributes
n | Description | Example | Rendered |
---|---|---|---|
0 | Reset more details |
"\x1B[44;33;1;2;3;4;9;58;5;1mHi \x1B[0mWorld" |
Hi World |
1 | Bold or intense | "Hi \x1B[1mWorld" |
Hi World |
2 | Faint/Dim | "Hi \x1B[2mWorld" |
Hi World |
3 | Italic | "Hi \x1B[3mWorld" |
Hi World |
4 | Underline (with optional style) more details |
"Hi \x1B[4mWorld" |
Hi World |
7 | Inverse colors more details |
"Hi \x1B[7mWorld" |
Hi World |
8 | Hidden (but selectable) | "Hi \x1B[8mWorld" |
Hi World |
9 | Crossed-out | "Hi \x1B[9mWorld" |
Hi World |
21 | Doubly underlined more details |
"Hi \x1B[21mWorld" |
Hi World |
22 | Neither bold nor faint | "\x1B[44;33;1;2;3;4;9;58;5;1mHi \x1B[22mWorld" |
Hi World |
23 | Not italic | "\x1B[44;33;1;2;3;4;9;58;5;1mHi \x1B[23mWorld" |
Hi World |
24 | Not underlined more details |
"\x1B[44;33;1;2;3;4;9;58;5;1mHi \x1B[24mWorld" |
Hi World |
27 | Not inversed more details |
"\x1B[7mHi \x1B[27mWorld" |
Hi World |
28 | Not hidden | "\x1B[8mHi \x1B[28mWorld" |
Hi World |
29 | Not crossed out | "\x1B[44;33;1;2;3;4;9;58;5;1mHi \x1B[29mWorld" |
Hi World |
30–37 | Set foreground color (standard) more details |
"Hi \x1B[32mWorld" |
Hi World |
38 | Set foreground color (38;5;n or 38;2;r;g;b) more details |
"Hi \x1B[38;2;110;120;170mWorld" |
Hi World |
39 | Default foreground color | "\x1B[44;33;1;2;3;4;9;58;5;1mHi \x1B[39mWorld" |
Hi World |
40–47 | Set background color (standard) more details |
"Hi \x1B[42mWorld" |
Hi World |
48 | Set background color (48;5;n or 48;2;r;g;b) more details |
"Hi \x1B[48;2;110;120;170mWorld" |
Hi World |
49 | Default background color | "\x1B[44;33;1;2;3;4;9;58;5;1mHi \x1B[49mWorld" |
Hi World |
58 | Set underline color (58;5;n or 58;2;r;g;b) more details |
"\x1B[4mHi \x1B[58;2;110;120;170mWorld" |
Hi World |
59 | Default underline color | "\x1B[44;33;1;2;3;4;9;58;5;1mHi \x1B[59mWorld" |
Hi World |
90–97 | Set foreground color (bright) more details |
"Hi \x1B[92mWorld" |
Hi World |
100–107 | Set background color (bright) more details |
"Hi \x1B[102mWorld" |
Hi World |
Unsupported SGR attributes
All the following sequences are rendered as
Hello World
Input | Sequence meaning |
---|---|
"Hello \x1B[5m World" |
5: Slow blink |
"Hello \x1B[6m World" |
6: Rapid blink |
"Hello \x1B[10m World" |
10: Default font |
"Hello \x1B[11m World" |
11: Alternative font 1 |
"Hello \x1B[12m World" |
12: Alternative font 2 |
"Hello \x1B[13m World" |
13: Alternative font 3 |
"Hello \x1B[14m World" |
14: Alternative font 4 |
"Hello \x1B[15m World" |
15: Alternative font 5 |
"Hello \x1B[16m World" |
16: Alternative font 6 |
"Hello \x1B[17m World" |
17: Alternative font 7 |
"Hello \x1B[18m World" |
18: Alternative font 8 |
"Hello \x1B[19m World" |
19: Alternative font 9 |
"Hello \x1B[20m World" |
20: Fraktur/Gothic font |
"Hello \x1B[25m World" |
25: Not blinking |
"Hello \x1B[26m World" |
26: Proportional spacing |
"Hello \x1B[50m World" |
50: Disable proportional spacing |
"Hello \x1B[51m World" |
51: Framed |
"Hello \x1B[52m World" |
52: Encircled |
"Hello \x1B[53m World" |
53: Overlined |
"Hello \x1B[54m World" |
54: Neither framed nor encircled |
"Hello \x1B[55m World" |
55: Not overlined |
"Hello \x1B[60m World" |
60: Ideogram underline or right side line |
"Hello \x1B[61m World" |
61: Ideogram double underline, or double line on the right side |
"Hello \x1B[62m World" |
62: Ideogram overline or left side line |
"Hello \x1B[63m World" |
63: Ideogram double overline, or double line on the left side |
"Hello \x1B[64m World" |
64: Ideogram stress marking |
"Hello \x1B[65m World" |
65: No ideogram attributes |
"Hello \x1B[73m World" |
73: Superscript |
"Hello \x1B[74m World" |
74: Subscript |
"Hello \x1B[75m World" |
75: Neither superscript nor subscript |
Non-graphic sequences
All the following sequences are rendered as
Hello World
Input | Sequence meaning |
---|---|
"Hello \x1B[3A World" |
Cursor 3 times up |
"Hello \x1B[22;5H World" |
Moves the cursor to row 22, column 5 |
"Hello \x1B[2J World" |
Clear entire screen |
"Hello \x1B World" |
Invalid/unfinished sequence |