# Cursor Blink (?12)

> Start or stop the cursor blinking.

- **Sequence:** `CSI ? 12 h/l`
- **xterm:** [Functions using CSI](https://invisible-island.net/xterm/ctlseqs/ctlseqs.html)

`CSI ? 12 h` makes the cursor blink and `CSI ? 12 l` makes it steady. xterm
names it after the AT&T 610 terminal it took the number from; DEC's own use
of mode 12 is something else, and [DECSCUSR](https://control-codes.page/csi/decscusr/index.html.md) is the way to
set the blink and the shape together.

The cases follow xterm, where this mode and DECSCUSR set the same flag
([`dpmodes`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L7626-L7631),
[`CASE_DECSCUSR`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L4949-L5003),
[`do_dec_rqm`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/misc.c#L5517-L5519)):

- it is off to begin with, unless the `cursorBlink` resource says otherwise;
- a blinking DECSCUSR style sets it, and a steady one resets it, so DECRQM
  for mode `12` tells which DECSCUSR chose last;
- [DECSTR](https://control-codes.page/csi/decstr/index.html.md) and [RIS](https://control-codes.page/esc/ris/index.html.md) both reset it
  ([`ReallyReset`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L14381-L14383)).

If the `cursorBlink` resource is set to `always` or `never`, neither this mode
nor DECSCUSR can change it.

libghostty-vt keeps the mode and DECSCUSR in step as xterm does, but DECSTR
leaves the mode set, which is a known difference.

## Support

| Terminal | Version | Support | Notes |
| --- | --- | --- | --- |
| VT220 | [manual](https://vt100.net/docs/vt220-rm/), 2nd ed., 1984 | No | not in the manual |
| VT510 | [manual](https://vt100.net/docs/vt510-rm/), 1st ed., 1993 | No | not in the manual; mode 12 there is SRM, an ANSI mode |
| xterm | patch 412, [xterm-411a](https://github.com/ThomasDickey/xterm-snapshots/tree/xterm-411a) | Yes | off unless the `cursorBlink` resource says otherwise |
| libghostty-vt | [0f171f6](https://github.com/ghostty-org/ghostty/tree/0f171f650a1cbbd6df4a2573b6b0c7de57cc6d90) | Yes | BLINK-4: DECSTR leaves the mode set |
| 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 case that shows it working |
| foot | 1.28.0, [run in a VM](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/foot.json) | Yes | passes the case that shows 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) | Yes | passes the case that shows 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) | Yes | passes the case that shows it working |
| ConEmu | build 230724, its [documentation](https://conemu.github.io/en/AnsiEscapeCodes.html) | No | not in ConEmu's list, which has [DECSCUSR](https://control-codes.page/csi/decscusr/index.html.md) instead; [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) | Yes | passes the case that shows 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 case that shows it working |

## Validation

### BLINK-1: Steady to begin with

Input, one step per line:

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

Expected screen:

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

### BLINK-2: Set and reset

Input, one step per line:

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

Expected screen:

```text
|____|
reply \e[?12;1$y\e[?12;2$y
```

### BLINK-3: DECSCUSR sets it too

Input, one step per line:

```text
\e[1\sq   # blinking block
\e[?12$p
\e[2\sq   # steady block
\e[?12$p
```

Expected screen:

```text
|____|
reply \e[?12;1$y\e[?12;2$y
```

### BLINK-4: DECSTR resets it

*A known difference: libghostty-vt does not pass this case.*

Input, one step per line:

```text
\e[?12h
\e[!p
\e[?12$p
```

Expected screen:

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

### BLINK-5: So does RIS

Input, one step per line:

```text
\e[?12h
\ec
\e[?12$p
```

Expected screen:

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

---

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