# DEC Private Mode Reset (DECRST)

> Turn one or more DEC private modes off.

- **Sequence:** `CSI ? Pm l`
- **DEC STD 070:** [§5.10.1.2 DEC Private Modes, p. 5-133](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n387/mode/1up)
- **VT220:** [§4.6.2 Reset Mode (RM)](https://vt100.net/docs/vt220-rm/chapter4.html#S4.6.2)
- **VT510:** [RM—Reset Mode](https://vt100.net/docs/vt510-rm/RM.html)
- **xterm:** [Functions using CSI](https://invisible-island.net/xterm/ctlseqs/ctlseqs.html)

`CSI ? Pm l` resets one or more DEC private modes, the ones
[DECSET](https://control-codes.page/csi/decset/index.html.md), `CSI ? Pm h`, sets. It is [RM](https://control-codes.page/csi/rm/index.html.md) with a `?`
in front of the parameters, and the `?` changes what every number means:
`CSI 4 l` is replace mode, but `CSI ? 4 l` is jump scrolling. Each mode has
a page under [private modes](https://control-codes.page/modes/index.html.md).

DEC's manuals do not call it DECRST. To them it is RM, Reset Mode, with a `?`:
DEC STD 070 lists the private modes in its table of SM and RM parameters, and the
VT220 and VT510 manuals describe both forms under RM. The names DECSET and
DECRST are xterm's, from its list of control sequences, and are the ones
most documentation uses now.

Each parameter names one mode, and they are reset in order, with the same
rules as DECSET: a `0` is an error and is ignored, as is any number the
terminal does not know, and ANSI and private parameters cannot be mixed.
xterm resets each mode in turn in [`dpmodes`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L7493-L8047), and so does libghostty-vt.

Resetting a mode is not always a matter of a flag. Some modes act when they
change: resetting [DECCOLM](https://control-codes.page/modes/deccolm/index.html.md) clears the screen, once
mode 40 allows it to act at all, and
resetting `1049` leaves the [alternate screen](https://control-codes.page/modes/altscreen/index.html.md) and
restores the cursor. Each mode's page says what its reset does.

## Validation

### DECRST-1: Two modes in one sequence

Input, one step per line:

```text
\e[?7;25l  # no autowrap, no cursor
\e[?7$p
\e[?25$p
```

Expected screen:

```text
|_____|
reply \e[?7;2$y\e[?25;2$y
```

### DECRST-2: Autowrap off

Input, one step per line:

```text
\e[?7l
ABCDEFG   # F and G go to the last column
```

Expected screen:

```text
|ABCDG|
|_____|
cursor 1,5
```

### DECRST-3: A mode that is not known does not stop the others

Input, one step per line:

```text
\e[?0;9999;7l  # 0 is an error, 9999 is no mode
ABCDEFG
```

Expected screen:

```text
|ABCDG|
|_____|
cursor 1,5
```

### DECRST-4: Without the question mark it is a different mode

Input, one step per line:

```text
\e[7l      # VEM, not DECAWM
ABCDEFG
```

Expected screen:

```text
|ABCDE|
|FG___|
cursor 2,3
```

---

This is the Markdown version of <https://control-codes.page/csi/decrst/>. On that page every validation case runs live in libghostty-vt, the terminal emulation core of Ghostty, compiled to WebAssembly.

The validation cases are written in the notation described in <https://control-codes.page/notation/index.html.md>.
