DECSR Secure Reset
Reset the terminal to its power-up state, erase everything the host could have stored in it, and confirm that it was done.
CSI Pr + p
- Defaults
- Pr = 0, no confirmation
- DEC STD 070
- §4, ch. 5 Secure Reset, p. 29
- VT510
- DECSR—Secure Reset
DECSR is the reset for a host that has to be sure what state the terminal is in before it trusts it: a login program, say, taking over from a session that could have left anything behind. DEC STD 070 says it “initializes the terminal to its Power-Up state and erases all host setable state information and data”, which goes further than RIS: it also erases the user-defined keys (DECUDK) “even if the ‘UDKs Locked’ state is in effect”, the soft character sets (DECDLD), macros, and any buffer that could hold data from the host (pp. 29–30). The VT510 manual lists among its actions that it “Clears the screen and all off-screen page memory” and “Returns the cursor to the upper-left corner of the first page”.
The parameter asks for a confirmation:
If a non-zero numeric parameter in the range 1 to 16383 is provided, the device responds with a Secure Reset Confirmation (DECSRC) control function with the same parameter upon successful completion. If Pn is omitted or zero, no response is generated. If Pn exceeds 16383, the entire sequence shall be ignored.
DECSRC is CSI Pr * q, carrying the number back, so a host that picks a random number can tell its own reset’s confirmation from anything else (DECSRC—Secure Reset Confirmation). DEC STD 070 makes DECSR level 4, but notes that it “is recognized at all conformance levels”, and that it also takes the terminal out of display controls mode, since otherwise only the user could.
xterm does not implement DECSR. Its parse table ignores the whole of a control sequence with + as its intermediate byte (VTPrsTbl.c):
CASE_CSI_IGNORE, /* vt420 and vt520 */
and DECSRC appears only as a comment (VTPrsTbl.c). A default xterm consumes the sequence and does nothing, and the cases follow it, as the sources page explains: no reset and no confirmation, whatever the parameter. DEC STD 070’s reset and DECSRC are described above, not tested.
DEC STD 070’s algorithm sends the confirmation’s introducer as the 8-bit CSI, 0x9B. A terminal sending 7-bit controls would send ESC [, as it does for CSI in every other report.
Not in libghostty-vt
libghostty-vt does not implement DECSR either. Its dispatch for CSI … p in stream.zig handles only DECRQM, and logs any other intermediate byte as unimplemented, so CSI + p changes nothing and sends nothing, as in xterm.
Validation
DECSR-1: No confirmation is sent
\e[1+p # DEC STD 070: confirm with CSI 1 * q
|_____|
reply none
DECSR-2: The screen is not cleared
AB
\e[2;3H
\e[+p # DEC STD 070: reset, clearing the screen
|AB___|
|_____|
cursor 2,3
reply none
DECSR-3: A number too large is ignored
AB
\e[16384+p # more than 16383: DEC STD 070 ignores it too
|AB___|
|_____|
cursor 1,3
reply none