^[control-codes
live in libghostty-vt

Control sequences

DECRQM Request Mode

View as Markdown

Ask the terminal whether a mode is set, and get a DECRPM report back.

CSI ? Pd $ p

DECRQM Request Mode, for an ANSI mode

CSI Pa $ p

DECRPM Report Mode, for an ANSI mode

CSI Pa ; Ps $ y

DECRPM Report Mode, for a private mode

CSI ? Pd ; Ps $ y
DEC STD 070
§5.13.2 Request Mode, p. 5-193
VT510
DECRQM—Request Mode - Host To Terminal

A host sends DECRQM to ask whether one mode is set, and the terminal answers with DECRPM, Report Mode. There are two forms, for the two kinds of mode:

AskAboutThe answer
CSI Pa $ pan ANSI mode, one SM and RM setCSI Pa ; Ps $ y
CSI ? Pd $ pa private mode, one DECSET and DECRST setCSI ? Pd ; Ps $ y

Ps in the answer says what state the mode is in:

PsThe mode is
0not recognized
1set
2reset
3set, and cannot be changed
4reset, and cannot be changed

DECRPM is defined in DEC STD 070 §5.13.2, p. 5-195 and in the VT510 manual as DECRPM—Report Mode. Both manuals say a DECRQM asks about one mode at a time. DEC STD 070 sends the answer with the 8-bit CSI; libghostty-vt sends ESC [, as it does for its other reports.

DEC STD 070 says that every ANSI mode “defined in X3.64-1979” is reported as set or reset. The ones a DEC terminal never implements, such as GATM (1), SRTM (5) and VEM (7), are listed in DEC STD 070’s VT420 table and the VT510 manual’s as always reset, so the answer for them is 4, reset and unchangeable. A mode the terminal does not recognize is reported as 0; DEC STD 070 also reports that way the DEC private modes that exist but “cannot be set or reset from the host”.

A host can save the modes it is about to change by asking about each one first, and restore them afterwards with SM and RM. That is the use the VT510 manual gives for it.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984Nonot in the manual
VT510manual, 1st ed., 1993YesDECRQM, DECRPM
xtermpatch 412, xterm-411aYes
libghostty-vt0f171f6YesDECRQM-6: reports unimplemented ANSI modes such as GATM as 0, not 4
kitty0.49.1, run in a VMPartlyfails DECRQM-6 of the 6 cases that show it working
foot1.28.0, run in a VMPartlyfails DECRQM-4, DECRQM-6 of the 6 cases that show it working
pyte0.8.2, run as a libraryNofails the 6 cases that show it working
xterm.js headless6.0.0, run as a libraryPartlyfails DECRQM-6 of the 6 cases that show it working
alacritty_terminal0.26.0, run as a libraryPartlyfails DECRQM-6 of the 6 cases that show it working
ConEmubuild 230724, its documentationNonot in its list: ANSI escape codes
rxvt-unicode9.31, run in a VMPartlyfails DECRQM-4, DECRQM-6 of the 6 cases that show it working
VTE0.84.1, run as a libraryYespasses the 5 cases that show it working

Validation

DECRQM-1: A DEC mode that is reset

\e[?6$p   # origin mode?
|_____|
reply \e[?6;2$y

DECRQM-2: The same mode, set

\e[?6h    # origin mode on
\e[?6$p
|_____|
reply \e[?6;1$y

DECRQM-3: A mode that starts out set

\e[?25$p  # the cursor is shown at first
\e[?25l
\e[?25$p
|_____|
cursor-visible no
reply \e[?25;1$y\e[?25;2$y

DECRQM-4: An ANSI mode

\e[4$p    # insert mode?
\e[4h
\e[4$p
|_____|
reply \e[4;2$y\e[4;1$y

DECRQM-5: A DEC mode the terminal does not know

\e[?9999$p
|_____|
reply \e[?9999;0$y

DECRQM-6: An ANSI mode that is always reset

\e[1$p    # GATM, guarded area transfer
|_____|
reply \e[1;4$y

libghostty-vt answers \e[1;0$y, not recognized. It reports only the ANSI modes it implements, KAM, IRM, SRM and LNM, and 0 for every other one. DEC STD 070 requires every X3.64 ANSI mode to be reported as set or reset, and both its VT420 table and the VT510 manual’s mark GATM permanently reset. xterm answers 4 for GATM and the other unimplemented ANSI modes (do_ansi_rqm), and esctest2’s test_DECRQM_ANSI_GATM expects 4.

Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.