设置顶部和底部边距 (DECSTBM)
设置顶部和底部边距,也称为滚动区域。
- 0x1B
- ESC
- 0x5B
- [
- ____
- t
- 0x3B
- ;
- ____
- b
- 0x72
- r
参数 t 和 b 是整数值。如果任一值为 0,该值将被
重置为默认值。t 的默认值是 1,
b 的默认值是屏幕的行数。
值 t 和 b 可以省略。如果任一值被省略,
则使用其默认值。注意,不可能省略 t
而不省略 b。唯一有效的序列是 CSI t ; b r、
CSI t r 和 CSI r。
如果 top 大于等于 bottom,此序列不执行任何动作。滚动区域
必须至少有两行(b 必须大于 t)。
此序列描述的其余部分假定 t 和 b 为有效值。
此序列会取消待定换行状态,并将光标移到 屏幕左上角。如果设置了 原点模式,光标会 移到滚动区域的左上角。
要重置滚动区域,调用此序列并将两个值都设为
"0"。这将强制 t 和 b 的默认值,
即整个屏幕。
顶部与底部边距构成了所谓的_滚动区域_。滚动区域影响 许多序列的操作,如 插入行、光标下移 等。滚动区域是将终端的修改限制在 屏幕内矩形区域的有效且高效的方式。
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "ABC\n"
printf "DEF\n"
printf "GHI\n"
printf "\033[r" # scroll region top/bottom
printf "\033[T"
|c_______|
|ABC_____|
|DEF_____|
|GHI_____|
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "ABC\n"
printf "DEF\n"
printf "GHI\n"
printf "\033[2r" # scroll region top/bottom
printf "\033[T"
|ABC_____|
|________|
|DEF_____|
|GHI_____|
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "ABC\n"
printf "DEF\n"
printf "GHI\n"
printf "\033[1;2r" # scroll region top/bottom
printf "\033[T"
|________|
|ABC_____|
|GHI_____|
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;2r" # scroll region top/bottom
printf "\033[T"
|________|
|ABC_____|
|DEF_____|
|GHI_____|