# 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.

## 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>.
