^[control-codes live in libghostty-vt

Control sequences

DL Delete Line

Delete n lines at the cursor, pulling the lines below it up.

CSI Pn M
Defaults
Pn = 1
ECMA-48
§8.3.32 DL – Delete Line, p. 39
DEC STD 070
§5.11 Delete Line, p. 5-148
VT510
DL—Delete Line

Delete Pn lines, starting with the line the cursor is on. The lines below them, up to the bottom margin, move up to close the gap, and blank lines appear at the bottom margin. A 0 is taken as 1, and asking for more lines than there are between the cursor and the bottom margin deletes only those.

As with IL, only the scrolling region is affected, the part of each line between the left and right margins if those are set, and DL does nothing if the cursor is outside the region. The VT510 manual adds that the new blank lines have no visual character attributes.

Afterwards the cursor is at the left margin of the line it was on, which is what DEC STD 070 specifies.

SU also moves lines up, but from the top of the scrolling region, wherever the cursor is.

Validation

DL-1: Delete one line

1\r\n2\r\n3\r\n4
\e[2;3H
\e[M
|1____|
|3____|
|4____|
|_____|
cursor 2,1

DL-2: More lines than there are

1\r\n2\r\n3\r\n4
\e[2;1H
\e[9M
|1____|
|_____|
|_____|
|_____|

DL-3: Only the scrolling region moves

1\r\n2\r\n3\r\n4
\e[1;3r   # region is lines 1 to 3; homes the cursor
\e[M
|2____|
|3____|
|_____|
|4____|

DL-4: Nothing happens outside the scrolling region

1\r\n2\r\n3\r\n4
\e[2;3r   # region is lines 2 and 3; homes the cursor, above it
\e[M
|1____|
|2____|
|3____|
|4____|
cursor 1,1

DL-5: Inside left and right margins

abcde\r\nfghij\r\nklmno\r\npqrst\r\nuvwxy
\e[?69h   # allow left and right margins
\e[2;4s   # margins at columns 2 and 4
\e[2;3H   # on the h
\e[M
|abcde|
|flmnj|
|kqrso|
|pvwxt|
|u___y|
cursor 2,2
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.