^[control-codes
live in libghostty-vt

Control sequences

CUU Cursor Up

View as Markdown

Move the cursor up n lines.

CSI Pn A
Defaults
Pn = 1
ECMA-48
§8.3.22 CUU – Cursor Up, p. 37
DEC STD 070
§5.4.4 Cursor Up, p. 5-41
VT220
§4.7 Cursor Positioning
VT510
CUU—Cursor Up

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

The cursor stops at the top margin if it started at or below it. A cursor already above the top margin, which only absolute positioning can put there, stops at the first line instead. CUU never scrolls: at the top margin it simply goes no further, where RI would scroll the region down.

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 CursorUp, and libghostty-vt does the same.

CUD goes the other way, and CPL moves up and returns to the left margin as well.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984Yes§4.7 Cursor Positioning
VT510manual, 1st ed., 1993YesCUU
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 CUU-3 of the 5 cases that show it working
pyte0.8.2, run as a libraryPartlyfails CUU-4, CUU-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 CUU-3 of the 5 cases that show it working
ConEmubuild 230724, its documentationYeslists ESC [ lines A: 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

CUU-1: Up one line

\e[3;2H
\e[A
X
|_____|
|_X___|
|_____|

CUU-2: Up n lines, stopping at the first line

\e[3;2H
\e[9A
X
|_X___|
|_____|
|_____|

CUU-3: Stops at the top margin

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

CUU-4: Above the top margin

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

CUU-5: From a pending wrap

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