mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 16:37:27 +00:00
Add window titles to various ask kitten invocations
This commit is contained in:
parent
321f1a6650
commit
beb18cc250
5 changed files with 28 additions and 11 deletions
|
|
@ -362,12 +362,15 @@ func GetChoices(o *Options) (response string, err error) {
|
|||
if hidden_text != "" && message != "" {
|
||||
message = message[:hidden_text_start_pos] + hidden_text + message[hidden_text_end_pos:]
|
||||
hidden_text = ""
|
||||
draw_screen()
|
||||
_ = draw_screen()
|
||||
}
|
||||
}
|
||||
|
||||
lp.OnInitialize = func() (string, error) {
|
||||
lp.SetCursorVisible(false)
|
||||
if o.Title != "" {
|
||||
lp.SetWindowTitle(o.Title)
|
||||
}
|
||||
return "", draw_screen()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,11 @@ The name for this question. Used to store history of previous answers which can
|
|||
be used for completions and via the browse history readline bindings.
|
||||
|
||||
|
||||
--title --window-title
|
||||
The title for the window in which the question is displayed. Only implemented
|
||||
for yesno and choices types.
|
||||
|
||||
|
||||
--choice -c
|
||||
type=list
|
||||
dest=choices
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ func Run(args []string) (rc int, err error) {
|
|||
}
|
||||
|
||||
lp.OnInitialize = func() (string, error) {
|
||||
lp.SetWindowTitle("kitty mouse features demo")
|
||||
lp.SetCursorVisible(false)
|
||||
draw_screen()
|
||||
return "", nil
|
||||
|
|
|
|||
|
|
@ -678,7 +678,7 @@ class Boss:
|
|||
), dim=True, italic=True)),
|
||||
partial(self.remote_cmd_permission_received, pcmd, wid, peer_id, self_window),
|
||||
'a;green:Allow request', 'p;yellow:Allow password', 'r;magenta:Deny request', 'd;red:Deny password',
|
||||
window=window, default='a', hidden_text=hidden_text
|
||||
window=window, default='a', hidden_text=hidden_text, title=_('Allow remote control?'),
|
||||
)
|
||||
if overlay_window is None:
|
||||
return False
|
||||
|
|
@ -950,7 +950,7 @@ class Boss:
|
|||
msg = _('Are you sure you want to close this window?')
|
||||
if window.has_running_program:
|
||||
msg += ' ' + _('It is running a program.')
|
||||
self.confirm(msg, self.handle_close_window_confirmation, window.id, window=window)
|
||||
self.confirm(msg, self.handle_close_window_confirmation, window.id, window=window, title=_('Close window?'))
|
||||
else:
|
||||
self.mark_window_for_close(window)
|
||||
|
||||
|
|
@ -980,6 +980,7 @@ class Boss:
|
|||
window: Optional[Window] = None, # the window associated with the confirmation
|
||||
confirm_on_cancel: bool = False, # on closing window
|
||||
confirm_on_accept: bool = True, # on pressing enter
|
||||
title: str = '' # window title
|
||||
) -> Window:
|
||||
result: bool = False
|
||||
|
||||
|
|
@ -990,9 +991,11 @@ class Boss:
|
|||
def on_popup_overlay_removal(wid: int, boss: Boss) -> None:
|
||||
callback(result, *args)
|
||||
|
||||
cmd = ['--type=yesno', '--message', msg, '--default', 'y' if confirm_on_accept else 'n']
|
||||
if title:
|
||||
cmd += ['--title', title]
|
||||
w = self.run_kitten_with_metadata(
|
||||
'ask', ['--type=yesno', '--message', msg, '--default', 'y' if confirm_on_accept else 'n'],
|
||||
window=window, custom_callback=callback_, action_on_removal=on_popup_overlay_removal,
|
||||
'ask', cmd, window=window, custom_callback=callback_, action_on_removal=on_popup_overlay_removal,
|
||||
default_data={'response': 'y' if confirm_on_cancel else 'n'})
|
||||
assert isinstance(w, Window)
|
||||
return w
|
||||
|
|
@ -1006,6 +1009,7 @@ class Boss:
|
|||
hidden_text: str = '', # text to hide in the message
|
||||
hidden_text_placeholder: str = 'HIDDEN_TEXT_PLACEHOLDER', # placeholder text to insert in to message
|
||||
unhide_key: str = 'u', # key to press to unhide hidden text
|
||||
title: str = '' # window title
|
||||
) -> Optional[Window]:
|
||||
result: str = ''
|
||||
|
||||
|
|
@ -1025,6 +1029,8 @@ class Boss:
|
|||
input_data = hidden_text
|
||||
else:
|
||||
input_data = None
|
||||
if title:
|
||||
cmd += ['--title', title]
|
||||
|
||||
def on_popup_overlay_removal(wid: int, boss: Boss) -> None:
|
||||
callback(result)
|
||||
|
|
@ -1077,7 +1083,7 @@ class Boss:
|
|||
w = self.confirm(ngettext('Are you sure you want to close this tab, it has one window running?',
|
||||
'Are you sure you want to close this tab, it has {} windows running?', num).format(num),
|
||||
self.handle_close_tab_confirmation, tab.id,
|
||||
window=tab.active_window,
|
||||
window=tab.active_window, title=_('Close tab?'),
|
||||
)
|
||||
tab.confirm_close_window_id = w.id
|
||||
|
||||
|
|
@ -1681,7 +1687,7 @@ class Boss:
|
|||
ngettext('Are you sure you want to close this OS window, it has one window running?',
|
||||
'Are you sure you want to close this OS window, it has {} windows running', num).format(num),
|
||||
self.handle_close_os_window_confirmation, os_window_id,
|
||||
window=tm.active_window,
|
||||
window=tm.active_window, title=_('Close OS window'),
|
||||
)
|
||||
tm.confirm_close_window_id = w.id
|
||||
|
||||
|
|
@ -1737,7 +1743,7 @@ class Boss:
|
|||
ngettext('Are you sure you want to quit kitty, it has one window running?',
|
||||
'Are you sure you want to quit kitty, it has {} windows running?', num).format(num),
|
||||
self.handle_quit_confirmation,
|
||||
window=tm.active_window,
|
||||
window=tm.active_window, title=_('Quit kitty?'),
|
||||
)
|
||||
self.quit_confirmation_window_id = w.id
|
||||
set_application_quit_request(CLOSE_BEING_CONFIRMED)
|
||||
|
|
|
|||
|
|
@ -950,7 +950,7 @@ class Window:
|
|||
'What would you like to do with this URL:\n' + styled(sanitize_url_for_dispay_to_user(url), fg='yellow'),
|
||||
partial(self.hyperlink_open_confirmed, url, cwd),
|
||||
'o:Open', 'c:Copy to clipboard', 'n;red:Nothing', default='o',
|
||||
window=self,
|
||||
window=self, title=_('Hyperlink activated'),
|
||||
)
|
||||
return
|
||||
get_boss().open_url(url, cwd=cwd)
|
||||
|
|
@ -1205,6 +1205,7 @@ class Window:
|
|||
'A program running in this window wants to clone it into another window.'
|
||||
' Allow it do so, once?'),
|
||||
partial(self.handle_remote_clone_confirmation, cdata), window=self,
|
||||
title=_('Allow cloning of window?'),
|
||||
)
|
||||
elif ac in ('yes', 'y', 'true'):
|
||||
self.handle_remote_clone_confirmation(cdata, True)
|
||||
|
|
@ -1475,14 +1476,15 @@ class Window:
|
|||
get_boss().choose(
|
||||
msg, partial(self.handle_dangerous_paste_confirmation, btext, sanitized),
|
||||
's;green:Sanitize and paste', 'p;red:Paste anyway', 'c;yellow:Cancel',
|
||||
window=self, default='s',
|
||||
window=self, default='s', title=_('Allow paste?'),
|
||||
)
|
||||
return
|
||||
if 'confirm-if-large' in opts.paste_actions:
|
||||
msg = ''
|
||||
if len(btext) > 16 * 1024:
|
||||
msg = _('Pasting very large amounts of text ({} bytes) can be slow.').format(len(btext))
|
||||
get_boss().confirm(msg + _(' Are you sure?'), partial(self.handle_large_paste_confirmation, btext), window=self)
|
||||
get_boss().confirm(msg + _(' Are you sure?'), partial(self.handle_large_paste_confirmation, btext), window=self, title=_(
|
||||
'Allow large paste?'))
|
||||
return
|
||||
self.paste_text(btext)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue