# Send/Receive Mode (SRM)

> Turn local echo off and on.

- **Sequence:** `CSI 12 h/l`
- **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.

## Support

| Terminal | Version | Support | Notes |
| --- | --- | --- | --- |
| VT220 | [manual](https://vt100.net/docs/vt220-rm/), 2nd ed., 1984 | Yes | [§4.6.5 Send/Receive Mode (SRM)](https://vt100.net/docs/vt220-rm/chapter4.html#S4.6.5) |
| VT510 | [manual](https://vt100.net/docs/vt510-rm/), 1st ed., 1993 | Yes | [SRM](https://vt100.net/docs/vt510-rm/SRM.html) |
| xterm | patch 412, [xterm-411a](https://github.com/ThomasDickey/xterm-snapshots/tree/xterm-411a) | Yes |  |
| libghostty-vt | [0f171f6](https://github.com/ghostty-org/ghostty/tree/0f171f650a1cbbd6df4a2573b6b0c7de57cc6d90) | Yes |  |
| kitty | 0.49.1, [run in a VM](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/kitty.json) | No | fails the 3 cases that show it working |
| foot | 1.28.0, [run in a VM](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/foot.json) | No | fails the 3 cases that show it working |
| xterm.js headless | 6.0.0, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/xtermjs.json) | No | fails the 3 cases that show it working |
| alacritty_terminal | 0.26.0, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/alacritty.json) | No | fails the 3 cases that show it working |
| ConEmu | build 230724, its [documentation](https://conemu.github.io/en/AnsiEscapeCodes.html) | No | not in its [ANSI escape codes](https://conemu.github.io/en/AnsiEscapeCodes.html) |
| rxvt-unicode | 9.31, [run in a VM](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/urxvt.json) | No | fails the 3 cases that show it working |
| VTE | 0.84.1, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/vte.json) | No | fails the 3 cases that show it working |

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