Cursor Forward (CUF)
Move the cursor `n` cells right.
- 0x1B
- ESC
- 0x5B
- [
- ____
- n
- 0x43
- C
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.
The rightmost boundary the cursor can move to is determined by the current cursor column and the right margin. If the cursor begins to the right of the right margin, modify the right margin to be the rightmost column of the screen for the duration of the sequence. The rightmost column the cursor can be on is the right margin.
Move the cursor n
cells to the right up to and including the rightmost boundary.
This sequence never wraps or modifies cell content. This sequence is not affected
by any terminal modes.
cols=$(tput cols)
printf "\033[${cols}G" # move to last column
printf "A" # set pending wrap state
printf "\033[C" # move forward one
printf "XYZ"
|_________X|
|YZ________|
printf "A"
printf "\033[500C" # forward larger than screen width
printf "B"
|A________Bc
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "\033[?69h" # enable left/right margins
printf "\033[3;5s" # scroll region left/right
printf "\033[1G" # move to left
printf "\033[500C" # forward larger than screen width
printf "X"
|____X_____|
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "\033[?69h" # enable left/right margins
printf "\033[3;5s" # scroll region left/right
printf "\033[6G" # move to right of margin
printf "\033[500C" # forward larger than screen width
printf "X"
|_________X|