clipboard kitten: Add a --wait-for-completion option to have the kitten wait till copying to clipboard is complete
Fixes #1693
This commit is contained in:
parent
5db1a07f81
commit
8ebad06e7e
@ -25,6 +25,10 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
||||
- icat kitten: Fix a regression that broke passing directories to icat
|
||||
(:iss:`1683`)
|
||||
|
||||
- clipboard kitten: Add a :opt:`kitty +kitten clipboard --wait-for-completion`
|
||||
option to have the kitten wait till copying to clipboard is complete
|
||||
(:iss:`1693`)
|
||||
|
||||
- Linux: Disable the Wayland backend on GNOME by default as GNOME has no
|
||||
support for server side decorations. Can be controlled by
|
||||
:opt:`linux_display_server`.
|
||||
|
||||
@ -22,6 +22,12 @@ class Clipboard(Handler):
|
||||
if self.data_to_send is not None:
|
||||
self.cmd.write_to_clipboard(self.data_to_send, self.args.use_primary)
|
||||
if not self.args.get_clipboard:
|
||||
if self.args.wait_for_completion:
|
||||
# ask kitty for the TN terminfo capability and
|
||||
# only quit after a response is received
|
||||
self.print('\x1bP+q544e\x1b\\', end='')
|
||||
self.print('Waiting for completion...')
|
||||
return
|
||||
self.quit_loop(0)
|
||||
return
|
||||
self.cmd.request_from_clipboard(self.args.use_primary)
|
||||
@ -30,6 +36,15 @@ class Clipboard(Handler):
|
||||
self.clipboard_contents = text
|
||||
self.quit_loop(0)
|
||||
|
||||
def on_capability_response(self, name, val):
|
||||
self.quit_loop(0)
|
||||
|
||||
def on_interrupt(self):
|
||||
self.quit_loop(1)
|
||||
|
||||
def on_eot(self):
|
||||
self.quit_loop(1)
|
||||
|
||||
|
||||
OPTIONS = r'''
|
||||
--get-clipboard
|
||||
@ -45,6 +60,13 @@ default=False
|
||||
type=bool-set
|
||||
Use the primary selection rather than the clipboard on systems that support it,
|
||||
such as X11.
|
||||
|
||||
|
||||
--wait-for-completion
|
||||
default=False
|
||||
type=bool-set
|
||||
Wait till the copy to clipboard is complete before exiting. Useful if running
|
||||
the kitten in a dedicated, ephemeral window.
|
||||
'''.format
|
||||
help_text = '''\
|
||||
Read or write to the system clipboard.
|
||||
@ -54,6 +76,7 @@ To set the clipboard text, pipe in the new text on stdin. Use the
|
||||
:file:`stdout`. Note that you must enable reading of clipboard in
|
||||
:file:`kitty.conf` first.
|
||||
'''
|
||||
|
||||
usage = ''
|
||||
|
||||
|
||||
|
||||
@ -84,6 +84,9 @@ class Handler:
|
||||
def on_clipboard_response(self, text, from_primary=False):
|
||||
pass
|
||||
|
||||
def on_capability_response(self, name, val):
|
||||
pass
|
||||
|
||||
def write(self, data):
|
||||
if isinstance(data, str):
|
||||
data = data.encode('utf-8')
|
||||
|
||||
@ -214,9 +214,20 @@ class Loop:
|
||||
self.handler.on_text(chunk, self.in_bracketed_paste)
|
||||
|
||||
def _on_dcs(self, dcs):
|
||||
debug(dcs)
|
||||
if dcs.startswith('@kitty-cmd'):
|
||||
import json
|
||||
self.handler.on_kitty_cmd_response(json.loads(dcs[len('@kitty-cmd'):]))
|
||||
elif dcs.startswith('1+r'):
|
||||
from binascii import unhexlify
|
||||
vals = dcs[3:].split(';')
|
||||
for q in vals:
|
||||
parts = q.split('=', 1)
|
||||
try:
|
||||
name, val = parts[0], unhexlify(parts[1]).decode('utf-8', 'replace')
|
||||
except Exception:
|
||||
continue
|
||||
self.handler.on_capability_response(name, val)
|
||||
|
||||
def _on_csi(self, csi):
|
||||
q = csi[-1]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user