# Fill Rectangular Area (DECFRA)

> Fill a rectangle of the screen with one character, in the current rendition.

- **Sequence:** `CSI Pch ; Pt ; Pl ; Pb ; Pr $ x`
- **Defaults:** Pt = 1, Pl = 1, Pb and Pr = the last line and column; Pch has none in xterm
- **DEC STD 070:** [§5.12.1 Fill Rectangular Area, p. 5-170](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n424/mode/1up)
- **VT510:** [DECFRA—Fill Rectangular Area](https://vt100.net/docs/vt510-rm/DECFRA.html)

Fill the rectangle from line `Pt`, column `Pl` to line `Pb`, column `Pr`
with the character whose code is `Pch`, in the current rendition set by
[SGR](https://control-codes.page/csi/sgr/index.html.md). The cursor does not move. The rectangle works as it does
for [DECERA](https://control-codes.page/csi/decera/index.html.md): corners left out or `0` take the screen's edge,
values past the edge are taken as the edge, an upside-down rectangle does
nothing, and only [origin mode](https://control-codes.page/modes/decom/index.html.md) brings the margins into it.

DEC STD 070 allows `Pch` from 32 to 126 and from 160 to 255, and has the
whole control ignored for anything else. xterm also accepts any printable
Unicode code point above 255, and the cases follow xterm
([`CASE_DECFRA`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L5666-L5684), whose comment says as
much). Unlike DEC STD 070, xterm needs `Pch` to be given: with no
parameters at all, DECFRA does nothing.

## Not in libghostty-vt

DECFRA is one of the VT420's rectangle operations, level 4 in DEC STD 070.
libghostty-vt, a VT220 (see [DA](https://control-codes.page/csi/da/index.html.md)), has no handler for
`CSI … $ x` in `stream.zig` and ignores it. xterm is a VT420 by default
and implements it, so every case below expects xterm's result and is a
known difference (see the [sources](https://control-codes.page/sources/index.html.md) page).

## Validation

### DECFRA-1: Fill a rectangle

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

Input, one step per line:

```text
abcdef\r\nghijkl\r\nmnopqr\r\nstuvwx
\e[1;3H
\e[37;2;2;3;4$x # 37 is %
```

Expected screen:

```text
|abcdef|
|g%%%kl|
|m%%%qr|
|stuvwx|
cursor 1,3
```

### DECFRA-2: The whole screen by default

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

Input, one step per line:

```text
\e[88$x   # 88 is X
```

Expected screen:

```text
|XXXXXX|
|XXXXXX|
|XXXXXX|
```

### DECFRA-3: In the current rendition

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

Input, one step per line:

```text
\e[1;4m   # bold, underlined
\e[88;1;1;1;2$x
\e[0m
```

Expected screen:

```text
|XX____|
attr 1,1 bold underline
attr 1,2 bold underline
```

### DECFRA-4: A character beyond Latin-1

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

Input, one step per line:

```text
\e[9472;1;1;1;6$x # 9472 is U+2500
```

Expected screen:

```text
|──────|
|______|
```

### DECFRA-5: Counted from the margins in origin mode

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

Input, one step per line:

```text
\e[?69h   # allow left and right margins
\e[2;5s   # margins at columns 2 and 5
\e[2;4r   # region is lines 2 to 4
\e[?6h    # origin mode
\e[42;1;1;9;9$x # 42 is *, clipped to the screen
```

Expected screen:

```text
|______|
|_*****|
|_*****|
|_*****|
```

---

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