# Cursor Blink (?12)

> Start or stop the cursor blinking.

- **Sequence:** `CSI ? 12 h`
- **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 and RIS 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.

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