Skip to main content

DECRQSS

AI-Generated Content
This page was generated with the assistance of AI and may contain inaccuracies. It is intended as a placeholder for future human verification. If you spot issues ahead of its initial review, please report them on GitHub!
Standard

DECRQSS (Request Selection or Setting) is a DCS sequence that queries the current value of a terminal setting. The terminal responds with a DCS string containing the setting's current state, allowing applications to discover configuration without maintaining shadow state.

Syntax​

DCS $ q Pt ST        DECRQSS request
DCS Ps $ r Pt ST DECRQSS response
Formal syntax
(* Request *)
DECRQSS-request  = 0x1b, "P", "$", "q", Pt, 0x1b, "\\" ;
Pt = final-char, { final-char } ;    (* setting identifier *)

(* Response *)
DECRQSS-response = 0x1b, "P", Ps, "$", "r", Pt, 0x1b, "\\" ;
Ps = "0" | "1" ;                     (* 0 = invalid request, 1 = valid *)
Pt = final-char, { final-char } ;    (* current setting value *)
final-char = ? any printable character ? ;

Parameters​

ParameterDescription
Pt (request)The setting identifier to query (see table below)
Ps (response)1 if the request is valid, 0 if the terminal does not recognize the setting
Pt (response)The current value of the requested setting, formatted as if it were the original control sequence

Common setting identifiers​

Pt valueSetting queried
mSGR — current graphic rendition attributes
rDECSTBM — top and bottom scrolling margins
sDECSLRM — left and right margins
SP qDECSCUSR — cursor style
" pDECSCL — conformance level
" qDECSCA — select character attributes (protection)

Response​

The response embeds the current setting value as it would appear in the original control sequence. For example, querying SGR when bold and red are active returns the parameters 1;31 within the response:

  • Request: DCS $ q m ST
  • Response: DCS 1 $ r 1;31 m ST (bold + red foreground active)

If the terminal does not support the queried setting, it responds with Ps = 0:

  • Response: DCS 0 $ r ST

Description​

DECRQSS was introduced on the VT320 as part of the DEC private control sequence repertoire. It provides a general mechanism for applications to interrogate the terminal's current state for a variety of settings.

The host sends DCS $ q Pt ST where Pt identifies which setting to query. The terminal responds with DCS Ps $ r Pt ST where Ps indicates validity and Pt contains the current value of that setting. The response Pt is formatted exactly as the parameters of the original control sequence that would produce the current state -- this means a parser can extract the setting value using the same logic used to parse the setting command itself.

Typical usage​

DECRQSS is commonly used by applications that need to:

  • Save and restore state: Query current SGR attributes or cursor style before making changes, then restore them afterward.
  • Feature detection: Determine whether the terminal supports a particular setting by checking whether the response has Ps = 1.
  • Margin discovery: Query DECSTBM or DECSLRM to learn the current scrolling region dimensions.

Implementation notes​

Support varies significantly across terminals. Many implementations only handle a subset of setting identifiers -- most commonly SGR (m), DECSTBM (r), and DECSCUSR (SP q). Applications should be prepared for either an invalid response (Ps = 0) or no response at all from terminals that do not implement DECRQSS.

Examples​

# Query current SGR attributes
printf '\eP$qm\e\\'

# Query current scrolling margins (DECSTBM)
printf '\eP$qr\e\\'

# Query cursor style (DECSCUSR)
printf '\eP$q q\e\\'

# Query conformance level (DECSCL)
printf '\eP$q"p\e\\'

Specifications​

SpecificationSection
VT510 Reference—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✗No
Bobcat??Bobcat is built on TerminalCtrl library which handles all escape sequence parsing. No evidence found in Bobcat's code, but this may be implemented in the external TerminalCtrl dependency.
contour✓v0.1.0DECRQSS (DCS $ q - Request Status String) implemented in Functions.h line 622, handled via hookDECRQSS in Screen.cpp line 4062, supports SGR, DECSTBM, DECSLRM, DECSCUSR, etc.
foot~1.11.0Supports DECSTBM, SGR, and DECSCUSR queries only
Ghostty✓v1.0.0Request status string (SGR, DECSCUSR, DECSTBM, DECSLRM)
iTerm2✓YesDCS $ q request status string via DCS_DECRQSS token
Kitty✓YesDCS $ q implementation
Konsole✗No
mintty✓YesDECRQSS (DCS $ q) implemented at src/termout.c:4235-4358 for SGR, margins, cursor style, etc.
mlterm~3.7.2Supports some parameters like DECSTGLT, DECSCPP, DECSLPP, DECSNLS, DECAC, DECATC, and SGR
PuTTY✗NoDCS sequences are recognized but only accumulated and ignored per terminal.c:3243-3246
Rio✗No
rxvt-unicode✗NoDCS sequences explicitly not implemented (discarded)
st✗NoDCS sequences are parsed but not handled (case 'P' returns immediately in strhandle)
terminology~v0.1.0Only DECSCL supported, SGR and DECSTBM marked TODO
VT100✗No
VTE~YesSupports DECSACE, DECSCUSR, DECSGR, DECSTBM, DECSLPP, DECSLRM, SGR; rejects many others
WezTerm~YesPartial support for DECSCL, DECSTBM, DECSLRM; other requests return invalid response
Windows Terminal✓YesSupports querying SGR, DECSTBM, DECSLRM, DECSCUSR, DECSCA, DECSACE, and DECAC settings
xterm✓xterm-170DCS $ q - Request Status String (DECRQSS) for VT420+ queries
xterm.js~5.0.0Partial: SGR, DECSTBM, DECSCUSR, DECSCA, DECSCL
Multiplexers
cy✗NoDCS Hook/Put/Unhook are empty stubs
GNU Screen✗No
tmux✓3.6Only supports cursor style query (SP q)
tuios✗No
Zellij✗NoNot implemented - terminal reports as VT220 to avoid DECRQSS expectations (vttest fix in v0.31.4)

See also​