光标位置 (CUP)
将光标移动到行 `y`、列 `x`。
- 0x1B
- ESC
- 0x5B
- [
- ____
- y
- 0x3B
- ;
- ____
- x
- 0x48
- H
参数 y 和 x 必须是大于等于 1 的整数。
任何一个小于等于 0 时,将该参数调整为 1。
值 y 和 x 均从 1 开始计数。例如,最顶行是第 1 行,
屏幕最左列是第 1 列。
此序列总是取消待定换行状态。
如果 没有设置 原点模式,光标会精确移动到
y 和 x 所指定的行和列。y 的最大值是
屏幕的最底行,x 的最大值是屏幕的最右列。
如果设置了 原点模式,光标位置相对于
滚动区域的左上角设置。y = 1 对应
上边距,x = 1 对应 左边距。
y 的最大值是 下边距,x 的最大值
是 右边距。
设置了原点模式时,使用此序列无法将光标位置设置到 滚动区域边界之外。
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "\033[2;3H"
printf "A"
|__________|
|__Ac______|
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "\033[500;500H"
printf "A"
|__________|
|__________|
|_________Ac
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "\033[2;3r" # scroll region top/bottom
printf "\033[?6h" # origin mode
printf "\033[1;1H" # move to top-left
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[2;3r" # scroll region top/bottom
printf "\033[?6h" # origin mode
printf "\033[1;1H" # move to top-left
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[2;3r" # scroll region top/bottom
printf "\033[?6h" # origin mode
printf "\033[500;500H" # move to top-left
printf "X"
|__________|
|__________|
|____X_____|
cols=$(tput cols)
printf "\033[${cols}G" # move to last column
printf "A" # set pending wrap state
printf "\033[1;1H"
printf "X"
|Xc_______X|