Skip to content

feat(screenshot): add Ctrl+C shortcut to copy w/o saving - #3645

Merged
bbedward merged 2 commits into
duxlabs-dev:masterfrom
hthienloc:feat/screenshot-copy-shortcut
Oct 2, 2026
Merged

bbedward merged 2 commits into
duxlabs-dev:masterfrom
hthienloc:feat/screenshot-copy-shortcut

Conversation

@hthienloc

Copy link
Copy Markdown
Member

What

  • Adds Ctrl+C shortcut in interactive region screenshot mode (dms screenshot region):

    • Copies the selected area directly to the system clipboard and immediately exits without saving a file.
    • Works on hovered snap targets (window / popout), during mid-drag, or on an already drawn selection.
    • Emits status: "aborted" in --json mode so external callers (such as annotation plugins) exit cleanly without launching an editor.
    • If no selection is made, cancels and exits cleanly (like Esc).
  • Suppresses the 4 corner resize handles and maintains the crosshair cursor while dragging with Ctrl held.

  • Displays Ctrl+C copy in the region HUD hint list.

Why

Related to #1528. Previously, screenshots could not be copied on the fly without saving when default or caller flags enabled file saving.

Sidenote

I didn't add Ctrl+S here since I still can't figure out how to handle the case where a user specifies a directory and presses Ctrl+S. Should it save to the default directory or the specified directory?

So I just limited the scope to Ctrl+C here.

Add Ctrl+C shortcut in interactive region selection mode to immediately
copy the current selection (or hovered snap target) to clipboard without
saving to a file.

- Works during mid-drag, on hovered targets, or on existing selections
- Bypasses file saving and forces clipboard output
- Emits aborted status in JSON mode so external callers (such as Quick
  Capture) exit cleanly without launching an annotation editor
- Exits cleanly without error if triggered with no selection
- Updates HUD items with Ctrl+C copy shortcut
- Hides corner resize handles and maintains crosshair cursor while dragging with Ctrl held
@hthienloc

Copy link
Copy Markdown
Member Author

/claude review

}
}

if result.CopyOnly {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With --stdout, Ctrl+C never reaches the clipboard: the config.Stdout branch right below writes the image to stdout and returns before config.Clipboard is checked. The user presses Ctrl+C and nothing is copied. Clear Stdout here too.

Suggested change
if result.CopyOnly {
if result.CopyOnly {
config.SaveFile = false
config.Stdout = false

r.selection.dragging = false
r.movingSelection = false
r.resizingHandle = handleNone
r.copyOnly = true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In scroll mode, finishSelection() doesn't capture anything. It calls enterScrollPhase and returns, so Ctrl+C during scroll-mode selection just starts scrolling. copyOnly stays true, though, so a later plain Enter/"done" in the scroll phase also skips saving and reports aborted. Either skip copyOnly when r.screenshoter.config.Mode == ModeScroll in this branch, or reset r.copyOnly = false in enterScrollPhase. The same applies to the two snap-target branches above.

@claude

claude Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Claude review

Overall the change works. Two edge cases leave Ctrl+C in a wrong state.

  • With --stdout, Ctrl+C sends the image to stdout and nothing is copied, core/cmd/dms/commands_screenshot.go:381
  • In scroll mode, Ctrl+C starts scrolling instead of copying, and the copy-only flag stays on, so a later Enter doesn't save either, core/internal/screenshot/region_input.go:783
    Checked: Ctrl+C key handling in the select and scroll phases, snap-target/drag/selection paths, the cursor and resize-handle changes, and the CopyOnly output path (JSON, notify, geometry, stdout). Model: claude-opus-5-5.

- Disable stdout output when copyOnly is active to ensure the image
  is copied to the clipboard instead of being written to stdout.
- Write 'Copied to clipboard' to stderr if --stdout was originally passed.
- Bypass entering scrollPhase in finishSelection() if copyOnly is set,
  immediately capturing and copying the selected region.
@hthienloc

Copy link
Copy Markdown
Member Author

/claude review

@claude

claude Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Claude review

No issues found. Both earlier findings are fixed: copy-only now clears Stdout, and finishSelection skips the scroll phase when copyOnly is set.
Checked: Ctrl+C handling in the select and scroll phases (snap target, mid-drag, existing selection, no selection), the copy-only output path (stdout, clipboard message, JSON, notify, geometry), and the cursor and resize-handle changes while dragging. Model: claude-opus-5-5.

@bbedward
bbedward merged commit 5318c43 into duxlabs-dev:master Oct 2, 2026
3 checks passed
@bbedward bbedward mentioned this pull request Oct 28, 2026
2 of 6 tasks
@hthienloc
hthienloc deleted the feat/screenshot-copy-shortcut branch November 15, 2026 15:38
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