Skip to content

Commit 686e48b

Browse files
committed
broadcast kitten: Allow broadcasting ctrl+c
Fixes kovidgoyal#3956
1 parent 2e03dcc commit 686e48b

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
2828

2929
- Launch command: Allow specifying the OS window title
3030

31+
- broadcast kitten: Allow broadcasting :kbd:`ctrl+c` (:pull:`3956`)
32+
3133

3234
0.23.1 [2021-08-17]
3335
----------------------

kittens/broadcast/main.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(self, opts: BroadcastCLIOptions, initial_strings: List[str]) -> Non
3131
self.payload['all'] = True
3232

3333
def initialize(self) -> None:
34-
self.print('Type the text to broadcast below, press', styled('Ctrl+c', fg='yellow'), 'to quit:')
34+
self.print('Type the text to broadcast below, press', styled('Ctrl+Esc', fg='yellow'), 'to quit:')
3535
for x in self.initial_strings:
3636
self.write_broadcast_text(x)
3737
self.write(SAVE_CURSOR)
@@ -51,7 +51,9 @@ def on_text(self, text: str, in_bracketed_paste: bool = False) -> None:
5151
self.commit_line()
5252

5353
def on_interrupt(self) -> None:
54-
self.quit_loop(0)
54+
self.write_broadcast_text('\x03')
55+
self.line_edit.clear()
56+
self.commit_line()
5557

5658
def on_eot(self) -> None:
5759
self.write_broadcast_text('\x04')
@@ -65,6 +67,9 @@ def on_key(self, key_event: KeyEventType) -> None:
6567
self.line_edit.clear()
6668
self.write(SAVE_CURSOR)
6769
return
70+
if key_event.matches('ctrl+esc'):
71+
self.quit_loop(0)
72+
return
6873

6974
ek = encode_key_event(key_event)
7075
ek = standard_b64encode(ek.encode('utf-8')).decode('ascii')

0 commit comments

Comments
 (0)