ask kitten: Esc to abort and Enter to confirm the default choice

This commit is contained in:
pagedown 2022-01-22 02:50:50 +08:00
parent 9b4d1219b8
commit 7ce11050cd
No known key found for this signature in database
GPG Key ID: E921CF18AC8FF6EB

View File

@ -241,13 +241,14 @@ class Choose(Handler):
if text in self.allowed:
self.response = text
self.quit_loop(0)
elif self.cli_opts.type == 'yesno' and text == 'q':
self.on_interrupt()
def on_key(self, key_event: KeyEventType) -> None:
if self.cli_opts.type == 'yesno':
if key_event.matches('esc'):
self.on_text('n')
self.on_interrupt()
elif key_event.matches('enter'):
self.on_text('y')
self.quit_loop(0)
def on_click(self, ev: MouseEvent) -> None:
for letter, r in self.clickable_ranges.items():