Back to Ghostty Org

Scroll Up (SU)

docs/vt/csi/su.mdx

latest1.9 KB
Original Source

<VTSequence sequence={["CSI", "Pn", "S"]} />

The parameter n must be an integer greater than or equal to 1. If n is less than or equal to 0, adjust n to be 1. If n is omitted, n defaults to 1.

This sequence executes Delete Line (DL) with the cursor position set to the top of the scroll region. There are some differences from DL which are explained below.

The cursor position after the operation must be unchanged from when SU was invoked. The pending wrap state is not reset.

Validation

SU V-1: Simple Usage

bash
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "ABC\n"
printf "DEF\n"
printf "GHI\n"
printf "\033[2;2H"
printf "\033[S"
|DEF_____|
|GHI_____|

SU V-2: Top/Bottom Scroll Region

bash
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "ABC\n"
printf "DEF\n"
printf "GHI\n"
printf "\033[2;3r" # scroll region top/bottom
printf "\033[1;1H"
printf "\033[S"
|ABC_____|
|GHI_____|

SU V-3: Left/Right Scroll Regions

bash
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "ABC123\n"
printf "DEF456\n"
printf "GHI789\n"
printf "\033[?69h" # enable left/right margins
printf "\033[2;4s" # scroll region left/right
printf "\033[2;2H"
printf "\033[S"
|AEF423__|
|DHI756__|
|G___89__|

SU V-4: Preserves Pending Wrap

bash
cols=$(tput cols)
printf "\033[1;${cols}H" # move to top-right
printf "\033[2J" # clear screen
printf "A"
printf "\033[2;${cols}H"
printf "B"
printf "\033[3;${cols}H"
printf "C"
printf "\033[S"
printf "X"
|_______B|
|_______C|
|________|
|X_______|

SU V-5: Scroll Full Top/Bottom Scroll Region

bash
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "top"
printf "\033[5;1H"
printf "ABCDEF"
printf "\033[2;5r" # scroll region top/bottom
printf "\033[4S"
|top_____|