Add default choices for features that use ask kitten

This commit is contained in:
pagedown 2022-01-22 03:21:59 +08:00
parent 9a119255fe
commit 88ee5e95fc
No known key found for this signature in database
GPG Key ID: E921CF18AC8FF6EB
3 changed files with 4 additions and 2 deletions

View File

@ -262,6 +262,7 @@ class Choose(Handler):
self.draw_screen()
def on_interrupt(self) -> None:
self.response = ''
self.quit_loop(1)
on_eot = on_interrupt

View File

@ -654,7 +654,7 @@ class Boss:
if window.has_running_program:
msg += ' ' + _('It is running a program.')
self._run_kitten(
'ask', ['--type=yesno', '--message', msg],
'ask', ['--type=yesno', '--default=y', '--message', msg],
window=window,
custom_callback=partial(self.handle_close_window_confirmation, window.id)
)
@ -676,7 +676,7 @@ class Boss:
window: Optional[Window] = None, confirm_on_cancel: bool = False) -> None:
def callback_(res: Dict[str, Any], x: int, boss: Boss) -> None:
callback(res.get('response') == 'y', *args)
self._run_kitten('ask', ['--type=yesno', '--message', msg],
self._run_kitten('ask', ['--type=yesno', '--default=y', '--message', msg],
window=window, custom_callback=callback_, default_data={'response': 'y' if confirm_on_cancel else 'n'})
def confirm_tab_close(self, tab: Tab) -> None:

View File

@ -653,6 +653,7 @@ class Window:
'What would you like to do with this URL:\n') +
styled(unquote(url), fg='yellow'),
'--choice=o:Open', '--choice=c:Copy to clipboard', '--choice=n;red:Nothing'
'--default=o'
],
window=self,
custom_callback=partial(self.hyperlink_open_confirmed, url, cwd),