This commit is contained in:
Kovid Goyal 2025-09-03 21:34:21 +05:30
commit 2ca7b505f4
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 13 additions and 2 deletions

View file

@ -3725,10 +3725,12 @@
to :kbd:`Ctrl+C`. It will copy only if there is a selection and send an
interrupt otherwise. Similarly, :ac:`copy_and_clear_or_interrupt` will copy
and clear the selection or send an interrupt if there is no selection.
The :ac:`copy_or_noop` action will copy if there is a selection and pass
the key through to the application if there is no selection.
'''
)
map('Copy to clipboard',
'copy_to_clipboard cmd+c copy_to_clipboard',
map('Copy to clipboard or pass through',
'copy_or_noop cmd+c copy_or_noop',
only='macos',
)

View file

@ -2142,6 +2142,15 @@ def copy_or_interrupt(self) -> None:
self.scroll_end()
self.write_to_child(self.encoded_key(KeyEvent(key=ord('c'), mods=GLFW_MOD_CONTROL)))
@ac('cp', 'Copy the selected text from the active window to the clipboard, if no selection, pass the key through to the application')
def copy_or_noop(self) -> bool:
text = self.text_for_selection()
if text:
set_clipboard_string(text)
return False
else:
return True
@ac('cp', 'Copy the selected text from the active window to the clipboard and clear selection, if no selection, send SIGINT (aka :kbd:`ctrl+c`)')
def copy_and_clear_or_interrupt(self) -> None:
self.copy_or_interrupt()