跳到主要内容
ansicode

DECSET ?2026 — 同步更新模式

在帧结束信号到来前缓冲屏幕更新 —— 全屏重绘时消除闪烁。

字节形式

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

\\x1b[\x1b[?2026h (begin frame) \x1b[?2026l (end frame)
\\033[\033[?2026h / \033[?2026l
\\e[\e[?2026h / \e[?2026l
ESC [ESC [ ? 2 0 2 6 h / l
hex1b 5b 3f 32 30 32 36 68 / 6c

说明

最早由 iTerm2 + contour 提案,如今 kitty、wezterm、foot、ghostty、Windows Terminal、mintty、alacritty(1.7+)以及 tmux(直通)均已采纳。把整屏重绘包裹在 `\x1b[?2026h`(开始同步更新)与 `\x1b[?2026l`(结束)之间,终端会暂停渲染直到收到 `l`,然后一次性绘制最终状态 —— 消除 neovim、helix、tui-rs、ratatui 等程序在慢速 PTY(尤其 SSH)下的半帧抖动。不识别 `?2026` 的终端按字节顺序绘制,因此可放心成对发送。需要严格检测的程序可用 DECRQM 查询 `\x1b[?2026$p` 并解析回报。建议单帧内 ≤ 100 ms —— 超时后终端会自动中止同步状态,避免屏幕卡死。

规范出处: Synchronized Output Mode (contour spec) / Mode 2026

示例

bash
printf '\033[?2026h'   # begin frame\n# … emit the full repaint here …\nprintf '\033[?2026l'   # end frame -> painted atomically
python
import sys\nsys.stdout.write('\x1b[?2026h'); redraw(); sys.stdout.write('\x1b[?2026l')
go
fmt.Print("\x1b[?2026h"); redraw(); fmt.Print("\x1b[?2026l")
javascript
process.stdout.write('\x1b[?2026h'); redraw(); process.stdout.write('\x1b[?2026l')
c
printf("\x1b[?2026h"); redraw(); printf("\x1b[?2026l");

终端支持

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

相关序列

在家族食谱中

DEC 食谱 · 6. 焦点事件与同步更新 —— `?1004`、`?2026`