[PR #7520] feat: add input_copy and input_cut keybindings for keyboard-based text selection #12425

Open
opened 2026-02-16 18:17:20 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/7520

State: open
Merged: No


Summary

Adds support for copying and cutting selected text in the OpenCode TUI input field using keyboard shortcuts, enabling fully keyboard-centric clipboard workflows.

Fixes #7516

Changes

  • Add input_copy keybinding (default: Ctrl+Insert)
  • Add input_cut keybinding (default: Shift+Delete)
  • Implement event handlers in prompt component using existing Clipboard API
  • Works with text selected via Shift+Arrow and other keyboard selection methods

Default Keybindings

The feature uses CUA-standard (Common User Access) keybindings:

  • Ctrl+Insert for copy
  • Shift+Delete for cut

Why CUA-standard?

  • Universal compatibility: Works across all terminal emulators (not intercepted like Ctrl+Shift+C/V)
  • Industry standard: From IBM/Windows/Office, familiar to many users
  • Consistent: Aligns with existing input_paste default (Shift+Insert)
  • No conflicts: Avoids terminal native shortcuts

Users can customize these via config if desired.

Implementation Details

  • Uses TextareaRenderable.hasSelection() to detect active selections
  • Uses TextareaRenderable.getSelectedText() to retrieve selected text
  • Uses TextareaRenderable.deleteChar() for cut operation (deletes selection)
  • Graceful error handling with console logging
  • Follows established patterns from input_paste and input_clear

Testing

  • Type checking passes (all packages)
  • All tests pass (622/622)
  • Manual testing: Copy and cut operations work correctly
  • Edge case: No-op when no text is selected (graceful handling)

Related

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7520 **State:** open **Merged:** No --- ## Summary Adds support for copying and cutting selected text in the OpenCode TUI input field using keyboard shortcuts, enabling fully keyboard-centric clipboard workflows. Fixes #7516 ## Changes - Add `input_copy` keybinding (default: `Ctrl+Insert`) - Add `input_cut` keybinding (default: `Shift+Delete`) - Implement event handlers in prompt component using existing `Clipboard` API - Works with text selected via `Shift+Arrow` and other keyboard selection methods ## Default Keybindings The feature uses **CUA-standard** (Common User Access) keybindings: - **`Ctrl+Insert`** for copy - **`Shift+Delete`** for cut ### Why CUA-standard? - ✅ **Universal compatibility**: Works across all terminal emulators (not intercepted like `Ctrl+Shift+C/V`) - ✅ **Industry standard**: From IBM/Windows/Office, familiar to many users - ✅ **Consistent**: Aligns with existing `input_paste` default (`Shift+Insert`) - ✅ **No conflicts**: Avoids terminal native shortcuts Users can customize these via config if desired. ## Implementation Details - Uses `TextareaRenderable.hasSelection()` to detect active selections - Uses `TextareaRenderable.getSelectedText()` to retrieve selected text - Uses `TextareaRenderable.deleteChar()` for cut operation (deletes selection) - Graceful error handling with console logging - Follows established patterns from `input_paste` and `input_clear` ## Testing - ✅ Type checking passes (all packages) - ✅ All tests pass (622/622) - ✅ Manual testing: Copy and cut operations work correctly - ✅ Edge case: No-op when no text is selected (graceful handling) ## Related - Issue: #7516 - Branch: `flexiondotorg:input_copy` - Base: `anomalyco:dev`
yindo added the pull-request label 2026-02-16 18:17:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12425