# Reset Special Colors (OSC 105)

> Put xterm's special colors back as they started.

- **Sequence:** `OSC 105 ; Pc ST`
- **ECMA-48:** [§8.3.89 OSC – Operating System Command, p. 51](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n64/mode/1up)
- **xterm:** [Operating System Commands](https://invisible-island.net/xterm/ctlseqs/ctlseqs.html)

`OSC 105 ; Pc ST` puts [special color](https://control-codes.page/osc/special-colors/index.html.md) `Pc` back as the
terminal started it, undoing `OSC 5`. `Pc` is `0` to `4`, for bold,
underline, blink, reverse and italic, and with none, `OSC 105 ST`, all five
are reset. It is [OSC 104](https://control-codes.page/osc/reset-palette/index.html.md) with the numbering moved up
by 256, and is read the same way, stopping at the first thing in the list
that is not a number ([`ResetAnsiColorRequest`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/misc.c#L3051-L3086)). The same colors can be reset as palette
numbers 256 to 260 with OSC 104.

In a default xterm it does not work. A reset sets the color again from its
resource, `colorBD` and the rest, and each of those is
`XtDefaultForeground` by default ([`charproc.c`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L666-L672)).
That is the X Toolkit's name for the default foreground, which the toolkit
understands when it reads resources, but it is not a color name, and the
reset looks it up as one, with `XParseColor`, which fails
([`xtermAllocColor`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/misc.c#L3099-L3136)). So the reset changes
nothing, and a special color that has been changed stays changed. Starting
up is not affected: when the lookup fails there, xterm falls back to the
default foreground ([`xtermGetColorRes`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/misc.c#L2923-L2949)), which is
why an unchanged special color is reported as black. A special color whose
resource names a real color can be reset.

libghostty-vt has no special colors, and ignores `OSC 5` and `OSC 105`, so
the cases that ask are known differences.

## Support

| Terminal | Version | Support | Notes |
| --- | --- | --- | --- |
| VT220 | [manual](https://vt100.net/docs/vt220-rm/), 2nd ed., 1984 | No | OSC is not among the controls it recognizes ([§4.2](https://vt100.net/docs/vt220-rm/chapter4.html#S4.2)) |
| VT510 | [manual](https://vt100.net/docs/vt510-rm/), 1st ed., 1993 | No | ignores an OSC string ([chapter 4](https://vt100.net/docs/vt510-rm/chapter4.html)) |
| xterm | patch 412, [xterm-411a](https://github.com/ThomasDickey/xterm-snapshots/tree/xterm-411a) | Partly | parses it, but cannot reset a special color whose resource is the default, `XtDefaultForeground` |
| libghostty-vt | [0f171f6](https://github.com/ghostty-org/ghostty/tree/0f171f650a1cbbd6df4a2573b6b0c7de57cc6d90) | No | no special colors (OSC105-1 to OSC105-3) |
| Konsole | 26.11.70, [a24c3d71](https://invent.kde.org/utilities/konsole/-/tree/a24c3d71be3684f24d030aa2dbe9bd723d985233) | No | not in its source |
| 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) |

## Validation

### OSC105-1: Resetting one changes nothing

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

Input, one step per line:

```text
\e]5;0;red;1;blue\a  # bold and underline
\e]105;0\a
\e]5;0;?;1;?\a
```

Expected screen:

```text
|____|
reply \e]5;0;rgb:ffff/0000/0000\a\e]5;1;rgb:0000/0000/ffff\a
```

### OSC105-2: Nor does resetting them all

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

Input, one step per line:

```text
\e]5;0;red;1;blue\a
\e]105\a
\e]5;0;?;1;?\a
```

Expected screen:

```text
|____|
reply \e]5;0;rgb:ffff/0000/0000\a\e]5;1;rgb:0000/0000/ffff\a
```

### OSC105-3: Nor through OSC 104, as color 256

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

Input, one step per line:

```text
\e]5;0;red\a
\e]104;256\a
\e]5;0;?\a
```

Expected screen:

```text
|____|
reply \e]5;0;rgb:ffff/0000/0000\a
```

### OSC105-4: Nothing on screen

Input, one step per line:

```text
A
\e]5;0;red\a
\e]105;0\a
B
```

Expected screen:

```text
|AB__|
cursor 1,3
```

---

This is the Markdown version of <https://control-codes.page/osc/reset-special-colors/>. 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>.
