Skip to main content

DECRQM

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

DECRQM (Request Mode) is a CSI sequence that queries whether a specific terminal mode is set, reset, or unknown. There are two variants: one for ANSI modes and one for DEC private modes.

Syntax​

CSI Ps $ p         DECRQM — Request ANSI mode
CSI ? Ps $ p DECRQM — Request DEC private mode
CSI Ps ; Pm $ y DECRPM — ANSI mode report (response)
CSI ? Ps ; Pm $ y DECRPM — DEC private mode report (response)
Formal syntax
(* ANSI mode request *)
DECRQM-ansi     = 0x1b, "[", Ps, "$", "p" ;

(* DEC private mode request *)
DECRQM-dec      = 0x1b, "[", "?", Ps, "$", "p" ;

(* ANSI mode response *)
DECRPM-ansi     = 0x1b, "[", Ps, ";", Pm, "$", "y" ;

(* DEC private mode response *)
DECRPM-dec      = 0x1b, "[", "?", Ps, ";", Pm, "$", "y" ;

Ps              = digit, { digit } ;               (* mode number *)
Pm              = "0" | "1" | "2" | "3" | "4" ;    (* mode value *)
digit           = "0" | "1" | "2" | "3" | "4"
              | "5" | "6" | "7" | "8" | "9" ;

Parameters (Request)​

ParameterDescription
PsMode number to query (e.g., 4 for IRM, 25 for DECTCEM, 1049 for alt screen)

Response​

The terminal responds with DECRPM (Report Mode) containing the mode number and its current state:

PmMeaning
0Not recognized
1Set
2Reset
3Permanently set
4Permanently reset

Description​

Per the VT510 manual, DECRQM allows the host to query whether a specific mode is currently set or reset without changing it. This is useful for applications that need to save and restore mode state, or that need to detect which modes a terminal supports.

The ? prefix distinguishes DEC private mode queries from ANSI mode queries. For example, CSI 4 $ p queries ANSI mode 4 (Insert/Replace Mode), while CSI ? 25 $ p queries DEC private mode 25 (DECTCEM cursor visibility).

A response of Pm = 0 (not recognized) indicates the terminal does not support that mode number. Values 3 and 4 (permanently set/reset) indicate modes that cannot be changed.

DECRQM is particularly useful for feature detection. Applications can query modes like 2026 (synchronized output) or 2027 (grapheme clustering) to determine if the terminal supports them before enabling them.

Examples​

# Query DEC private mode 25 (DECTCEM - cursor visibility)
printf '\e[?25$p'
# Response if set: ESC [ ? 25 ; 1 $ y

# Query DEC private mode 2026 (synchronized output)
printf '\e[?2026$p'
# Response if not recognized: ESC [ ? 2026 ; 0 $ y

# Query ANSI mode 4 (Insert/Replace Mode)
printf '\e[4$p'
# Response if reset: ESC [ 4 ; 2 $ y

Specifications​

SpecificationSection
VT510 Reference—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty~v0.13.0Only standard modes (4, 20) and some private modes supported
Bobcat✓0.9.0Supported via TerminalCtrl library
contour✓v0.2.0.171_rc2
foot✓YesImplemented at csi.c:2203-2219 and csi.c:629-673
Ghostty✓v1.0.0
iTerm2✓YesRequest mode implemented for both ANSI (VT100CSI_DECRQM_ANSI) and DEC private modes (VT100CSI_DECRQM_DEC) via CSI $ p and CSI ? $ p sequences.
Kitty✓YesSupports querying known terminal modes
Konsole✗NoNo implementation found for DECRQM (CSI ? Ps $ p)
mintty✓YesImplemented at src/termout.c:3329-3335. Handles both ANSI and DEC private mode queries.
mlterm✓rel-3_8_2Supports both CSI ? Ps $ p and CSI Ps $ p
PuTTY✗NoRequest mode (CSI ? Ps $ p) not implemented
Rio✓v0.1.13
rxvt-unicode✓9.25
st✗NoCSI ? Ps $ p not implemented
terminology✗NoNo implementation found for CSI ? Ps $ p
VT100✗No
VTE✓YesSupports both ECMA and DEC mode queries
WezTerm✓20220319-142410-0fcdea07Fixed flushing in version 20220408-101518-b908e2dd
Windows Terminal✓YesSupports extensive mode reporting including IRM, LNM, DECCKM, DECCOLM, DECSCNM, and many others
xterm✓xterm-262VT300+ feature
xterm.js✓5.0.0
Multiplexers
cy✗No
GNU Screen✗NoCSI ? Ps $ p not implemented
tmux~3.6Supports only specific modes: ?12 (cursor blink), ?2004 (bracketed paste), ?1004 (focus), ?1006 (SGR mouse), 2031 (theme)
tuios✓v0.0.15Supports both ANSI and DEC mode queries
Zellij~v0.12.0Only responds to mode 2026 (synchronized output) via CSI ? 2026 $ p; does not support general mode queries

See also​