# Send/Receive Mode (SRM)

> Turn local echo off and on.

- **Sequence:** `CSI 12 h`
- **ECMA-48:** [§7.2.15 SRM – Send/Receive Mode, p. 24](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n37/mode/1up)
- **DEC STD 070:** [§5.10.2 Send Receive Mode, p. 5-135](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n389/mode/1up)
- **VT220:** [§4.6.5 Send/Receive Mode (SRM)](https://vt100.net/docs/vt220-rm/chapter4.html#S4.6.5)
- **VT510:** [SRM—Local Echo: Send/Receive Mode](https://vt100.net/docs/vt510-rm/SRM.html)
- **xterm:** [Functions using CSI](https://invisible-island.net/xterm/ctlseqs/ctlseqs.html)

Mode 12 is local echo. Reset (`CSI 12 l`), what is typed is shown on the
screen by the terminal itself as well as being sent; set (`CSI 12 h`), it is
only sent, and the host echoes it if it wants it seen.

| State | ECMA-48 calls it | Meaning |
| --- | --- | --- |
| Reset, `CSI 12 l` | MONITOR | what is typed is shown at once |
| Set, `CSI 12 h` | SIMULTANEOUS | only what the host sends is shown |

Unusually, the set state is the default. ECMA-48 recommends that every mode
start reset, but DEC STD 070
([§5.10.2, p. 5-135](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n389/mode/1up)) and the VT510 manual make no local
echo the default, and so does xterm: it sets the mode when it starts and on
a reset ([`charproc.c`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L14450)).

xterm keeps the mode, and when it is reset, it parses what it sends as if
the host had sent it ([`charproc.c`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L9487-L9490)). That is
input, which this site cannot type, so nothing on the screen changes here.
libghostty-vt keeps the mode, set by default, and both answer
[DECRQM](https://control-codes.page/csi/decrqm/index.html.md) with its state.

## Validation

### SRM-1: Set by default

Input, one step per line:

```text
\e[12$p
```

Expected screen:

```text
|_____|
reply \e[12;1$y
```

### SRM-2: Reset

Input, one step per line:

```text
\e[12l
\e[12$p
```

Expected screen:

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

### SRM-3: And set again

Input, one step per line:

```text
\e[12l
\e[12h
\e[12$p
```

Expected screen:

```text
|_____|
reply \e[12;1$y
```

---

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