# Graphic Rendition Combination Mode (GRCM)

> Whether each SGR replaces the rendition or adds to it.

- **Sequence:** `CSI 21 h`
- **ECMA-48:** [§7.2.8 GRCM – Graphic Rendition Combination Mode, p. 23](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n36/mode/1up)

Mode 21 decides what an [SGR](https://control-codes.page/csi/sgr/index.html.md) does to the attributes already in
effect. Reset, which ECMA-48 makes the default, each SGR replaces them:
anything not named in it is turned off. Set, it changes only what it names.

| State | ECMA-48 calls it | Meaning |
| --- | --- | --- |
| Reset, `CSI 21 l` | REPLACING | each SGR cancels the one before |
| Set, `CSI 21 h` | CUMULATIVE | each SGR changes only what it names |

xterm and libghostty-vt behave as if the mode were set. ECMA-48's default would have bold,
then underline, give an underlined character that is not bold.

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

### GRCM-1: Not recognized

Input, one step per line:

```text
\e[21$p
```

Expected screen:

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

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

Input, one step per line:

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

Expected screen:

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

### GRCM-3: SGR is cumulative, even with the mode reset

Input, one step per line:

```text
\e[21l     # ignored
\e[1m       # bold
\e[4m       # underline
X
```

Expected screen:

```text
|X__|
attr 1,1 bold underline
```

---

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