^[control-codes
live in libghostty-vt

Control sequences

CUD Cursor Down

View as Markdown

Move the cursor down n lines.

CSI Pn B
Defaults
Pn = 1
ECMA-48
§8.3.19 CUD – Cursor Down, p. 36
DEC STD 070
§5.4.4 Cursor Down, p. 5-43
VT220
§4.7 Cursor Positioning
VT510
CUD—Cursor Down

Move the cursor Pn lines down, keeping its column. A 0 is taken as 1.

The cursor stops at the bottom margin if it started at or above it. A cursor already below the bottom margin stops at the last line instead. CUD never scrolls, which is the difference between it and a line feed: at the bottom margin a line feed scrolls the region up, and CUD stays put.

Moving the cursor cancels any pending wrap. DEC STD 070 calls the pending wrap the Last Column Flag, and its appendix on autowrap lists this among the controls that should reset it (§D.6.1, p. D-13); xterm clears it in CursorDown, and libghostty-vt does the same.

CUU goes the other way, and CNL moves down and returns to the left margin as well.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984Yes§4.7 Cursor Positioning
VT510manual, 1st ed., 1993YesCUD
xtermpatch 412, xterm-411aYes
libghostty-vt0f171f6Yes
kitty0.49.1, run in a VMYespasses the 5 cases that show it working
foot1.28.0, run in a VMPartlyfails CUD-3 of the 5 cases that show it working
pyte0.8.2, run as a libraryPartlyfails CUD-4, CUD-5 of the 5 cases that show it working
xterm.js headless6.0.0, run as a libraryYespasses the 5 cases that show it working
alacritty_terminal0.26.0, run as a libraryPartlyfails CUD-3 of the 5 cases that show it working
ConEmubuild 230724, its documentationYeslists ESC [ lines B: ANSI escape codes
rxvt-unicode9.31, run in a VMYespasses the 5 cases that show it working
VTE0.84.1, run as a libraryYespasses the 5 cases that show it working

Validation

CUD-1: Down one line

\e[1;2H
\e[B
X
|_____|
|_X___|
|_____|

CUD-2: Down n lines, stopping at the last line

\e[1;2H
\e[9B
X
|_____|
|_____|
|_X___|

CUD-3: Stops at the bottom margin, without scrolling

A
\e[1;3r   # region is lines 1 to 3
\e[2;1H
\e[9B
X
|A____|
|_____|
|X____|
|_____|

CUD-4: Below the bottom margin

\e[1;2r   # region is lines 1 and 2
\e[3;1H   # below it
\e[9B
X
|_____|
|_____|
|_____|
|X____|

CUD-5: From a pending wrap

ABCDE     # fills the line; a wrap is pending
\e[B
X
|ABCDE|
|____X|
|_____|
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.