parent
6e838b83d8
commit
30cad2e0a6
@ -67,6 +67,8 @@ Detailed list of changes
|
|||||||
|
|
||||||
- A new action :ac:`scroll_prompt_to_top` to move the current prompt to the top (:pull:`4891`)
|
- A new action :ac:`scroll_prompt_to_top` to move the current prompt to the top (:pull:`4891`)
|
||||||
|
|
||||||
|
- :ac:`select_tab`: Use stable numbers when selecting the tab (:iss:`4792`)
|
||||||
|
|
||||||
|
|
||||||
0.24.4 [2022-03-03]
|
0.24.4 [2022-03-03]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|||||||
@ -2135,16 +2135,16 @@ class Boss:
|
|||||||
callback: Callable[[Union[_T, str, None]], None],
|
callback: Callable[[Union[_T, str, None]], None],
|
||||||
subtitle: str = ''
|
subtitle: str = ''
|
||||||
) -> Optional[Window]:
|
) -> Optional[Window]:
|
||||||
lines = [title, subtitle, ''] if subtitle else [title, '']
|
lines = [title, subtitle, ' '] if subtitle else [title, ' ']
|
||||||
idx_map: List[Union[_T, str]] = []
|
idx_map: List[Union[_T, str, None]] = []
|
||||||
ans: Union[str, _T, None] = None
|
ans: Union[str, _T, None] = None
|
||||||
fmt = ': {1}'
|
fmt = ': {1}'
|
||||||
|
|
||||||
for obj, text in entries:
|
for obj, text in entries:
|
||||||
|
idx_map.append(obj)
|
||||||
if obj is None:
|
if obj is None:
|
||||||
lines.append(text)
|
lines.append(text)
|
||||||
else:
|
else:
|
||||||
idx_map.append(obj)
|
|
||||||
lines.append(fmt.format(len(idx_map), text))
|
lines.append(fmt.format(len(idx_map), text))
|
||||||
|
|
||||||
def done(data: Dict[str, Any], target_window_id: int, self: Boss) -> None:
|
def done(data: Dict[str, Any], target_window_id: int, self: Boss) -> None:
|
||||||
@ -2157,7 +2157,7 @@ class Boss:
|
|||||||
q = self._run_kitten(
|
q = self._run_kitten(
|
||||||
'hints', args=(
|
'hints', args=(
|
||||||
'--ascending', '--customize-processing=::import::kitty.choose_entry',
|
'--ascending', '--customize-processing=::import::kitty.choose_entry',
|
||||||
r'--regex=(?m)^:\s+.+$', '--window-title', title,
|
'--window-title', title,
|
||||||
), input_data='\r\n'.join(lines).encode('utf-8'), custom_callback=done, action_on_removal=done2
|
), input_data='\r\n'.join(lines).encode('utf-8'), custom_callback=done, action_on_removal=done2
|
||||||
)
|
)
|
||||||
return q if isinstance(q, Window) else None
|
return q if isinstance(q, Window) else None
|
||||||
@ -2176,13 +2176,10 @@ class Boss:
|
|||||||
return f'{tab.name or tab.title} [{tab.num_window_groups} {w}]'
|
return f'{tab.name or tab.title} [{tab.num_window_groups} {w}]'
|
||||||
|
|
||||||
ct = self.active_tab
|
ct = self.active_tab
|
||||||
st = ''
|
|
||||||
if ct is not None:
|
|
||||||
st = f'Current tab: {format_tab_title(ct)}'
|
|
||||||
self.choose_entry(
|
self.choose_entry(
|
||||||
'Choose a tab to switch to',
|
'Choose a tab to switch to',
|
||||||
((t.id, format_tab_title(t)) for t in self.all_tabs if t is not ct),
|
((None, f'Current tab: {format_tab_title(t)}') if t is ct else (t.id, format_tab_title(t)) for t in self.all_tabs),
|
||||||
chosen, subtitle=st
|
chosen
|
||||||
)
|
)
|
||||||
|
|
||||||
@ac('win', '''
|
@ac('win', '''
|
||||||
|
|||||||
@ -10,7 +10,17 @@ from .typing import MarkType
|
|||||||
|
|
||||||
|
|
||||||
def mark(text: str, args: HintsCLIOptions, Mark: Type[MarkType], extra_cli_args: List[str], *a: Any) -> Generator[MarkType, None, None]:
|
def mark(text: str, args: HintsCLIOptions, Mark: Type[MarkType], extra_cli_args: List[str], *a: Any) -> Generator[MarkType, None, None]:
|
||||||
for idx, m in enumerate(re.finditer(args.regex, text)):
|
idx = 0
|
||||||
|
found_start_line = False
|
||||||
|
for m in re.finditer(r'(?m)^.+$', text):
|
||||||
start, end = m.span()
|
start, end = m.span()
|
||||||
mark_text = text[start:end].replace('\n', '').replace('\0', '')
|
line = text[start:end].replace('\0', '').replace('\n', '')
|
||||||
yield Mark(idx, start, end, mark_text, {'index': idx})
|
if line == ' ':
|
||||||
|
found_start_line = True
|
||||||
|
continue
|
||||||
|
if line.startswith(': '):
|
||||||
|
yield Mark(idx, start, end, line, {'index': idx})
|
||||||
|
idx += 1
|
||||||
|
elif found_start_line:
|
||||||
|
# skip this line incrementing the index
|
||||||
|
idx += 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user