diff --git a/docs/changelog.rst b/docs/changelog.rst index 67d10a091..2f56a7752 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -67,6 +67,9 @@ To update |kitty|, :doc:`follow the instructions `. use the family name as the full face name of the regular font not working (:iss:`3861`) +- clipboard kitten: fix copies to clipboard not working without the + :option:`kitty +kitten clipboard --wait-for-completion` option + 0.21.2 [2021-06-28] ---------------------- diff --git a/kittens/clipboard/main.py b/kittens/clipboard/main.py index 57dc2db66..d34d60522 100644 --- a/kittens/clipboard/main.py +++ b/kittens/clipboard/main.py @@ -19,6 +19,7 @@ class Clipboard(Handler): self.args = args self.clipboard_contents: Optional[str] = None self.data_to_send = data_to_send + self.quit_on_write = False def initialize(self) -> None: if self.data_to_send is not None: @@ -30,10 +31,14 @@ class Clipboard(Handler): self.print('\x1bP+q544e\x1b\\', end='') self.print('Waiting for completion...') return - self.quit_loop(0) + self.quit_on_write = True return self.cmd.request_from_clipboard(self.args.use_primary) + def on_writing_finished(self) -> None: + if self.quit_on_write: + self.quit_loop(0) + def on_clipboard_response(self, text: str, from_primary: bool = False) -> None: self.clipboard_contents = text self.quit_loop(0) diff --git a/kittens/tui/handler.py b/kittens/tui/handler.py index 12ebc5dbb..b3794e804 100644 --- a/kittens/tui/handler.py +++ b/kittens/tui/handler.py @@ -107,6 +107,9 @@ class Handler: def on_eot(self) -> None: pass + def on_writing_finished(self) -> None: + pass + def on_kitty_cmd_response(self, response: Dict) -> None: pass diff --git a/kittens/tui/loop.py b/kittens/tui/loop.py index 392c2b94b..524c9cb8d 100644 --- a/kittens/tui/loop.py +++ b/kittens/tui/loop.py @@ -343,6 +343,7 @@ class Loop: self.write_buf: List[bytes] = [] self.asycio_loop.remove_writer(fd) self.waiting_for_writes = False + handler.on_writing_finished() else: consumed = 0 for i, buf in enumerate(self.write_buf):