^[control-codes live in libghostty-vt

Escape sequences

RIS Reset to Initial State

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
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.

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.