^[control-codes
live in libghostty-vt

Escape sequences

RIS Reset to Initial State

View as Markdown

Reset the terminal to the state it has when switched on.

ESC c
ECMA-48
§8.3.105 RIS – Reset to Initial State, p. 55
DEC STD 070
§D.2 Reset to Initial State, p. D-5
VT220
§4.18.2 Hard Terminal Reset (RIS)
VT510
RIS—Reset to Initial State

Put the terminal back the way it was when it was switched on. ECMA-48 lists what that “may imply”: clearing tab stops, resetting the graphic rendition, erasing every character position, moving the cursor to the first position of the first line, and setting the modes to their reset state.

DEC STD 070 keeps RIS in an appendix of exceptions, and says conforming software “will not use the RIS control”. Its algorithm resets the margins, the rendition, origin mode, insert mode, the character sets and the saved cursor, erases the display, homes the cursor, and puts a tab stop every eight columns. Some of that state, such as autowrap and the tab stops, a DEC terminal lets the user choose and store in setup, and RIS restores the stored choice, so DEC STD 070 warns that software cannot rely on it. The VT510 manual adds that RIS “usually causes a communication line disconnect” on a real terminal.

Both recommend the soft reset instead, DECSTR, CSI ! p (DEC STD 070 §4, ch. 5, p. 31, VT510 DECSTR). DECSTR resets the modes, margins, rendition and character sets a program might have changed, but leaves the screen and the cursor alone. libghostty-vt does not implement DECSTR; the last case below shows it.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984Yes§4.18.2 Hard Terminal Reset (RIS)
VT510manual, 1st ed., 1993YesRIS
xtermpatch 412, xterm-411aYes
libghostty-vt0f171f6YesRIS-6: ignores DECSTR, CSI ! p
kitty0.49.1, run in a VMYespasses the 6 cases that show it working
foot1.28.0, run in a VMYespasses the 4 cases that show it working
pyte0.8.2, run as a libraryPartlyfails RIS-6 of the 6 cases that show it working
xterm.js headless6.0.0, run as a libraryYespasses the 6 cases that show it working
alacritty_terminal0.26.0, run as a libraryPartlyfails RIS-6 of the 6 cases that show it working
ConEmubuild 230724, its documentationYesESC c, listed as a full reset: screen, backscroll and cursor, in ANSI escape codes
rxvt-unicode9.31, run in a VMPartlyfails RIS-6 of the 6 cases that show it working
VTE0.84.1, run as a libraryPartlyfails RIS-1, RIS-2, RIS-3, RIS-4 and 1 more of the 6 cases that show it working

Validation

RIS-1: Erases the screen and homes the cursor

AB\r\nCD
\ec
|____________|
|____________|
cursor 1,1

RIS-2: Resets the rendition

\e[1;31m  # bold, red
\ec
X
|X___________|
attr 1,1 plain

RIS-3: Resets the margins and origin mode

\e[2;3r   # region is lines 2 and 3
\e[?6h    # origin mode
\ec
X
|X___________|
|____________|
|____________|

RIS-4: Puts the tab stops back

\e[3g     # clear every tab stop
\ec
\tX
|________X___|

RIS-5: Resets insert mode

\e[4h     # insert mode
\ec
AB
\e[1;1H
Z         # replaces A rather than pushing it along
|ZB__________|

RIS-6: DECSTR, by contrast, keeps the screen

AB
\e[1;31m  # bold, red
\e[!p     # DECSTR
X
|ABX_________|
attr 1,3 plain
cursor 1,4

libghostty-vt ignores CSI ! p. Its dispatch for the final byte p in stream.zig handles only DECRQM, with a $ intermediate, and logs any other intermediate as unimplemented, so the screen is kept, as it should be, but the rendition stays bold and red. DEC STD 070’s list of what DECSTR resets includes “Current Rendition normal”, and the VT510 manual’s DECSTR page lists SGR as reset to normal rendition.

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