DECSCLM — 平滑滚动模式(CSI ? 4 h / l)
在平滑(逐帧一行的动画)与跳跃(瞬时)滚动间切换 —— DEC VT100 硬件时代的设置,现代模拟器几乎全部忽略。
字节形式
涵盖所有常见的字符串字面量写法,方便正反查找。
\\x1b[
\x1b[?4h (smooth) \x1b[?4l (jump)\\033[
\033[?4h / \033[?4l\\e[
\e[?4h / \e[?4lESC [
ESC [ ? 4 h / ESC [ ? 4 lhex
1b 5b 3f 34 68 / 6c说明
设置滚动模式。设置(`\x1b[?4h`)时,终端为滚动加动画 —— 内容需要向上滚动一行时,整屏像素在数帧内平滑上移,而非单次更新跳变。重置(`\x1b[?4l`,默认)是跳跃滚动 —— 单帧瞬时更新。DEC VT100 硬件有物理刷新率限制,使得平滑滚动可见地变慢(约每秒 6 行),合作型软件因此在终端上默认关闭,仅在 `cat` 之类强调可读性的文件显示时临时启用。在现代软件模拟器中差别基本失效 —— 帧率过高使 `?4h` 与 `?4l` 视觉差异微乎其微,模拟器要么以微动画形式实现(`gnometerm`、`iterm2`),要么静默忽略(`alacritty`、`kitty`、`wezterm`、`ghostty`、`Windows Terminal`)。主要用于 VT100 模拟器(xterm、mlterm)的历史准确性以及测试中区分 TUI 行为。注意:实现了平滑滚动时会降低有效吞吐 —— 批量打印日志前请关闭。
规范出处: DEC VT100 (DECSCLM) / xterm-ctlseqs
参数
示例
printf '\033[?4h' # smooth scroll on (visible on xterm, gnome-terminal)\nfor i in $(seq 1 80); do echo "line $i"; done\nprintf '\033[?4l'import sys\nsys.stdout.write('\x1b[?4l') # disable smooth scrolling before bulk log dumpfmt.Print("\x1b[?4h") // smooth on (will be no-op on most modern emulators)process.stdout.write('\x1b[?4l') // jump scrolling (default; explicit reset)printf("\x1b[?4l"); /* ensure jump-scroll before printing 10k log lines */终端支持
- xterm
- 支持
- Linux console (fbcon)
- 不支持
- macOS Terminal.app
- 部分
- iTerm2
- 部分
- Windows Terminal
- 不支持
- cmd.exe / ConPTY
- 不支持
- kitty
- 不支持
- alacritty
- 不支持
- WezTerm
- 不支持
- Ghostty
- 不支持
- GNOME Terminal
- 部分
- Konsole
- 部分
- tmux
- 不支持
- GNU screen
- 不支持
| xterm | Linux console (fbcon) | macOS Terminal.app | iTerm2 | Windows Terminal | cmd.exe / ConPTY | kitty | alacritty | WezTerm | Ghostty | GNOME Terminal | Konsole | tmux | GNU screen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 支持 | 不支持 | 部分 | 部分 | 不支持 | 不支持 | 不支持 | 不支持 | 不支持 | 不支持 | 部分 | 部分 | 不支持 | 不支持 |