Skip to content

tui: 鼠标拖动选择文字,松开自动复制 - #90

Merged
killpanda merged 1 commit into
mainfrom
claude/project-thread-g7wyh9
Nov 6, 2026
Merged

killpanda merged 1 commit into
mainfrom
claude/project-thread-g7wyh9

Conversation

@killpanda

Copy link
Copy Markdown
Owner

Requested by jack mini · project thread

问题

TUI 启动时开启了鼠标捕获(EnableMouseCapture,为了滚轮滚动),终端因此不再自己处理鼠标选择,拖动选不中文字,也就没法复制。

修改

  • 新增 src/tui/select.rs:左键拖动在起点所在区域(对话区或输入框,弹窗时为全屏)内选中一段文字,反色显示;松开时从渲染好的帧里读回文字(中文等宽字符不会被拆成空格),通过系统剪贴板工具复制,没有工具时退回 OSC 52,并提示“已复制 N 个字符”。
  • 单击、滚轮或按键会清除选区。
  • 复制最后一条回复(Ctrl+Y)与选区复制共用 copy_text。
  • /mouse 说明与 docs/learning-rust.md 快捷键表补充:仍可按住 Shift 拖动或 /mouse 关闭捕获使用终端原生选择。

测试

  • cargo test:112 个全部通过(新增 5 个选区单测:单行、反向多行、宽字符、区域裁剪、高亮)。
  • cargo clippy --all-targets 无警告。
  • 在 tmux 里实际运行,向输入框发送 SGR 鼠标拖动事件,选区反色显示,并提示“已复制 10 个字符”。

Generated by Claude Code

Mouse capture (for wheel scrolling) keeps the terminal from selecting
text, so dragging did nothing. A left-button drag now marks a span inside
the chat or the prompt box, draws it reversed, and on release copies its
text (read back from the frame, wide characters kept whole) through the
native clipboard tool or OSC 52.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014BrrmWMes5EESLagmFZYrD
@killpanda killpanda self-assigned this Nov 6, 2026
@graphify-labs

graphify-labs Bot commented Nov 6, 2026

Copy link
Copy Markdown

Graphify reviews are paused for this workspace because nobody has used it in 7 days. A workspace owner can resume reviews from the Repositories page: https://app.graphify.com/angus-lab/repositories

@killpanda
killpanda merged commit ef6438f into main Nov 6, 2026
1 check passed
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.

2 participants