OSC 5 Change Special Color
Set, query and reset the colors xterm can draw bold, underlined, blinking, reversed and italic text in.
OSC 5 ; Pc ; Pt ST
Besides the palette, xterm has five special colors, which it can use to show an attribute as a color instead of, or as well as, the attribute itself:
Pc | Resource | Used for |
|---|---|---|
0 | colorBD | bold |
1 | colorUL | underline |
2 | colorBL | blink |
3 | colorRV | reverse |
4 | colorIT | italic |
OSC 5 ; Pc ; Pt ST sets one, Pt of ? asks for it, and OSC 105 ; Pc ST puts it back, exactly as OSC 4 and OSC 104 do for the palette; they are also palette numbers 256 to 260, so OSC 4 ; 256 ; ? ST asks for the bold color too (do_osc, ReportAnsiColorRequest). Each is used only when its mode is on, which OSC 6 turns on and off, and all five modes are off by default. Each starts as the default foreground (charproc.c), so in a terminal set up as a default xterm, as the cases are, each is reported as black.
libghostty-vt has no special colors, and ignores OSC 5 and OSC 105 and palette numbers past 255, so the cases that ask are known differences.
Validation
OSC5-1: The color for bold
\e]5;0;?\a
|______|
reply \e]5;0;rgb:0000/0000/0000\a
OSC5-2: Set, and asked for through OSC 4
\e]5;1;#ff0000\a # the color for underline
\e]4;257;?\a
|______|
reply \e]4;257;rgb:ffff/0000/0000\a
OSC5-3: Nothing on screen
A
\e]5;0;red\a
\e]105;0\a
B
|AB____|
cursor 1,3