Skip to content

feat: add mouse selection and copy/paste to embedded terminal#374

Merged
Wirasm merged 2 commits into
mainfrom
kild/313-mouse-selection
Feb 11, 2026
Merged

feat: add mouse selection and copy/paste to embedded terminal#374
Wirasm merged 2 commits into
mainfrom
kild/313-mouse-selection

Conversation

@Wirasm

@Wirasm Wirasm commented Feb 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Wire GPUI mouse events (MouseDown, MouseMove) to alacritty_terminal's Selection API for click-drag text selection
  • Render selection as semi-transparent ice-colored highlight quads between cell backgrounds and text
  • Cmd+C copies selection to clipboard, sends SIGINT (0x03) when no selection active
  • Cmd+V pastes clipboard contents to PTY stdin
  • Support single-click (simple), double-click (word), and triple-click (line) selection

Closes #313

Test plan

  • Click-drag selects text with visual highlight
  • Double-click selects word, triple-click selects line
  • Cmd+C with selection copies to clipboard (verify paste in another app)
  • Cmd+C without selection sends SIGINT (Ctrl+C behavior preserved)
  • Cmd+V pastes clipboard content into terminal
  • Click clears existing selection
  • Selection renders behind text (text remains readable)

Wire GPUI mouse events to alacritty_terminal's Selection API for
click-drag text selection with visual highlight. Cmd+C copies selection
to clipboard (falls back to SIGINT with no selection), Cmd+V pastes
clipboard to PTY. Supports single-click, double-click (word), and
triple-click (line) selection.
@Wirasm

Wirasm commented Feb 11, 2026

Copy link
Copy Markdown
Owner Author

PR Review Summary

Critical Issues (0 found)

None.

Important Issues (3 found — all addressed)

Agent Issue Location Status
comment-analyzer Mouse down handler comment says "clears selection" but code always creates new terminal_element.rs:677 Fixed
comment-analyzer Cmd+C comment missing selection-clearing behavior terminal_view.rs:80 Fixed
code-reviewer pixel_to_grid missing bounds clamping before as i32/as usize casts terminal_element.rs:110 Fixed

Suggestions (4 found — triaged, not actioned)

Agent Suggestion Location Decision
silent-failure-hunter PTY write failures (Cmd+C/V) have no user-visible feedback terminal_view.rs:87-99 Skip — already logged with tracing::error; batch loop catches dead PTY and sets error_state
silent-failure-hunter write_to_clipboard has no error path, selection cleared regardless terminal_view.rs:84 Skip — GPUI API is infallible by design
silent-failure-hunter Selection rendering silently clamps out-of-bounds lines terminal_element.rs:451-475 Skip — defensive clamping is correct; debug logging for alacritty internals is over-engineering
comment-analyzer pixel_to_grid doc comment could explain Side calculation terminal_element.rs:95 Added clamping note; Side logic is self-evident from code

Strengths

  • Clean layered rendering architecture (Layers 1–5) with selection fitting naturally at 2.5
  • Proper structured logging following project conventions (ui.terminal.*)
  • Smart Cmd+C dual behavior (copy vs SIGINT) matches native terminal UX
  • Selection types (simple/word/line via click count) are clean and correct

Verdict

READY TO MERGE after pushing the 3 fixes above.

- Surface PTY write failures to user via error banner (Cmd+C/Cmd+V)
- Add bounds clamping in pixel_to_grid to prevent overflow on cast
- Add debug logging when selection coordinates are clamped
- Fix inaccurate comments (mouse down handler, Cmd+C behavior)
@Wirasm Wirasm merged commit 73ed8bc into main Feb 11, 2026
6 checks 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.

kild-ui: mouse selection and copy/paste for embedded terminals

1 participant