Skip to content

Commit 2cd9d56

Browse files
author
SqlRush
committed
Parse DEC backarrow key mode
1 parent f1085e7 commit 2cd9d56

5 files changed

Lines changed: 10 additions & 0 deletions

File tree

docs/cc-100-roadmap.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ M7 补充:terminal CSI parser 现在把 xterm/DEC `?45h/l` reverse-wraparound
172172

173173
M7 补充:terminal CSI parser 现在把 DEC `?66h/l` application keypad mode 解析成结构化 `applicationKeypad` mode action,补齐 application cursor mode 相邻的输入状态序列。
174174

175+
M7 补充:terminal CSI parser 现在把 DEC `?67h/l` backarrow key mode 解析成结构化 `backarrowKey` mode action,补齐键盘输入状态序列。
176+
175177
M7 补充:terminal CSI parser 现在把 REP repeat-preceding-character (`CSI b`/`CSI 4b`) 解析成 edit action,visible-text/snapshot pipeline 和 ANSI message wrapping/trim 会按重复次数展开前一个可重复 grapheme。
176178

177179
M7 补充:terminal CSI parser 现在按 ANSI 默认参数解析 scroll-region (`CSI r`/`CSI ;10r`),缺失 top 默认为 1,缺失 bottom 保持为 0 表示 reset/full-height,避免把 reset 误判为单行区域。

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ test/parity/ # golden tests against TS/official behavior
269269
- 本轮补充:terminal CSI parser 把 DEC `?12h/l` cursor blink mode 解析成结构化 `cursorBlink` mode action,补齐 cursor visibility/style 相邻的终端状态序列。
270270
- 本轮补充:terminal CSI parser 把 xterm/DEC `?45h/l` reverse-wraparound mode 解析成结构化 `reverseWrap` mode action,补齐 auto-wrap 相邻的 wrap 状态序列。
271271
- 本轮补充:terminal CSI parser 把 DEC `?66h/l` application keypad mode 解析成结构化 `applicationKeypad` mode action,补齐 application cursor mode 相邻的输入状态序列。
272+
- 本轮补充:terminal CSI parser 把 DEC `?67h/l` backarrow key mode 解析成结构化 `backarrowKey` mode action,补齐键盘输入状态序列。
272273
- 本轮补充:terminal CSI parser 把 REP repeat-preceding-character (`CSI b`) 归入 edit action,visible-text/snapshot pipeline 和 ANSI message wrapping/trim 会按重复次数展开前一个可重复 grapheme。
273274
- 本轮补充:terminal CSI parser 按 ANSI 默认参数解析 scroll-region (`CSI r`/`CSI ;10r`),缺失 top 默认为 1,缺失 bottom 保持 0 表示 reset/full-height,避免 reset scroll region 被误判为单行区域。
274275
- 本轮补充:terminal CSI parser 把 DECSTR soft reset (`CSI !p`) 归入 reset action,并在 terminal parser 中清理 SGR/link 状态。

docs/first-second-parity-audit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ M7 progress now includes:
220220
- `internal/tui`: terminal CSI parser now recognizes DEC cursor blink mode (`?12h/l`) as a structured `cursorBlink` mode action.
221221
- `internal/tui`: terminal CSI parser now recognizes xterm/DEC reverse-wraparound mode (`?45h/l`) as a structured `reverseWrap` mode action.
222222
- `internal/tui`: terminal CSI parser now recognizes DEC application keypad mode (`?66h/l`) as a structured `applicationKeypad` mode action.
223+
- `internal/tui`: terminal CSI parser now recognizes DEC backarrow key mode (`?67h/l`) as a structured `backarrowKey` mode action.
223224
- `internal/tui`: keybinding config, keymap resolution, and interaction script named-key input now accept terminal aliases for `ctrl-h`/`ctrl-i`/`ctrl-j`/`ctrl-m`, `ctrl-[`, and `ctrl-?`, including `control-*` and compact/camel variants.
224225
- `internal/tui`: keybinding config now accepts page navigation aliases such as `pgup`, `pg-up`, `prior`, `pgdn`, `pg-down`, and `next`.
225226
- `internal/tui`: terminal key parsing now accepts CSI-u/kitty keyboard protocol sequences for existing ctrl/alt editing keys, shift-enter, shift-tab, and printable shift-only runes.

internal/tui/terminal_csi.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ const (
7878
DECModeAltScreen = 47
7979
DECModeReverseWrap = 45
8080
DECModeApplicationKeypad = 66
81+
DECModeBackarrowKey = 67
8182
DECModeAltScreenBuffer = 1047
8283
DECModeSaveRestoreCursor = 1048
8384
DECModeAltScreenClear = 1049
@@ -241,6 +242,7 @@ const (
241242
CSIModeActionReverseWrap CSIModeActionType = "reverseWrap"
242243
CSIModeActionCursorBlink CSIModeActionType = "cursorBlink"
243244
CSIModeActionApplicationKeypad CSIModeActionType = "applicationKeypad"
245+
CSIModeActionBackarrowKey CSIModeActionType = "backarrowKey"
244246
CSIModeActionMouseTracking CSIModeActionType = "mouseTracking"
245247
CSIModeActionFocusEvents CSIModeActionType = "focusEvents"
246248
CSIModeActionAlternateScroll CSIModeActionType = "alternateScroll"
@@ -601,6 +603,8 @@ func csiPrivateModeAction(mode int, enabled bool) (CSIAction, bool) {
601603
return CSIAction{Type: CSIActionMode, Mode: CSIModeAction{Type: CSIModeActionAlternateScreen, Enabled: enabled}}, true
602604
case DECModeApplicationKeypad:
603605
return CSIAction{Type: CSIActionMode, Mode: CSIModeAction{Type: CSIModeActionApplicationKeypad, Enabled: enabled}}, true
606+
case DECModeBackarrowKey:
607+
return CSIAction{Type: CSIActionMode, Mode: CSIModeAction{Type: CSIModeActionBackarrowKey, Enabled: enabled}}, true
604608
case DECModeSaveRestoreCursor:
605609
cursorType := CSICursorActionRestore
606610
if enabled {

internal/tui/tui_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3664,6 +3664,8 @@ func TestParseCSISequenceActions(t *testing.T) {
36643664
{seq: "\x1b[?45l", want: CSIModeAction{Type: CSIModeActionReverseWrap, Enabled: false}},
36653665
{seq: "\x1b[?66h", want: CSIModeAction{Type: CSIModeActionApplicationKeypad, Enabled: true}},
36663666
{seq: "\x1b[?66l", want: CSIModeAction{Type: CSIModeActionApplicationKeypad, Enabled: false}},
3667+
{seq: "\x1b[?67h", want: CSIModeAction{Type: CSIModeActionBackarrowKey, Enabled: true}},
3668+
{seq: "\x1b[?67l", want: CSIModeAction{Type: CSIModeActionBackarrowKey, Enabled: false}},
36673669
{seq: EnterAlternateScreen, want: CSIModeAction{Type: CSIModeActionAlternateScreen, Enabled: true}},
36683670
{seq: "\x1b[?47l", want: CSIModeAction{Type: CSIModeActionAlternateScreen, Enabled: false}},
36693671
{seq: "\x1b[?1047h", want: CSIModeAction{Type: CSIModeActionAlternateScreen, Enabled: true}},

0 commit comments

Comments
 (0)