跳到主要内容
ansicode

DECSCPP — 选择每页列数(CSI Pn $ |)

把活动页面调整为 80 或 132 列 —— DECCOLM 用私有模式表达的同一行为,DECSCPP 是其参数化等价物。

字节形式

涵盖所有常见的字符串字面量写法,方便正反查找。

\\x1b[\x1b[80$| (80 cols) \x1b[132$| (132 cols)
\\033[\033[80$| / \033[132$|
\\e[\e[80$| / \e[132$|
ESC [ESC [ Pn $ |
hex1b 5b 38 30 24 7c / 1b 5b 31 33 32 24 7c

说明

Set Columns Per Page。DEC VT400 / VT520 序列,中间字节 `$`(0x24),末字节 `|`(0x7c)。`Pn=80`(或省略)请求 80 列模式;`Pn=132` 请求 132 列模式;其他值静默忽略。**DECSCPP 是 DECCOLM 的参数化版本**(`\x1b[?3h/l`,slug `deccolm`):两者最终都让终端改变页宽,但 DECCOLM 是固定的二态开关,DECSCPP 显式携带列数。两者共享以下实现定义的副作用: - 屏幕被**清空**(以当前 SGR 背景填充空格)。 - 光标**归位**到第 1 行 / 第 1 列。 - 滚动区域(DECSTBM)与水平边距(DECSLRM)**重置**为整页。 这些副作用正是历史上感知 `resize` 的程序仅在终端初始化时发送 DECCOLM / DECSCPP、绝不在 TUI 渲染循环中触发的原因 —— 翻转列宽会清空可见缓冲。现代模拟器几乎一致:仅当配置时启用 DECCOLM(xterm 的 `allowC132` / `c132` 资源、gnome-terminal 的 allowAlternateScreen)时才尊重 DECSCPP;禁用时静默忽略 —— 与 DECCOLM 同样保守的姿态。中间字节陷阱:`CSI Pn |`(无 `$`)按上下文是 **DECTABSR / DECTSR**,不是 DECSCPP —— `$` 字节才把列数设置序列与制表 / 状态报告族区分开。

规范出处: DEC VT400 (DECSCPP) / xterm-ctlseqs

参数

Pn列数。`80`(或省略)选择 80 列模式;`132` 选择 132 列模式;其他值被忽略。

示例

bash
# Request 132-column wide mode for a log dump:\nprintf '\033[132$|'   # screen clears, cursor homes\ncat very-wide-output.log\nprintf '\033[80$|'    # restore 80-col on exit
python
import sys\nsys.stdout.write('\x1b[132$|')   # widen\ntry:\n    render_wide_table()\nfinally:\n    sys.stdout.write('\x1b[80$|')
go
fmt.Print("\x1b[132$|")   // wide\ndefer fmt.Print("\x1b[80$|")   // narrow back
javascript
process.stdout.write('\x1b[132$|')\nprocess.on('exit', () => process.stdout.write('\x1b[80$|'))
c
printf("\x1b[132$|");   /* 132 cols — clears screen, homes cursor */\nprintf("\x1b[80$|");    /* back to 80 */

终端支持

xterm
支持
Linux console (fbcon)
不支持
macOS Terminal.app
不支持
iTerm2
不支持
Windows Terminal
不支持
cmd.exe / ConPTY
不支持
kitty
不支持
alacritty
不支持
WezTerm
不支持
Ghostty
不支持
GNOME Terminal
部分
Konsole
部分
tmux
不支持
GNU screen
不支持

相关序列