Skip to content

Commit 7cf90fb

Browse files
author
SqlRush
committed
Parse application cursor mode
1 parent 3a9f0f7 commit 7cf90fb

5 files changed

Lines changed: 16 additions & 6 deletions

File tree

docs/cc-100-roadmap.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ M7 补充:terminal ESC parser 现在把 HTS horizontal-tab-set (`ESC H`) 解
146146

147147
M7 补充:terminal sequence dispatcher 现在把 SS3 application cursor (`ESC OA`/`OB`/`OC`/`OD`) 解析成结构化 cursor move action,避免 application cursor mode 序列落入 unknown。
148148

149+
M7 补充:terminal CSI parser 现在把 DEC `?1h/l` application cursor mode 解析成独立 mode action,和 SS3 application cursor key 解析闭环。
150+
149151
M7 补充:terminal CSI parser 现在把 REP repeat-preceding-character (`CSI b`/`CSI 4b`) 解析成 edit action,visible-text/snapshot pipeline 和 ANSI message wrapping/trim 会按重复次数展开前一个可重复 grapheme。
150152

151153
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
@@ -254,6 +254,7 @@ test/parity/ # golden tests against TS/official behavior
254254
- 本轮补充:terminal CSI parser 把 TBC tab-clear (`CSI g`/`CSI 3g`) 归入 cursor action,保留 clear-current/all code。
255255
- 本轮补充:terminal ESC parser 把 HTS horizontal-tab-set (`ESC H`) 归入 cursor/tab-set action,和 CSI tab-clear 控制序列形成闭环。
256256
- 本轮补充:terminal sequence dispatcher 把 SS3 application cursor (`ESC OA`/`OB`/`OC`/`OD`) 归入结构化 cursor move action,避免 application cursor mode 序列落入 unknown。
257+
- 本轮补充:terminal CSI parser 把 DEC `?1h/l` application cursor mode 解析成独立 mode action,和 SS3 application cursor key 解析闭环。
257258
- 本轮补充:terminal CSI parser 把 REP repeat-preceding-character (`CSI b`) 归入 edit action,visible-text/snapshot pipeline 和 ANSI message wrapping/trim 会按重复次数展开前一个可重复 grapheme。
258259
- 本轮补充:terminal CSI parser 按 ANSI 默认参数解析 scroll-region (`CSI r`/`CSI ;10r`),缺失 top 默认为 1,缺失 bottom 保持 0 表示 reset/full-height,避免 reset scroll region 被误判为单行区域。
259260
- 本轮补充: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
@@ -207,6 +207,7 @@ M7 progress now includes:
207207
- `internal/tui`: terminal sequence dispatcher and parser now classify DCS/APC/PM/SOS string-control sequences as `stringControl` actions with payload, terminator, and incomplete-flush state while keeping visible text extraction free of those invisible payloads.
208208
- `internal/tui`: terminal CSI parser now recognizes DEC highlight, UTF-8, and urxvt numeric mouse modes (`?1001h/l`, `?1005h/l`, `?1015h/l`) as mouse-tracking mode actions.
209209
- `internal/tui`: terminal CSI parser now recognizes xterm alternate scroll mode (`?1007h/l`) as a structured mode action instead of an unknown sequence.
210+
- `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.
210211
- `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.
211212
- `internal/tui`: keybinding config now accepts page navigation aliases such as `pgup`, `pg-up`, `prior`, `pgdn`, `pg-down`, and `next`.
212213
- `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: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const (
6363
CSICommandRestoreCursor byte = 'u'
6464
CSICommandTerminalParams byte = 'x'
6565

66+
DECModeApplicationCursor = 1
6667
DECModeCursorVisible = 25
6768
DECModeAltScreen = 47
6869
DECModeAltScreenBuffer = 1047
@@ -215,12 +216,13 @@ type CSIScrollAction struct {
215216
type CSIModeActionType string
216217

217218
const (
218-
CSIModeActionAlternateScreen CSIModeActionType = "alternateScreen"
219-
CSIModeActionBracketedPaste CSIModeActionType = "bracketedPaste"
220-
CSIModeActionMouseTracking CSIModeActionType = "mouseTracking"
221-
CSIModeActionFocusEvents CSIModeActionType = "focusEvents"
222-
CSIModeActionAlternateScroll CSIModeActionType = "alternateScroll"
223-
CSIModeActionSynchronized CSIModeActionType = "synchronizedOutput"
219+
CSIModeActionApplicationCursor CSIModeActionType = "applicationCursor"
220+
CSIModeActionAlternateScreen CSIModeActionType = "alternateScreen"
221+
CSIModeActionBracketedPaste CSIModeActionType = "bracketedPaste"
222+
CSIModeActionMouseTracking CSIModeActionType = "mouseTracking"
223+
CSIModeActionFocusEvents CSIModeActionType = "focusEvents"
224+
CSIModeActionAlternateScroll CSIModeActionType = "alternateScroll"
225+
CSIModeActionSynchronized CSIModeActionType = "synchronizedOutput"
224226
)
225227

226228
type CSIMouseTrackingMode string
@@ -543,6 +545,8 @@ func csiCursorStyle(index int) (CursorStyle, bool) {
543545

544546
func csiPrivateModeAction(mode int, enabled bool) (CSIAction, bool) {
545547
switch mode {
548+
case DECModeApplicationCursor:
549+
return CSIAction{Type: CSIActionMode, Mode: CSIModeAction{Type: CSIModeActionApplicationCursor, Enabled: enabled}}, true
546550
case DECModeCursorVisible:
547551
cursorType := CSICursorActionHide
548552
if enabled {

internal/tui/tui_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3642,6 +3642,8 @@ func TestParseCSISequenceActions(t *testing.T) {
36423642
seq string
36433643
want CSIModeAction
36443644
}{
3645+
{seq: "\x1b[?1h", want: CSIModeAction{Type: CSIModeActionApplicationCursor, Enabled: true}},
3646+
{seq: "\x1b[?1l", want: CSIModeAction{Type: CSIModeActionApplicationCursor, Enabled: false}},
36453647
{seq: EnterAlternateScreen, want: CSIModeAction{Type: CSIModeActionAlternateScreen, Enabled: true}},
36463648
{seq: "\x1b[?47l", want: CSIModeAction{Type: CSIModeActionAlternateScreen, Enabled: false}},
36473649
{seq: "\x1b[?1047h", want: CSIModeAction{Type: CSIModeActionAlternateScreen, Enabled: true}},

0 commit comments

Comments
 (0)