Skip to content

feat(tui-v3): v2-style arrow navigation with logical line boundaries#520

Merged
lsdefine merged 2 commits into
lsdefine:mainfrom
jlu005807:feat/arrow-nav-logical-line
May 28, 2026
Merged

feat(tui-v3): v2-style arrow navigation with logical line boundaries#520
lsdefine merged 2 commits into
lsdefine:mainfrom
jlu005807:feat/arrow-nav-logical-line

Conversation

@jlu005807
Copy link
Copy Markdown
Contributor

@jlu005807 jlu005807 commented May 28, 2026

新增 _logical_visual_range() (L2556-2564)

计算指定逻辑行在视觉行列表 segs 中的起止索引范围,用于判断光标是否在视觉首行/末行。

上键 ↑ 新逻辑

多行(buf中有\n) 且 在视觉首行?
├─ 第0行且已在行首 → _nav_hist(-1) 翻历史
├─ 第0行但不在行首 → pos=行首 跳行首
├─ 非第0行且已在行首 → _cur_v(-1) 正常上移(到上一行)
└─ 非第0行但不在行首 → pos=行首 跳该行行首

  • 多行 且 不在视觉首行 → _cur_v(-1) 视觉行上移
  • 单行(无\n) → _cur_v(-1) 保持原行为

下键 ↓ 新逻辑

多行(buf中有\n) 且 在视觉末行?
├─ 末行且已在行末 → _nav_hist(1) 翻历史
├─ 末行但不在行末 → pos=行末 跳行末
├─ 非末行且已在行末 → _cur_v(1) 正常下移(到下一行)
└─ 非末行但不在行末 → pos=行末 跳该行行末

  • 多行 且 不在视觉末行 → _cur_v(1) 视觉行下移
  • 单行(无\n) → _cur_v(1) 保持原行为
场景 效果 效果
单行(长文本 wrap) 视觉行上移 视觉行下移
多行 · 视觉首行 跳行首 / 翻历史 视觉行下移
多行 · 视觉末行 视觉行上移 跳行末 / 翻历史
多行 · 视觉中间行 视觉行上移 视觉行下移
调色板可见时 上移选中项 下移选中项
pending 消息 + 空输入 弹回消息

兼容性

• ✅ 不影响其他快捷键(←→/Ctrl+U/Ctrl+A/Home/End 等)
• ✅ 不影响命令补全调色板
• ✅ 不影响 pending 消息弹回
• ✅ 不新增外部依赖

@jlu005807 jlu005807 force-pushed the feat/arrow-nav-logical-line branch from 2572ee9 to 133c2fe Compare May 28, 2026 05:14
@shenhao-stu
Copy link
Copy Markdown
Contributor

good!

@lsdefine lsdefine merged commit 3a9e90b into lsdefine:main May 28, 2026
nianyucatfish added a commit to nianyucatfish/GenericAgent that referenced this pull request May 28, 2026
- _ptk_keypress_to_bytes 在 Windows 上对 Enter 收到 \r 时用
  GetAsyncKeyState(VK_SHIFT) 物理检测 Shift,按下时返回 \n 以触发换行
  (PTK 在某些 Windows 终端区分不出 Shift+Enter 与裸 Enter)。
- 新增 _line_region / _logical_visual_range 辅助函数,↑/↓ 按键:
  不在该逻辑行的视觉首/末行 → 视觉滚行;在视觉首行且光标在行首 →
  历史导航,否则先跳逻辑行首/尾,下次按键再跨行/进历史。多行粘贴
  内部导航更符合直觉。

Refs:
- Shift+Enter 物理检测 from upstream PR lsdefine#519 by @jlu005807
  lsdefine#519
- 多行输入逻辑行边界导航思路 from upstream PR lsdefine#520 by @jlu005807
  lsdefine#520
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants