# Report Version (XTVERSION)

> Ask the terminal for its name and version.

- **Sequence:** `CSI > Ps q`
- **Defaults:** Ps = 0
- **xterm:** [Functions using CSI](https://invisible-island.net/xterm/ctlseqs/ctlseqs.html)

`CSI > q`, or `CSI > 0 q`, asks the terminal for its name and version. The
answer is a device control string, `DCS > | text ST`. Where
[DA](https://control-codes.page/csi/da/index.html.md) answers with what a terminal claims to be compatible with,
which is usually a VT terminal, this answers with what it actually is, so
a program can work around a particular terminal's bugs.

It is xterm's. xterm answers only when the parameter is `0` or left out,
and its text is `XTerm(` and its patch number `)`
([`CASE_REPORT_VERSION`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L5461-L5472),
[`xtermVersion`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/version.c#L43-L80)).
The snapshot this site links to, tagged xterm-411a, is a step toward patch
412 and calls itself that
([`version.h`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/version.h#L41)).

The text is the terminal's own, so no other terminal gives xterm's, and
that case is a known difference by nature. libghostty-vt asks its host
through the `XTVERSION` callback, and without one, as here, answers
`libghostty`; Ghostty answers `ghostty` and its version. It also answers when
the parameter is not `0`, which xterm does not, a second known difference.

## 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 | answers `XTerm(412)` |
| libghostty-vt | [0f171f6](https://github.com/ghostty-org/ghostty/tree/0f171f650a1cbbd6df4a2573b6b0c7de57cc6d90) | Yes | asks its host, `libghostty` without one (XTVERSION-1); XTVERSION-2: also answers a nonzero parameter |
| ConEmu | build 230724, its [documentation](https://conemu.github.io/en/AnsiEscapeCodes.html) | No | not in ConEmu's list; [ANSI escape codes](https://conemu.github.io/en/AnsiEscapeCodes.html) |

## Validation

### XTVERSION-1: Name and version

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

Input, one step per line:

```text
\e[>q
```

Expected screen:

```text
|______|
reply \eP>|XTerm(412)\e\\
```

### XTVERSION-2: Only for 0

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

Input, one step per line:

```text
\e[>1q
```

Expected screen:

```text
|______|
reply none
```

### XTVERSION-3: Nothing on screen

Input, one step per line:

```text
A
\e[>q
B
```

Expected screen:

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

---

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