DECRQM
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)
(* 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)
| Parameter | Description |
|---|---|
Ps | Mode 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:
Pm | Meaning |
|---|---|
0 | Not recognized |
1 | Set |
2 | Reset |
3 | Permanently set |
4 | Permanently 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
| Specification | Section |
|---|---|
| VT510 Reference | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ~ | v0.13.0 | Only standard modes (4, 20) and some private modes supported |
| Bobcat | ✓ | 0.9.0 | Supported via TerminalCtrl library |
| contour | ✓ | v0.2.0.171_rc2 | |
| foot | ✓ | Yes | Implemented at csi.c:2203-2219 and csi.c:629-673 |
| Ghostty | ✓ | v1.0.0 | |
| iTerm2 | ✓ | Yes | Request mode implemented for both ANSI (VT100CSI_DECRQM_ANSI) and DEC private modes (VT100CSI_DECRQM_DEC) via CSI $ p and CSI ? $ p sequences. |
| Kitty | ✓ | Yes | Supports querying known terminal modes |
| Konsole | ✗ | No | No implementation found for DECRQM (CSI ? Ps $ p) |
| mintty | ✓ | Yes | Implemented at src/termout.c:3329-3335. Handles both ANSI and DEC private mode queries. |
| mlterm | ✓ | rel-3_8_2 | Supports both CSI ? Ps $ p and CSI Ps $ p |
| PuTTY | ✗ | No | Request mode (CSI ? Ps $ p) not implemented |
| Rio | ✓ | v0.1.13 | |
| rxvt-unicode | ✓ | 9.25 | |
| st | ✗ | No | CSI ? Ps $ p not implemented |
| terminology | ✗ | No | No implementation found for CSI ? Ps $ p |
| VT100 | ✗ | No | |
| VTE | ✓ | Yes | Supports both ECMA and DEC mode queries |
| WezTerm | ✓ | 20220319-142410-0fcdea07 | Fixed flushing in version 20220408-101518-b908e2dd |
| Windows Terminal | ✓ | Yes | Supports extensive mode reporting including IRM, LNM, DECCKM, DECCOLM, DECSCNM, and many others |
| xterm | ✓ | xterm-262 | VT300+ feature |
| xterm.js | ✓ | 5.0.0 | |
| Multiplexers | |||
| cy | ✗ | No | |
| GNU Screen | ✗ | No | CSI ? Ps $ p not implemented |
| tmux | ~ | 3.6 | Supports only specific modes: ?12 (cursor blink), ?2004 (bracketed paste), ?1004 (focus), ?1006 (SGR mouse), 2031 (theme) |
| tuios | ✓ | v0.0.15 | Supports both ANSI and DEC mode queries |
| Zellij | ~ | v0.12.0 | Only responds to mode 2026 (synchronized output) via CSI ? 2026 $ p; does not support general mode queries |
See also
- DECTCEM — Cursor Visibility — Example of a DEC private mode queryable via DECRQM