# Screen Mode (DECSCNM)

> Show the whole screen in reverse video: dark text on a light background.

- **Sequence:** `CSI ? 5 h`
- **DEC STD 070:** [§5.6 Set/Reset Screen Mode, p. 5-94](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n348/mode/1up)
- **VT510:** [DECSCNM—Screen Mode: Light or Dark Screen](https://vt100.net/docs/vt510-rm/DECSCNM.html)

`CSI ? 5 h` sets reverse screen and `CSI ? 5 l` puts it back to normal.
Reverse screen swaps the foreground and background colors of the whole
display, so that a terminal showing light text on a dark background shows
dark text on a light one. DEC STD 070 says the actual colors are the
implementation's to choose, and that every character rendition must still
work in both modes. Normal is the default in the VT510 manual.

It is a way of showing the screen, not a change to it. The VT510 manual says
DECSCNM "does not change the data in page memory": the characters and their
attributes, such as those set with [SGR](https://control-codes.page/csi/sgr/index.html.md), stay as they were.

libghostty-vt records the mode and leaves drawing it to its host, and the
terminals drawn on this site do not show it, so the cases check the mode
with DECRQM, and that the cells are unchanged.

## Validation

### DECSCNM-1: Set, and the cells are unchanged

Input, one step per line:

```text
AB
\e[?5h
\e[?5$p   # DECRQM: is mode 5 set?
```

Expected screen:

```text
|AB___|
attr 1,1 plain
reply \e[?5;1$y
```

### DECSCNM-2: Reset

Input, one step per line:

```text
\e[?5h
\e[?5l
\e[?5$p
```

Expected screen:

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

### DECSCNM-3: Normal to begin with

Input, one step per line:

```text
\e[?5$p
```

Expected screen:

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

---

This is the Markdown version of <https://control-codes.page/modes/decscnm/>. 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>.
