Skip to content

Commit 4bc7493

Browse files
author
SqlRush
committed
Parse SGR-pixels mouse mode
1 parent 594bb63 commit 4bc7493

5 files changed

Lines changed: 9 additions & 3 deletions

File tree

docs/cc-100-roadmap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ M7 补充:prompt history `LogEntry` 读取现在接受 `sessionID`/`session`/`
862862

863863
本轮补充:terminal CSI parser 现在把 DEC `?9h/l` X10 mouse tracking mode 解析成 mouseTracking `x10` action,和 input tokenizer/parser 的 X10 mouse payload 支撑闭环。
864864

865-
本轮补充:terminal CSI parser 现在也把 DEC `?1001h/l` highlight、`?1005h/l` UTF-8 mouse mode`?1015h/l` urxvt numeric mouse mode 解析成 mouseTracking action,和输入侧 numeric mouse 兼容面闭环。
865+
本轮补充:terminal CSI parser 现在也把 DEC `?1001h/l` highlight、`?1005h/l` UTF-8 mouse mode`?1015h/l` urxvt numeric mouse mode 和 xterm `?1016h/l` SGR-pixels mouse mode 解析成 mouseTracking action,和输入侧 numeric/SGR mouse 兼容面闭环。
866866

867867
本轮补充:terminal CSI parser 现在把 xterm `?1007h/l` alternate scroll mode 解析成独立 mode action,避免 alternate-screen wheel 兼容序列落入 unknown。
868868

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ test/parity/ # golden tests against TS/official behavior
482482
- 本轮补充:terminal CSI parser 现在把 DSR (`CSI n`) 解析成 report action,覆盖 device-status、cursor-position 和 private-mode unknown report,避免 terminal status query/response 序列继续落入 generic unknown。
483483
- 本轮补充:terminal CSI parser 现在把 DEC `?1006h/l` SGR mouse mode 解析成 mouseTracking action,和 lifecycle 发出的 SGR mouse enable/disable 序列闭环。
484484
- 本轮补充:terminal CSI parser 现在把 DEC `?9h/l` X10 mouse tracking mode 解析成 mouseTracking `x10` action,和 input tokenizer/parser 的 X10 mouse payload 支撑闭环。
485-
- 本轮补充:terminal CSI parser 现在也把 DEC `?1001h/l` highlight、`?1005h/l` UTF-8 mouse mode`?1015h/l` urxvt numeric mouse mode 解析成 mouseTracking action,和输入侧 numeric mouse 兼容面闭环。
485+
- 本轮补充:terminal CSI parser 现在也把 DEC `?1001h/l` highlight、`?1005h/l` UTF-8 mouse mode`?1015h/l` urxvt numeric mouse mode 和 xterm `?1016h/l` SGR-pixels mouse mode 解析成 mouseTracking action,和输入侧 numeric/SGR mouse 兼容面闭环。
486486
- 本轮补充:terminal CSI parser 现在把 xterm `?1007h/l` alternate scroll mode 解析成独立 mode action,避免 alternate-screen wheel 兼容序列落入 unknown。
487487
- 本轮补充:terminal CSI parser 现在把 DEC `?2026h/l` synchronized output mode 解析成 mode action,和 renderer/snapshot 的 BSU/ESU 包裹路径闭环。
488488
- 本轮补充:terminal ESC helper 增加官方 ESC final-byte 判定和 `ParseESCSequence`/`ParseESCContent`,覆盖 RIS reset、DECSC/DECRC save/restore、IND/RI/NEL cursor action、HTS/charset ignored 分支和 unknown sequence fallback。

docs/first-second-parity-audit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ M7 progress now includes:
283283
- `internal/tui`: terminal CSI parser now emits structured edit actions for insert/delete chars and insert/delete lines, plus forward/back tab cursor actions; output `CSI M` is parsed as delete-lines while input tokenization still keeps X10 mouse payload handling separate.
284284
- `internal/tui`: terminal CSI parser now emits report actions for DSR `CSI n`, including device-status, cursor-position, and private-mode unknown reports.
285285
- `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.
286-
- `internal/tui`: terminal CSI parser now recognizes DEC X10, highlight, UTF-8, and urxvt numeric mouse modes (`?9h/l`, `?1001h/l`, `?1005h/l`, `?1015h/l`) as mouse-tracking mode actions.
286+
- `internal/tui`: terminal CSI parser now recognizes DEC X10, highlight, UTF-8, urxvt numeric, and xterm SGR-pixels mouse modes (`?9h/l`, `?1001h/l`, `?1005h/l`, `?1015h/l`, `?1016h/l`) as mouse-tracking mode actions.
287287
- `internal/tui`: terminal CSI parser now recognizes xterm alternate scroll mode (`?1007h/l`) as a structured mode action instead of an unknown sequence.
288288
- `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.
289289
- `internal/tui`: terminal CSI parser now recognizes DEC 132/80-column mode (`?3h/l`) as a structured `columnMode` action.

internal/tui/terminal_csi.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ const (
104104
DECModeMouseSGR = 1006
105105
DECModeAlternateScroll = 1007
106106
DECModeMouseURXVT = 1015
107+
DECModeMouseSGRPixels = 1016
107108
DECModeBracketedPaste = 2004
108109
DECModeSynchronizedUpdate = 2026
109110
)
@@ -298,6 +299,7 @@ const (
298299
CSIMouseTrackingUTF8 CSIMouseTrackingMode = "utf8"
299300
CSIMouseTrackingSGR CSIMouseTrackingMode = "sgr"
300301
CSIMouseTrackingURXVT CSIMouseTrackingMode = "urxvt"
302+
CSIMouseTrackingSGRPixels CSIMouseTrackingMode = "sgrPixels"
301303
)
302304

303305
type CSIModeAction struct {
@@ -792,6 +794,8 @@ func csiPrivateModeAction(mode int, enabled bool) (CSIAction, bool) {
792794
return CSIAction{Type: CSIActionMode, Mode: CSIModeAction{Type: CSIModeActionAlternateScroll, Enabled: enabled}}, true
793795
case DECModeMouseURXVT:
794796
return csiMouseModeAction(CSIMouseTrackingURXVT, enabled), true
797+
case DECModeMouseSGRPixels:
798+
return csiMouseModeAction(CSIMouseTrackingSGRPixels, enabled), true
795799
case DECModeFocusEvents:
796800
return CSIAction{Type: CSIActionMode, Mode: CSIModeAction{Type: CSIModeActionFocusEvents, Enabled: enabled}}, true
797801
case DECModeSynchronizedUpdate:

internal/tui/tui_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4353,6 +4353,8 @@ func TestParseCSISequenceActions(t *testing.T) {
43534353
{seq: "\x1b[?1007l", want: CSIModeAction{Type: CSIModeActionAlternateScroll, Enabled: false}},
43544354
{seq: "\x1b[?1015h", want: CSIModeAction{Type: CSIModeActionMouseTracking, Enabled: true, MouseMode: CSIMouseTrackingURXVT}},
43554355
{seq: "\x1b[?1015l", want: CSIModeAction{Type: CSIModeActionMouseTracking, Enabled: false, MouseMode: CSIMouseTrackingOff}},
4356+
{seq: "\x1b[?1016h", want: CSIModeAction{Type: CSIModeActionMouseTracking, Enabled: true, MouseMode: CSIMouseTrackingSGRPixels}},
4357+
{seq: "\x1b[?1016l", want: CSIModeAction{Type: CSIModeActionMouseTracking, Enabled: false, MouseMode: CSIMouseTrackingOff}},
43564358
{seq: EnableFocusEvents, want: CSIModeAction{Type: CSIModeActionFocusEvents, Enabled: true}},
43574359
{seq: BeginSynchronizedOutput, want: CSIModeAction{Type: CSIModeActionSynchronized, Enabled: true}},
43584360
{seq: EndSynchronizedOutput, want: CSIModeAction{Type: CSIModeActionSynchronized, Enabled: false}},

0 commit comments

Comments
 (0)