# Zero Default Mode (ZDM)

> Whether a parameter of 0 means zero or the default.

- **Sequence:** `CSI 22 h`
- **ECMA-48:** [§F.4.2 ZDM – Zero Default Mode, p. 87](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n100/mode/1up)

Mode 22 decides what a parameter of `0` means. Reset, it means the number
zero; set, it means the default, so `CSI 0 C` moves one column like `CSI C`.
The first edition of ECMA-48 treated `0` as the default, and the mode was
kept for implementations of it; the fifth edition deprecates it and moved
it to an annex.

| State | ECMA-48 calls it | Meaning |
| --- | --- | --- |
| Reset, `CSI 22 l` | ZERO | 0 is the number zero |
| Set, `CSI 22 h` | DEFAULT | 0 is the default value |

Terminals behave as if the mode were set. In xterm and libghostty-vt a
`0` given to a count, as in [CUF](https://control-codes.page/csi/cuf/index.html.md) or [ICH](https://control-codes.page/csi/ich/index.html.md), means
one, the same as leaving it out, whatever the mode says.

Neither xterm nor libghostty-vt implements it. Both ignore `CSI 22 h` and
`CSI 22 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

### ZDM-1: Not recognized

Input, one step per line:

```text
\e[22$p
```

Expected screen:

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

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

Input, one step per line:

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

Expected screen:

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

### ZDM-3: A zero is still the default

Input, one step per line:

```text
\e[22l     # zero means zero: ignored
A
\e[0C       # moves one column
B
```

Expected screen:

```text
|A_B__|
cursor 1,4
```

---

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