Skip to content

fix(terminal): mouse and keyboard clipboard support - #7

Open
andreas-byfut wants to merge 3 commits into
LordOfPolls:masterfrom
andreas-byfut:fix/terminal-mouse-and-clipboard
Open

andreas-byfut wants to merge 3 commits into
LordOfPolls:masterfrom
andreas-byfut:fix/terminal-mouse-and-clipboard

Conversation

@andreas-byfut

@andreas-byfut andreas-byfut commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

With a physical keyboard and mouse there was no way to paste, the wheel did nothing, and a
press-drag scrolled instead of selecting. These are three commits that build on each other:

  1. Paste and copy shortcuts: Ctrl+Shift+V and Shift+Insert paste, and Ctrl+Shift+C copies the
    selection. Plain Ctrl+C and Ctrl+V still reach the remote as control bytes. Ctrl+Shift+C with
    no selection is swallowed, as in desktop terminals.

  2. Fractional cell width: the column count came from the truncated cell width while the
    renderer draws at the fractional one. That cut off the last column, and taps, selection and
    handles drifted right across the row.

  3. Mouse: what the wheel does depends on the screen:

    • it scrolls the scrollback;
    • it sends wheel events to a mouse-tracking app;
    • it sends arrow keys on the alternate screen, like xterm's alternateScroll.

    A drag selects, a double-click selects a word, and a right-click copies the selection or
    pastes. Shift bypasses mouse tracking, as in xterm. Touch behaviour is unchanged.

Tests: ClipboardShortcutTest, TerminalCanvasTest, TerminalGesturesTest.

Known limits:

  • The first click of a double-click still runs the tap handler, so double-clicking a link opens
    the link dialog.
  • Middle-click is treated as a primary click.

…nsert and Ctrl+Shift+C

Ctrl+Shift+V and Shift+Insert paste, Ctrl+Shift+C copies the selection.
Plain Ctrl+C and Ctrl+V still reach the remote as control bytes.
…der the finger

The column count came from the truncated cell width while the renderer draws
at the fractional one, so the last column could be cut off and taps,
selection and handles drifted right across the row.
…y or paste

With a mouse the wheel did nothing and a press-drag scrolled the scrollback
instead of selecting. The wheel now scrolls the scrollback, sends wheel events
to a mouse-tracking app, or sends arrow keys on the alternate screen. A drag
selects, a double-click selects a word, and a right-click copies the selection
or pastes. Shift bypasses mouse tracking, as in xterm. Touch is unchanged.
@LordOfPolls

Copy link
Copy Markdown
Owner

Hi there, thanks for all the PRs.

As I'm sure you can appreciate, 10 PRs touching various parts of the codebase will take a bit to review.

However, before I review, please can you confirm if these were physically tested, i.e. with a device, not just the unit tests?

@andreas-byfut

andreas-byfut commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Hey, of course, take your time.

I have been using Shellwave with the fixes the last three days on a regular basis - mutliple hours with several reconnects.
Used with a tablet and physical keyboard/mouse connected via an usb-c hub.

Thanks again for this great app.
The least I could do is share something back.

@LordOfPolls

LordOfPolls commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Thanks, this works.

Minor changes please.

  • when mouse tracking is on, send right click to the the app unless Shift is held. Vim and tmux never get it right now.
  • Send mouse drags as button-drag reports while tracking is on, so tmux pane resizing and vim selection work
  • Trim the comments to ones that explain why - Theyre a touch verbose
  • This is a feat not a fix as youre adding, not fixing

@LordOfPolls LordOfPolls added enhancement New feature or request needs-revision labels Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request needs-revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants