# Erasure Mode (ERM)

> Whether erasing touches protected areas.

- **Sequence:** `CSI 6 h`
- **ECMA-48:** [§7.2.4 ERM – Erasure Mode, p. 22](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n35/mode/1up)

Mode 6 decides whether the erasing functions, [ED](https://control-codes.page/csi/ed/index.html.md), [EL](https://control-codes.page/csi/el/index.html.md),
[ECH](https://control-codes.page/csi/ech/index.html.md), EA and EF, erase the characters in protected areas as well.
In ECMA-48 an area is protected with [SPA and EPA](https://control-codes.page/esc/spa/index.html.md), or with
DAQ.

| State | ECMA-48 calls it | Meaning |
| --- | --- | --- |
| Reset, `CSI 6 l` | PROTECT | only unprotected areas are erased |
| Set, `CSI 6 h` | ALL | protected areas are erased as well |

DEC STD 070 does not list it, and does not need it: a DEC terminal's
protection is [DECSCA](https://control-codes.page/csi/decsca/index.html.md), which only the selective erases,
DECSED and DECSEL, honor.

Neither xterm nor libghostty-vt implements it. Both ignore `CSI 6 h` and
`CSI 6 l`, and both answer [DECRQM](https://control-codes.page/csi/decrqm/index.html.md) with `0`, not
recognized: the mode is not among the ones xterm's [`do_ansi_rqm`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/misc.c#L5408-L5463) answers for.

## Validation

### ERM-1: Not recognized

Input, one step per line:

```text
\e[6$p
```

Expected screen:

```text
|_____|
reply \e[6;0$y
```

### ERM-2: Not recognized after it is set, either

Input, one step per line:

```text
\e[6h
\e[6$p
```

Expected screen:

```text
|_____|
reply \e[6;0$y
```

---

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