docs(terminal): mark P1 done in roadmap + document stty control bytes
Ctrl-C/Ctrl-Z/Ctrl-\ reach the PTY as 0x03/0x1a/0x1c and are then interpreted by bash's stty (SIGINT/SIGTSTP/SIGQUIT), which is real-terminal behavior and preserved on purpose per user confirmation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,8 @@
|
|||||||
| `clear`(含 `ESC[3J` 清 scrollback) | `core.rs::contains_erase_scrollback` |
|
| `clear`(含 `ESC[3J` 清 scrollback) | `core.rs::contains_erase_scrollback` |
|
||||||
| alt-screen 滚轮 → 方向键翻页 | `component.rs::handle_wheel` |
|
| alt-screen 滚轮 → 方向键翻页 | `component.rs::handle_wheel` |
|
||||||
| 基础按键:Ctrl-C/D/L、方向键、Enter/Tab/Esc/Backspace | `component.rs::map_key_to_terminal_input` |
|
| 基础按键:Ctrl-C/D/L、方向键、Enter/Tab/Esc/Backspace | `component.rs::map_key_to_terminal_input` |
|
||||||
|
| 完整键表(F1–F12/Home/End/PageUp/Down/Ctrl A–Z/Alt-key) | `component.rs::key_to_bytes` |
|
||||||
|
| application-cursor 模式(DECCKM,方向键切 SS3) | `component.rs::cursor_seq` + `TerminalCore::application_cursor` |
|
||||||
| 粘贴(Ctrl-V / 浏览器菜单,含 bracketed paste) | `component.rs::handle_paste` / `prepare_paste` |
|
| 粘贴(Ctrl-V / 浏览器菜单,含 bracketed paste) | `component.rs::handle_paste` / `prepare_paste` |
|
||||||
| 文本选区 + 复制(自建模型,Ctrl-Shift-C,跨滚动) | `component.rs` 鼠标处理 / `core.rs::selection_text` |
|
| 文本选区 + 复制(自建模型,Ctrl-Shift-C,跨滚动) | `component.rs` 鼠标处理 / `core.rs::selection_text` |
|
||||||
|
|
||||||
@@ -58,22 +60,25 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### P1 — 完整功能键 + application-cursor 模式
|
### P1 — 完整功能键 + application-cursor 模式 ✅ 已完成
|
||||||
|
|
||||||
**现状**:只映射了方向键、Ctrl-C/D/L、Enter/Tab/Esc/Backspace。缺 F1–F12、Home/End/Insert/Delete、PageUp/PageDown、大量 Ctrl/Alt 组合。
|
**现状**:完整键表已实现并验证通过(`key_to_bytes_table` 单测覆盖)。
|
||||||
|
|
||||||
**计划实现**:
|
**已实现**:
|
||||||
1. 扩展 `map_key_to_terminal_input`,补齐:
|
1. **完整键表**(`component.rs::key_to_bytes`)
|
||||||
- `F1`–`F12` → `ESC O P/Q/R/S`(F1–4)、`ESC[15~`…(F5–12)
|
- F1–F4 SS3(`ESC O P/Q/R/S`)、F5–F12 CSI `~`(含 xterm 真实的 16/22 跳号)。
|
||||||
- `Home`/`End` → `ESC[H` / `ESC[F`(或 `ESC[1~` / `ESC[4~`)
|
- Home/End、Insert/Delete、PageUp/PageDown、Enter/Tab/Esc/Backspace。
|
||||||
- `Insert`/`Delete` → `ESC[2~` / `ESC[3~`
|
- Ctrl A..Z → 0x01..0x1a;以及 `@[\\]^_` 变体(→ 0x00/0x1b/0x1c/0x1d/0x1e/0x1f)。
|
||||||
- `PageUp`/`PageDown` → `ESC[5~` / `ESC[6~`
|
- Alt+char → `ESC char`(标准 meta-as-ESC 编码)。
|
||||||
- `Ctrl+A..Z` → 控制字符 `0x01..0x1A`(通用化,不再只 C/D/L)
|
2. **application-cursor 模式(DECCKM)**:`cursor_seq(byte, app_cursor)` 助手;为真时方向键 / Home / End 发 SS3(`ESC O X`),否则 CSI(`ESC [ X`)。`handle_keydown` 和 `handle_wheel` 都据此切换。
|
||||||
- `Alt+<key>` → 前缀 `ESC` + 字符
|
3. **测试**:`key_to_bytes_table` 单测覆盖整套键表,17 个 terminal 测试全过、clippy 干净。
|
||||||
2. **application-cursor 模式**:vt100 暴露 `screen().application_cursor()`。为真时,方向键要发 **SS3 形式 `ESC O A/B/C/D`** 而非 `ESC [ A/B/C/D`。`handle_keydown` 和 `handle_wheel`(alt-screen 滚轮翻页)都要据此切换序列。
|
|
||||||
- 这能修掉「某些 vim 配置 / 全屏程序里方向键行为怪异」的潜在问题。
|
|
||||||
|
|
||||||
**风险**:低。纯查表扩展 + 一个模式判断。建议把按键表抽成数据驱动并加单元测试覆盖。
|
**有意保留的"看起来像 bug"行为**(与真终端/xterm 一致):
|
||||||
|
- `Ctrl-C` (0x03) → SIGINT 中断前台进程
|
||||||
|
- `Ctrl-Z` (0x1a) → SIGTSTP 暂停前台进程(shell 提示符立刻返回)
|
||||||
|
- `Ctrl-\` (0x1c) → SIGQUIT 杀掉前台进程(shell 提示符返回)
|
||||||
|
|
||||||
|
这些是 bash 等的 `stty` 默认行为(intr/quit/susp),由内核 tty 纪律触发,与 xterm/SSH 进真终端一样——不是本组件 bug,也按用户确认保留。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user