^[control-codes live in libghostty-vt

Control sequences

CUU Cursor Up

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
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.

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.