Skip to content

Commit a5989e0

Browse files
author
SqlRush
committed
Parse DEC allow column switch mode
1 parent 2cd9d56 commit a5989e0

5 files changed

Lines changed: 11 additions & 1 deletion

File tree

docs/cc-100-roadmap.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ M7 补充:terminal CSI parser 现在把 DEC `?1h/l` application cursor mode
156156

157157
M7 补充:terminal CSI parser 现在把 DEC `?3h/l` 132/80-column mode 解析成结构化 `columnMode` action,覆盖常见列宽状态切换序列。
158158

159+
M7 补充:terminal CSI parser 现在把 DEC `?40h/l` allow column switching mode 解析成结构化 `allowColumnSwitch` mode action,补齐 `?3h/l` 列宽切换相邻的许可状态序列。
160+
159161
M7 补充:terminal CSI parser 现在把 DEC `?5h/l` reverse video/screen mode 解析成结构化 `reverseVideo` mode action,继续减少终端显示状态序列的 unknown fallback。
160162

161163
M7 补充:terminal CSI parser 现在把普通 `CSI 4h/l` insert/replace mode 解析成 `insertMode` action,避免 ECMA mode set/reset 序列落入 unknown。

docs/claude-code-go-rewrite-plan.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ test/parity/ # golden tests against TS/official behavior
261261
- 本轮补充:terminal sequence dispatcher 把 SS3 application cursor (`ESC OA`/`OB`/`OC`/`OD`) 归入结构化 cursor move action,避免 application cursor mode 序列落入 unknown。
262262
- 本轮补充:terminal CSI parser 把 DEC `?1h/l` application cursor mode 解析成独立 mode action,和 SS3 application cursor key 解析闭环。
263263
- 本轮补充:terminal CSI parser 把 DEC `?3h/l` 132/80-column mode 解析成结构化 `columnMode` action,覆盖常见列宽状态切换序列。
264+
- 本轮补充:terminal CSI parser 把 DEC `?40h/l` allow column switching mode 解析成结构化 `allowColumnSwitch` mode action,补齐 `?3h/l` 列宽切换相邻的许可状态序列。
264265
- 本轮补充:terminal CSI parser 把 DEC `?5h/l` reverse video/screen mode 解析成结构化 `reverseVideo` mode action,继续减少终端显示状态序列的 unknown fallback。
265266
- 本轮补充:terminal CSI parser 把普通 `CSI 4h/l` insert/replace mode 解析成 `insertMode` action,避免 ECMA mode set/reset 序列落入 unknown。
266267
- 本轮补充:terminal CSI parser 把普通 `CSI 20h/l` line-feed/new-line mode 解析成 `lineFeedMode` action,继续覆盖 ECMA mode set/reset 序列。

docs/first-second-parity-audit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ M7 progress now includes:
212212
- `internal/tui`: terminal CSI parser now recognizes xterm alternate scroll mode (`?1007h/l`) as a structured mode action instead of an unknown sequence.
213213
- `internal/tui`: terminal CSI parser now recognizes DEC application cursor mode (`?1h/l`) as a structured mode action, pairing with SS3 application cursor key parsing.
214214
- `internal/tui`: terminal CSI parser now recognizes DEC 132/80-column mode (`?3h/l`) as a structured `columnMode` action.
215+
- `internal/tui`: terminal CSI parser now recognizes DEC allow-column-switching mode (`?40h/l`) as a structured `allowColumnSwitch` mode action.
215216
- `internal/tui`: terminal CSI parser now recognizes DEC reverse video/screen mode (`?5h/l`) as a structured `reverseVideo` mode action.
216217
- `internal/tui`: terminal CSI parser now recognizes ordinary ECMA insert/replace mode (`CSI 4h/l`) as a structured `insertMode` action.
217218
- `internal/tui`: terminal CSI parser now recognizes ordinary ECMA line-feed/new-line mode (`CSI 20h/l`) as a structured `lineFeedMode` action.

internal/tui/terminal_csi.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ const (
7575
DECModeMouseX10 = 9
7676
DECModeCursorBlink = 12
7777
DECModeCursorVisible = 25
78-
DECModeAltScreen = 47
78+
DECModeAllowColumnSwitch = 40
7979
DECModeReverseWrap = 45
80+
DECModeAltScreen = 47
8081
DECModeApplicationKeypad = 66
8182
DECModeBackarrowKey = 67
8283
DECModeAltScreenBuffer = 1047
@@ -235,6 +236,7 @@ const (
235236
CSIModeActionInsert CSIModeActionType = "insertMode"
236237
CSIModeActionLineFeed CSIModeActionType = "lineFeedMode"
237238
CSIModeActionColumn CSIModeActionType = "columnMode"
239+
CSIModeActionAllowColumnSwitch CSIModeActionType = "allowColumnSwitch"
238240
CSIModeActionReverseVideo CSIModeActionType = "reverseVideo"
239241
CSIModeActionOrigin CSIModeActionType = "originMode"
240242
CSIModeActionAutoWrap CSIModeActionType = "autoWrap"
@@ -579,6 +581,8 @@ func csiPrivateModeAction(mode int, enabled bool) (CSIAction, bool) {
579581
return CSIAction{Type: CSIActionMode, Mode: CSIModeAction{Type: CSIModeActionApplicationCursor, Enabled: enabled}}, true
580582
case DECModeColumn:
581583
return CSIAction{Type: CSIActionMode, Mode: CSIModeAction{Type: CSIModeActionColumn, Enabled: enabled}}, true
584+
case DECModeAllowColumnSwitch:
585+
return CSIAction{Type: CSIActionMode, Mode: CSIModeAction{Type: CSIModeActionAllowColumnSwitch, Enabled: enabled}}, true
582586
case DECModeReverseVideo:
583587
return CSIAction{Type: CSIActionMode, Mode: CSIModeAction{Type: CSIModeActionReverseVideo, Enabled: enabled}}, true
584588
case DECModeOrigin:

internal/tui/tui_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3650,6 +3650,8 @@ func TestParseCSISequenceActions(t *testing.T) {
36503650
{seq: "\x1b[?1l", want: CSIModeAction{Type: CSIModeActionApplicationCursor, Enabled: false}},
36513651
{seq: "\x1b[?3h", want: CSIModeAction{Type: CSIModeActionColumn, Enabled: true}},
36523652
{seq: "\x1b[?3l", want: CSIModeAction{Type: CSIModeActionColumn, Enabled: false}},
3653+
{seq: "\x1b[?40h", want: CSIModeAction{Type: CSIModeActionAllowColumnSwitch, Enabled: true}},
3654+
{seq: "\x1b[?40l", want: CSIModeAction{Type: CSIModeActionAllowColumnSwitch, Enabled: false}},
36533655
{seq: "\x1b[?5h", want: CSIModeAction{Type: CSIModeActionReverseVideo, Enabled: true}},
36543656
{seq: "\x1b[?5l", want: CSIModeAction{Type: CSIModeActionReverseVideo, Enabled: false}},
36553657
{seq: "\x1b[?6h", want: CSIModeAction{Type: CSIModeActionOrigin, Enabled: true}},

0 commit comments

Comments
 (0)