Better window title when choosing tabs/OS windows

This commit is contained in:
Kovid Goyal
2020-11-21 14:58:08 +05:30
parent 6409786f8d
commit ff96036f62
2 changed files with 13 additions and 13 deletions

View File

@@ -120,7 +120,7 @@ class Hints(Handler):
self.all_marks = all_marks
self.ignore_mark_indices: Set[int] = set()
self.args = args
self.window_title = _('Choose URL') if args.type == 'url' else _('Choose text')
self.window_title = args.window_title or (_('Choose URL') if args.type == 'url' else _('Choose text'))
self.multiple = args.multiple
self.match_suffix = self.get_match_suffix(args)
self.chosen: List[Mark] = []
@@ -634,6 +634,9 @@ on selected matches. See https://sw.kovidgoyal.net/kitty/kittens/hints.html
for details. You can also specify absolute paths to load the script from elsewhere.
--window-title
The window title for the hints window, default title is selected based on
the type of text being hinted.
'''.format(
default_regex=DEFAULT_REGEX,
line='{{line}}', path='{{path}}'

View File

@@ -1460,7 +1460,8 @@ class Boss:
target_tab.make_active()
def select_tab(self) -> None:
lines = ['Choose a tab to switch to', '']
title = 'Choose a tab to switch to'
lines = [title, '']
fmt = ': {1}'
tab_id_map: Dict[int, Optional[Union[str, int]]] = {}
current_tab = self.active_tab
@@ -1486,7 +1487,7 @@ class Boss:
self._run_kitten(
'hints', args=(
'--ascending', '--customize-processing=::import::kitty.choose_entry',
r'--regex=(?m)^:\s+.+$',
r'--regex=(?m)^:\s+.+$', '--window-title', title,
), input_data='\r\n'.join(lines).encode('utf-8'), custom_callback=done, action_on_removal=done2
)
@@ -1495,10 +1496,8 @@ class Boss:
return self._move_window_to(target_os_window_id='new')
if args[0] == 'new-tab':
return self._move_window_to(target_tab_id='new')
lines = [
'Choose a tab to move the window to',
''
]
title = 'Choose a tab to move the window to'
lines = [title, '']
fmt = ': {1}'
tab_id_map: Dict[int, Optional[Union[str, int]]] = {}
current_tab = self.active_tab
@@ -1534,7 +1533,7 @@ class Boss:
self._run_kitten(
'hints', args=(
'--ascending', '--customize-processing=::import::kitty.choose_entry',
r'--regex=(?m)^:\s+.+$',
r'--regex=(?m)^:\s+.+$', '--window-title', title,
), input_data='\r\n'.join(lines).encode('utf-8'), custom_callback=done, action_on_removal=done2
)
@@ -1542,10 +1541,8 @@ class Boss:
if not args or args[0] == 'new':
return self._move_tab_to()
lines = [
'Choose an OS window to move the tab to',
''
]
title = 'Choose an OS window to move the tab to'
lines = [title, '']
fmt = ': {1}'
os_window_id_map: Dict[int, Optional[int]] = {}
current_os_window = getattr(self.active_tab, 'os_window_id', 0)
@@ -1582,7 +1579,7 @@ class Boss:
self._run_kitten(
'hints', args=(
'--ascending', '--customize-processing=::import::kitty.choose_entry',
r'--regex=(?m)^:\s+.+$',
r'--regex=(?m)^:\s+.+$', '--window-title', title,
), input_data='\r\n'.join(lines).encode('utf-8'), custom_callback=done, action_on_removal=done2
)