^[control-codes live in libghostty-vt

Device control strings

DECRQSS Request Selection or Setting

Ask for the current setting of a function, as the sequence that would set it.

DCS $ q Pt ST
DEC STD 070
§5.13.2 Request Selection or Setting, p. 5-196
VT510
DECRQSS—Request Selection or Setting
xterm
Device-Control functions

DCS $ q Pt ST asks for the current setting of the function whose final characters, with any intermediates, are Pt: m for SGR, r for DECSTBM, SP q for DECSCUSR. The answer, DECRPSS, is DCS Ps $ r D…D ST, where D…D is the sequence that would set it as it is, without the CSI, and Ps is 1 if the request was understood and 0 if not. One function per request.

DEC STD 070 gives Ps that way round, 1 for success, on the DECRPSS page (p. 5-197); the VT510 manual has them the other way, and xterm, esctest2 and libghostty-vt all follow DEC STD 070. The DCS page has more on how the string is parsed.

DEC STD 070 lists what a VT420 reports. A default xterm, a VT420, reports all of it except the status line, which is not in its default build (misc.c):

PtFunctionxtermlibghostty-vt
mSGRyesyes
rDECSTBMyesyes
sDECSLRMyesonly with left and right margins enabled
SP qDECSCUSRyesyes
" qDECSCAyesno
" pDECSCLyesno
tDECSLPPyesno
$ |DECSCPPyesno
* |DECSNLSyesno
* xDECSACEyesno
$ }, $ ~DECSASD, DECSSDTnono
> Pp mXTQMODKEYSyesno

xterm writes an SGR answer in a fixed order: 0, then bold, underline, blink, inverse and invisible, then faint, italic, crossed out and double underline, then the colors, with a color above 15 as 38:5:n and a direct color as 38:2::r:g:b (xtermFormatSGR). libghostty-vt writes the attributes in numerical order instead, and a double underline as 4:2, so those cases are known differences, as are the settings it does not report. DECSLPP’s answer is xterm’s as it is: it never reports fewer than 24 lines.

Validation

DECRQSS-1: SGR

\e[3;1m   # italic, bold
\eP$qm\e\\
|______|
reply \eP1$r0;1;3m\e\\

DECRQSS-2: SGR colors

\e[38;5;196;43m
\eP$qm\e\\
\e[0;91;104m
\eP$qm\e\\
\e[0;38;2;1;2;3m
\eP$qm\e\\
|______|
reply \eP1$r0;38:5:196;43m\e\\\eP1$r0;91;104m\e\\\eP1$r0;38:2::1:2:3m\e\\

DECRQSS-3: SGR attributes in xterm’s order

\e[1;2;3;4;5;7;8;9m
\eP$qm\e\\
|______|
reply \eP1$r0;1;4;5;7;8;2;3;9m\e\\

DECRQSS-4: Double underline

\e[21m
\eP$qm\e\\
|______|
reply \eP1$r0;21m\e\\

DECRQSS-5: The margins

\eP$qr\e\\
\e[?69h
\e[2;5s
\eP$qs\e\\
|______|
|______|
reply \eP1$r1;2r\e\\\eP1$r2;5s\e\\

DECRQSS-6: Left and right margins, not enabled

\eP$qs\e\\
|______|
reply \eP1$r1;6s\e\\

DECRQSS-7: The cursor style

\eP$q\sq\e\\
\e[3\sq
\eP$q\sq\e\\
|______|
reply \eP1$r2\sq\e\\\eP1$r3\sq\e\\

DECRQSS-8: Protection

\e[1"q
\eP$q"q\e\\
|______|
reply \eP1$r1"q\e\\

DECRQSS-9: The conformance level

\eP$q"p\e\\
|______|
reply \eP1$r64;1"p\e\\

DECRQSS-10: The page size

\eP$qt\e\\
\eP$q$|\e\\
\eP$q*|\e\\
|______|
reply \eP1$r24t\e\\\eP1$r80$|\e\\\eP1$r1*|\e\\

DECRQSS-11: The attribute change extent

\eP$q*x\e\\
|______|
reply \eP1$r0*x\e\\

DECRQSS-12: The status line, which a default xterm does not have

\eP$q$}\e\\
|______|
reply \eP0$r\e\\
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.