Skip to content

feat(gui): copy and paste with ctrl+c and ctrl+v in the terminal - #132

Closed
nikox96 wants to merge 2 commits into
timhartmann7:mainfrom
nikox96:feat/ctrl-c-v
Closed

nikox96 wants to merge 2 commits into
timhartmann7:mainfrom
nikox96:feat/ctrl-c-v

Conversation

@nikox96

@nikox96 nikox96 commented Sep 30, 2026

Copy link
Copy Markdown

Summary

In the desktop terminal on Windows and Linux, copying needed Ctrl+Shift+C or the webview's right-click menu. This makes the plain keys work, as in Windows Terminal:

  • Ctrl+C with a selection copies it and clears the selection. With nothing selected it still sends ^C, so a second Ctrl+C interrupts.
  • Ctrl+V pastes. xterm skips the key and the webview's native paste lands in xterm's textarea, the same path Ctrl+Shift+V already took. Bracketed paste and the 8 KB terminal_write chunking are unchanged, and no clipboard plugin or new capability is needed.
  • A Terminal setting ("Copy and paste with Ctrl+C / Ctrl+V"), on by default, turns both off and sends ^C and ^V to the remote again, for vim's visual-block mode and readline's quoted-insert. It persists like the other UI prefs (tauri-plugin-store + localStorage mirror). The row is hidden on macOS.
  • Ctrl+Shift+C and Ctrl+Shift+V work either way. macOS is unchanged (Cmd+C/V).
  • WebKitGTK under a non-Latin layout (keyCode 0) gets no native paste, so a bare Ctrl+V there goes through the existing terminal_paste command, like Ctrl+Shift+V already does.

The TUI is untouched: there, copy and paste belong to the host terminal, whose paste already arrives as bracketed paste.

Changes

  • ui/src/lib/screens/terminalInput.ts: isBareCopy / isBarePaste next to isCopyShortcut, sharing one chord matcher (same keydown, IME and non-Latin rules).
  • ui/src/lib/screens/TerminalView.svelte: handle the bare chords in the custom key handler when the pref is on.
  • ui/src/lib/stores/terminalClipboard.ts: the new pref, shaped like streamer.ts; hydrated in +layout.svelte.
  • ui/src/lib/screens/Settings.svelte: the Terminal switch.
  • CHANGELOG.md: entry under ## Unreleased.

Test plan

  • npm run check: 0 errors, 0 warnings
  • npm test: the new terminalInput and terminalClipboard suites pass. select.test.ts fails on Windows before and after this change (path separators), unrelated.
  • npx playwright test e2e/terminal.spec.ts --workers=1: the new and updated clipboard tests pass. The existing "host-first … then close" test fails locally on main too, unrelated.
  • Manual check with cargo tauri dev: select + Ctrl+C copies; Ctrl+C with no selection interrupts sleep; Ctrl+V pastes in bash and in vim; with the setting off, Ctrl+V enters visual-block in vim.

Nicolò Rossi added 2 commits October 1, 2026 14:02
On Windows and Linux a bare Ctrl+C now copies the selection and clears
it, and stays ^C when nothing is selected. Ctrl+V pastes through the
webview's native paste, so bracketed paste and chunking still apply.
A Terminal setting, on by default, turns both off to send ^C and ^V
to the remote again. Ctrl+Shift+C/V are unchanged and macOS is untouched.
@timhartmann7

Copy link
Copy Markdown
Owner

Thanks for the PR, the code is clean. We're keeping plain Ctrl+C and Ctrl+V for the shell, since vim, nano, emacs and readline rely on them, and Ctrl+Shift+C/V (or Ctrl+Insert/Shift+Insert) already copy and paste, so I'm closing this one.

@danstis

danstis commented Oct 16, 2026 •

Copy link
Copy Markdown

Thanks for the PR, the code is clean. We're keeping plain Ctrl+C and Ctrl+V for the shell, since vim, nano, emacs and readline rely on them, and Ctrl+Shift+C/V (or Ctrl+Insert/Shift+Insert) already copy and paste, so I'm closing this one.

@timhartmann7 If the code is clean, could this function be hidden behind an option that defaults to off?
In my case I normally end up going back to Windows terminal on windows due to the simple copy/paste nature of the terminal, so would love to see this, but understand that many people would not. If it was an option that could be enabled, I believe it would be the best of both worlds.

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