^[control-codes live in libghostty-vt

Control sequences

DECERA Erase Rectangular Area

Erase every character in a rectangle of the screen.

CSI Pt ; Pl ; Pb ; Pr $ z
Defaults
the whole screen
DEC STD 070
§5.12.1 Erase Rectangular Area, p. 5-171
VT510
DECERA—Erase Rectangular Area

Erase the rectangle whose top-left corner is line Pt, column Pl and whose bottom-right corner is line Pb, column Pr: every character in it becomes a space. Nothing outside the rectangle changes, and the cursor does not move.

A parameter left out or 0 takes the screen’s edge: Pt and Pl the first line and column, Pb and Pr the last, so CSI $ z erases the whole screen. A value past the edge is taken as the edge. If Pt is below Pb or Pl right of Pr, nothing is erased. With origin mode on, the corners count from the top and left margins; otherwise the margins play no part, and the rectangle may run across them. xterm parses the corners in xtermParseRect and erases in CASE_DECERA.

DEC STD 070 says the erased positions lose all their attributes. xterm fills them with spaces in the current rendition, keeping their colors (ScrnFillRectangle), and the cases follow xterm; none of them checks attributes.

Not in libghostty-vt

DECERA is one of the VT420’s rectangle operations, which DEC STD 070 makes level 4. libghostty-vt identifies itself as a VT220, level 2 (see DA), and has no handler for CSI … $ z in stream.zig, so it ignores it. xterm is a VT420 unless told otherwise (DFT_DECID) and implements DECERA at that level, so by this site’s rule every case below expects xterm’s result and is a known difference.

DECFRA fills a rectangle with a character instead, and DECSERA, on the selective erase page, erases only the characters not protected by DECSCA.

Validation

DECERA-1: A rectangle in the middle

abcdef\r\nghijkl\r\nmnopqr\r\nstuvwx
\e[1;3H
\e[2;2;3;4$z
|abcdef|
|g___kl|
|m___qr|
|stuvwx|
cursor 1,3

DECERA-2: The whole screen by default

abcdef\r\nghijkl\r\nmnopqr\r\nstuvwx
\e[$z
|______|
|______|
|______|
|______|

DECERA-3: Clipped to the screen

abcdef\r\nghijkl\r\nmnopqr\r\nstuvwx
\e[3;5;99;99$z
|abcdef|
|ghijkl|
|mnop__|
|stuv__|

DECERA-4: Counted from the margins in origin mode

abcdef\r\nghijkl\r\nmnopqr\r\nstuvwx
\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[1;1;2;2$z
|abcdef|
|g__jkl|
|m__pqr|
|stuvwx|

DECERA-5: Not limited by the margins otherwise

abcdef\r\nghijkl\r\nmnopqr\r\nstuvwx
\e[?69h   # allow left and right margins
\e[2;3s   # margins at columns 2 and 3
\e[1;2r   # region is lines 1 and 2
\e[2;2;4;6$z
|abcdef|
|g_____|
|m_____|
|s_____|
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.