DECRQM Request Mode
Ask the terminal whether a mode is set, and get a DECRPM report back.
CSI ? Pd $ p
- 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:
| Ask | About | The answer |
|---|---|---|
CSI Pa $ p | an ANSI mode, one SM and RM set | CSI Pa ; Ps $ y |
CSI ? Pd $ p | a private mode, one DECSET and DECRST set | CSI ? Pd ; Ps $ y |
Ps in the answer says what state the mode is in:
Ps | The mode is |
|---|---|
0 | not recognized |
1 | set |
2 | reset |
3 | set, and cannot be changed |
4 | reset, 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.
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.