^[control-codes live in libghostty-vt

Control sequences

EL Erase in Line

Erase part or all of the cursor's line.

CSI Ps K
Defaults
Ps = 0
ECMA-48
§8.3.41 EL – Erase in Line, p. 42
DEC STD 070
§5.11 Erase in Line, p. 5-154
VT510
EL—Erase in Line

Erase some of the line the cursor is on, chosen by Ps:

PsErases
0from the cursor to the end of the line, the cursor’s cell included
1from the start of the line to the cursor, the cursor’s cell included
2the whole line

The cursor does not move, and as with ED, erased cells take the current background color. CSI K is what a shell prints to clear the rest of a line it is redrawing.

Validation

EL-1: To the right

\e#8      # fill with E
\e[2;3H
\e[K
|EEEEE|
|EE___|
|EEEEE|
cursor 2,3

EL-2: To the left

\e#8      # fill with E
\e[2;3H
\e[1K
|EEEEE|
|___EE|
|EEEEE|

EL-3: The whole line

\e#8      # fill with E
\e[2;3H
\e[2K
|EEEEE|
|_____|
|EEEEE|

EL-4: With a background color

ABCDE
\e[1;3H
\e[41m    # red background
\e[K
|AB___|
attr 1,2 bg=default
attr 1,3 bg=1
attr 1,5 bg=1
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.