Cursor Up (CUU)
Move the cursor `n` cells up.
- 0x1B
- ESC
- 0x5B
- [
- ____
- n
- 0x41
- A
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 always unsets the pending wrap state.
If the current cursor position is at or below the top margin, the highest point the cursor can move is the top margin. If the current cursor position is above the top margin, the highest point the cursor can move is the first row.
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "\033[3;1H"
printf "A"
printf "\033[2A" # cursor up
printf "X"
|_Xc_______|
|__________|
|A_________|
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "\n\n\n\n" # screen is 4 high
printf "\033[2;4r" # set scrolling region
printf "\033[3;1H"
printf "A"
printf "\033[5A" # cursor up
printf "X"
|__________|
|_Xc_______|
|A_________|
|__________|
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "\n\n\n\n\n" # screen is 5 high
printf "\033[3;5r" # set scrolling region
printf "\033[3;1H"
printf "A"
printf "\033[2;1H" # move above region
printf "\033[5A" # cursor up
printf "X"
|Xc________|
|__________|
|A_________|
|__________|
|__________|