# Request Checksum of Rectangular Area (DECRQCRA)

> Ask for a checksum of part of the screen, to check it has not changed.

- **Sequence:** `CSI Pi ; Pp ; Pt ; Pl ; Pb ; Pr * y`
- **Defaults:** Pt = 1, Pl = 1, Pb and Pr = the last line and column
- **DEC STD 070:** [§5.12.2 Request Checksum of Rectangular Area, p. 5-179](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n433/mode/1up)
- **VT510:** [DECRQCRA—Request Checksum of Rectangular Area](https://vt100.net/docs/vt510-rm/DECRQCRA.html)

Ask the terminal for a checksum of a rectangle of the screen, so that an
application can check nothing there has changed behind its back. `Pi` is a
label of the application's choosing, `Pp` the page, and `Pt`, `Pl`, `Pb` and
`Pr` the rectangle's top, left, bottom and right, as for the other
[rectangle operations](https://control-codes.page/csi/decera/index.html.md). The terminal answers with DECCKSR,
`DCS Pi ! ~ D…D ST`, where `D…D` is the checksum as four hexadecimal digits
([DEC STD 070 p. 5-181](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n435/mode/1up),
[DECCKSR](https://vt100.net/docs/vt510-rm/DECCKSR.html)). DEC STD 070
makes it part of level 4's data integrity features, for transaction
processing.

xterm, a VT420 by default, implements it
([`CASE_DECRQCRA`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L5626-L5646)),
summing the characters in the rectangle with a value added for each video
attribute, skipping blanks at the ends of lines, and negating the total
([`xtermCheckRect`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/screen.c#L3162-L3290);
its `checksumExtension` resource turns parts of that off). But it answers
only when the `GetChecksum` window operation is allowed, and by default it
is not: `GetChecksum` is in xterm's default list of disallowed window
operations
([`main.h`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/main.h#L150-L175)).
So a default xterm sends nothing.

libghostty-vt does not implement DECRQCRA either: its CSI dispatch in
`stream.zig` has no case for the final byte `y`. It sends nothing, which is
what a default xterm does, so the cases below pass.

## Validation

### DECRQCRA-1: No answer by default

Input, one step per line:

```text
ABC
\e[1;1;1;1;1;3*y
```

Expected screen:

```text
|ABC_______|
reply none
```

### DECRQCRA-2: Nor for the whole screen

Input, one step per line:

```text
ABC
\e[7;1*y
```

Expected screen:

```text
|ABC_______|
|__________|
reply none
```

---

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