broadcast kitten: Allow broadcasting ctrl+c

Fixes #3956
This commit is contained in:
Kovid Goyal 2021-08-19 22:05:29 +05:30
parent 09c18f474f
commit 9a50dfc4b5
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 9 additions and 2 deletions

View File

@ -28,6 +28,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- Launch command: Allow specifying the OS window title - Launch command: Allow specifying the OS window title
- broadcast kitten: Allow broadcasting :kbd:`ctrl+c` (:pull:`3956`)
0.23.1 [2021-08-17] 0.23.1 [2021-08-17]
---------------------- ----------------------

View File

@ -31,7 +31,7 @@ class Broadcast(Handler):
self.payload['all'] = True self.payload['all'] = True
def initialize(self) -> None: def initialize(self) -> None:
self.print('Type the text to broadcast below, press', styled('Ctrl+c', fg='yellow'), 'to quit:') self.print('Type the text to broadcast below, press', styled('Ctrl+Esc', fg='yellow'), 'to quit:')
for x in self.initial_strings: for x in self.initial_strings:
self.write_broadcast_text(x) self.write_broadcast_text(x)
self.write(SAVE_CURSOR) self.write(SAVE_CURSOR)
@ -51,7 +51,9 @@ class Broadcast(Handler):
self.commit_line() self.commit_line()
def on_interrupt(self) -> None: def on_interrupt(self) -> None:
self.quit_loop(0) self.write_broadcast_text('\x03')
self.line_edit.clear()
self.commit_line()
def on_eot(self) -> None: def on_eot(self) -> None:
self.write_broadcast_text('\x04') self.write_broadcast_text('\x04')
@ -65,6 +67,9 @@ class Broadcast(Handler):
self.line_edit.clear() self.line_edit.clear()
self.write(SAVE_CURSOR) self.write(SAVE_CURSOR)
return return
if key_event.matches('ctrl+esc'):
self.quit_loop(0)
return
ek = encode_key_event(key_event) ek = encode_key_event(key_event)
ek = standard_b64encode(ek.encode('utf-8')).decode('ascii') ek = standard_b64encode(ek.encode('utf-8')).decode('ascii')