# Set Termcap Data (XTSETTCAP)

> Tell xterm which terminal description to take its function keys from.

- **Sequence:** `DCS + p Pt ST`
- **xterm:** [Device-Control functions](https://invisible-island.net/xterm/ctlseqs/ctlseqs.html)

`DCS + p Pt ST` gives xterm the name of a terminal description, in
hexadecimal like the names [XTGETTCAP](https://control-codes.page/dcs/xtgettcap/index.html.md) takes. xterm looks
it up in the system's terminfo or termcap, and from then on, when its
keyboard is in *termcap* mode (`-tcap`, or `CSI ? 1050 h`), its function keys
send what that description says they send. An empty name, one that is not
in hexadecimal, or one that cannot be found rings the bell instead
([`XTSETTCAP`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/misc.c#L5166-L5170),
[`set_termcap`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/xtermcap.c#L624-L657)).
A default xterm allows it: its `disallowedTcapOps` names `SetTcap`, but that
list applies only when `allowTcapOps` is off, and it is on.

Its keyboard is not in termcap mode by default, so the only thing a case can
see is the bell. The cases follow xterm, and assume no terminal description
called `no-such-terminal` is installed.

libghostty-vt does not implement it, and consumes the string without ringing
the bell, so the cases that expect the bell are known differences.

## 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 |
| xterm | patch 412, [xterm-411a](https://github.com/ThomasDickey/xterm-snapshots/tree/xterm-411a) | Yes | allowed by default; `allowTcapOps` is on |
| libghostty-vt | [0f171f6](https://github.com/ghostty-org/ghostty/tree/0f171f650a1cbbd6df4a2573b6b0c7de57cc6d90) | No | consumed without ringing the bell (XTSETTCAP-2, XTSETTCAP-3) |
| ConEmu | build 230724, its [documentation](https://conemu.github.io/en/AnsiEscapeCodes.html) | No | not in ConEmu's list, which has no DCS; [ANSI escape codes](https://conemu.github.io/en/AnsiEscapeCodes.html) |

## Validation

### XTSETTCAP-1: Nothing on screen

Input, one step per line:

```text
A
\eP+p787465726D\e\\  # xterm
B
```

Expected screen:

```text
|AB____|
cursor 1,3
reply none
```

### XTSETTCAP-2: An empty name rings the bell

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

Input, one step per line:

```text
\eP+p\e\\
```

Expected screen:

```text
|______|
bell 1
```

### XTSETTCAP-3: So does one it cannot find

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

Input, one step per line:

```text
\eP+p6E6F2D737563682D7465726D696E616C\e\\  # no-such-terminal
```

Expected screen:

```text
|______|
bell 1
```

---

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