Skip to content

Commit 87238d0

Browse files
author
SqlRush
committed
Parse modified SS3 function keys
1 parent a8f81ae commit 87238d0

5 files changed

Lines changed: 26 additions & 1 deletion

File tree

docs/cc-100-roadmap.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ M6 补充:microcompact disk cache loader 现在接受更多相邻 timestamp/ex
208208

209209
M7 补充:keybinding resolver/config 和脚本 named-key 输入已覆盖 `ctrl-h`/`ctrl-i`/`ctrl-j`/`ctrl-m`、`ctrl-[`、`ctrl-?` 及 `control-*` 终端别名;terminal parser 支持 CSI-u/kitty keyboard protocol 的 ctrl/alt/shift-enter/shift-tab 序列;image hint parser 支持 OSC ST terminator 和 base64 `name=` filename;keybinding JSON loader 支持 wrapper object-map、`shortcuts`、object action 字段、string-array key sequence/chord 和 `null`/`false` unbind;mouse parser 支持 legacy X10/normal tracking 序列;interaction script 支持结构化 mouse/mouse_event 步骤,button 接受 `buttonMask`/`button_mask`/`btn`/`code`/`mask`,坐标接受 `mouseX`/`mouse_x`/`clientX`/`screenX`/`pageX`/`offsetX`/`viewportX` 和对应 Y/row/line 别名,release 接受 `mouseUp`/`isRelease`/`mouseRelease`/`releaseEvent` 等字段别名;interaction script 还支持字符串 `keys` 和 `input`/`input_text`/`keys_text`/`raw_key`/`paste_text` 字段别名,status/snapshot/viewport/pasted-content contains 断言接受单字符串或字符串数组,且 `keybindings`、`expectEvents`、`expectDialogResults`、`expectPrompt.pastedContents`、`expectTasks.contains` 接受单对象或对象数组。
210210

211+
M7 补充:terminal input parser 现在把 modified SS3 function-key 序列(如 `ESC O 1;2P``ESC O 1;5Q``ESC O 1;16S`)归一为现有 F1-F4 key surface,补齐 xterm/kitty 兼容模式下的 F-key 输入形态。
212+
211213
M7 补充:task runtime 现在会在状态行、任务面板排序/渲染、批量取消和 scripted task expectation 前把 `active`/`in_progress``success`/`done``error``canceled` 等 task state 别名归一为 canonical 状态。
212214

213215
M7 补充:permission runtime 现在会把 `Reject`/`deny`/`decline`/`disallow`/`no` 等 permission action 归一为 denied 结果,把 `Cancel`/`abort` 归一为 cancelled 结果,并让 scripted dialog-result status 断言接受 `rejected`/`approved` 等状态别名。

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ test/parity/ # golden tests against TS/official behavior
364364
- 本轮补充:scripted interaction expectation wrapper 现在也接受 assertion/check 数组;数组元素可用 `type`/`kind`/`name`/`target` 等 discriminator 加 `value`/`payload` 载荷声明 prompt/event/dialog/snapshot/screen/task/vim/viewport 断言,覆盖官方 fixture 常见的分列 checks 形态。
365365
- 本轮补充:scripted interaction assertion/check 数组元素的载荷现在也接受 `resource`/`node`/`attributes`/`properties`/`result`/`response`/`output`,让 JSON:API/resource-style 断言体可直接映射到 prompt/event/dialog/snapshot/screen/task/vim/viewport expectation。
366366
- 本轮补充:keybinding config、keymap 解析和 interaction script named-key 输入接受 `ctrl-h`/`ctrl-i`/`ctrl-j`/`ctrl-m`、`ctrl-[`、`ctrl-?`、对应 `control-*` 以及 compact/camel 形式;terminal parser 支持 CSI-u/kitty keyboard protocol 的 ctrl/alt/shift-enter/shift-tab 序列;image hint parser 支持 OSC ST terminator 和 base64 `name=` filename;keybinding JSON loader 支持 wrapper object-map、`shortcuts`、object action 字段、string-array key sequence/chord 和 `null`/`false` unbind;mouse parser 支持 legacy X10/normal tracking 序列;interaction script 支持结构化 mouse/mouse_event 步骤,button 接受 `buttonMask`/`button_mask`/`btn`/`code`/`mask`,坐标接受 `mouseX`/`mouse_x`/`clientX`/`screenX`/`pageX`/`offsetX`/`viewportX` 和对应 Y/row/line 别名,release 接受 `mouseUp`/`isRelease`/`mouseRelease`/`releaseEvent` 等字段别名;interaction script 还支持字符串 `keys` 和 `input`/`input_text`/`keys_text`/`raw_key`/`paste_text` 字段别名,并允许 status/snapshot/viewport/pasted-content contains 断言使用单字符串或字符串数组,`keybindings`、`expectEvents`、`expectDialogResults`、`expectPrompt.pastedContents` 和 `expectTasks.contains` 使用单对象或对象数组。
367+
- 本轮补充:terminal input parser 现在把 modified SS3 function-key 序列(如 `ESC O 1;2P``ESC O 1;5Q``ESC O 1;16S`)归一为现有 F1-F4 key surface,补齐 xterm/kitty 兼容模式下的 F-key 输入形态。
367368
- 本轮补充:keybinding config 的 page/navigation/editing key name 现在接受 `pgup`/`pg-up`/`prior`/`pageUpKey``pgdn`/`pg-down`/`next`/`pageDownKey``homeKey`/`endKey``deleteForward`/`forwardDelete``deleteBackward`,覆盖常见终端、DOM 和配置别名。
368369
- 本轮补充:keybinding config 和脚本 named-key 输入现在接受 DOM/fixture 风格的 `enterKey`/`returnKey`/`numpadEnter``escapeKey`/`escKey``tabKey``shiftEnterKey`/`shiftNumpadEnter``shiftTabKey`/`backtabKey`,减少配置导入时对基础控制键名称的手工归一。
369370
- 本轮补充:keybinding config 和脚本 named-key 输入接受 DOM-style arrow key aliases,包括 `arrowLeft`/`arrowRight`/`arrowUp`/`arrowDown` 以及 ctrl/alt/meta/option arrow variants。

docs/first-second-parity-audit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ M7 progress now includes:
510510
- `internal/tui`: Vim macro recording now treats uppercase macro registers such as `qA` as append-to-lowercase register operations, matching the existing named-register append behavior while keeping `@a`/`@@` playback on the canonical lowercase macro.
511511
- `internal/tui`: key parsing and configurable keybindings now expose `ctrl+space` from raw NUL and Kitty/CSI-u `0u`, `32;5u`, `64;5u`, and `50;5u` forms, with `ctrl-space`/`ctrl-@`/`ctrl-2` and compact `cSpace`/`c@`/`c2` aliases available for user keymaps and scripts.
512512
- `internal/tui`: key parsing and configurable keybindings now expose Ctrl-backslash, Ctrl-], Ctrl-^/Ctrl-6, and Ctrl-_/Ctrl-/ from raw terminal control bytes and Kitty/CSI-u forms, with symbol, named, and compact aliases available for user keymaps and scripts.
513-
- `internal/tui`: key parsing and configurable keybindings now expose F1-F12 from common SS3, legacy Linux-console, tilde CSI, and modified CSI function-key sequences, with `f1`, `function-key-1`, and `fn1` style aliases available for user keymaps and scripts.
513+
- `internal/tui`: key parsing and configurable keybindings now expose F1-F12 from common SS3, modified SS3, legacy Linux-console, tilde CSI, and modified CSI function-key sequences, with `f1`, `function-key-1`, and `fn1` style aliases available for user keymaps and scripts.
514514
- `internal/tui`: terminal ESC parsing now recognizes charset selection sequences such as `ESC ( B`, `ESC ) 0`, `ESC * B`, `ESC / A`, and `ESC % G` as structured charset actions and consumes them in visible-text parsing instead of surfacing them as unknown terminal output.
515515
- `internal/tui`: terminal ESC parsing now also recognizes ISO-2022 charset shift controls such as `ESC N`, `ESC n`, `ESC o`, `ESC |`, `ESC }`, and `ESC ~` as structured charset-shift actions and consumes them in visible-text parsing instead of surfacing them as unknown terminal output.
516516
- `internal/contracts`/`internal/session`: image content blocks now normalize source aliases such as `mediaType`/`mimeType`/`contentType` and `base64`/`payload`, including top-level image block fields, into canonical `ImageSource` values during transcript resume.

internal/tui/input.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,24 @@ func parseFunctionKey(seq string) (Key, bool) {
259259
case "\x1b[[E":
260260
return Key{Type: KeyF5}, true
261261
}
262+
if strings.HasPrefix(seq, "\x1bO") && len(seq) >= 5 && strings.Contains(seq[2:len(seq)-1], ";") {
263+
code, ok := firstCSIParamNumber(seq[2 : len(seq)-1])
264+
if !ok || code != 1 {
265+
return Key{}, false
266+
}
267+
switch seq[len(seq)-1] {
268+
case 'P':
269+
return Key{Type: KeyF1}, true
270+
case 'Q':
271+
return Key{Type: KeyF2}, true
272+
case 'R':
273+
return Key{Type: KeyF3}, true
274+
case 'S':
275+
return Key{Type: KeyF4}, true
276+
default:
277+
return Key{}, false
278+
}
279+
}
262280
if !strings.HasPrefix(seq, "\x1b[") {
263281
return Key{}, false
264282
}

internal/tui/tui_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,10 @@ func TestParseFunctionKeySequences(t *testing.T) {
10201020
{seq: "\x1bOQ", want: KeyF2},
10211021
{seq: "\x1bOR", want: KeyF3},
10221022
{seq: "\x1bOS", want: KeyF4},
1023+
{seq: "\x1bO1;2P", want: KeyF1},
1024+
{seq: "\x1bO1;5Q", want: KeyF2},
1025+
{seq: "\x1bO1;9R", want: KeyF3},
1026+
{seq: "\x1bO1;16S", want: KeyF4},
10231027
{seq: "\x1b[[A", want: KeyF1},
10241028
{seq: "\x1b[[B", want: KeyF2},
10251029
{seq: "\x1b[[C", want: KeyF3},

0 commit comments

Comments
 (0)