diff --git a/docs/changelog.rst b/docs/changelog.rst index ec382c0b6..a38845079 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -120,6 +120,8 @@ Detailed list of changes - Fix getting last command output not working correctly when the screen is scrolled (:pull:`4522`) +- Show number of windows per tab in the :ac:`select_tab` action (:pull:`4523`) + 0.24.1 [2022-01-06] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/boss.py b/kitty/boss.py index 8e152aaf1..04a736cbd 100755 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -2076,9 +2076,10 @@ class Boss: def choose_entry( self, title: str, entries: Iterable[Tuple[Union[_T, str, None], str]], - callback: Callable[[Union[_T, str, None]], None] + callback: Callable[[Union[_T, str, None]], None], + subtitle: str = '' ) -> Optional[Window]: - lines = [title, ''] + lines = [title, subtitle, ''] idx_map: List[Union[_T, str]] = [] ans: Union[str, _T, None] = None fmt = ': {1}' @@ -2114,8 +2115,19 @@ class Boss: if tab.id == ans: self.set_active_tab(tab) + def format_tab_title(tab: Tab) -> str: + w = 'windows' if tab.num_window_groups > 1 else 'window' + return f'{tab.title} [{tab.num_window_groups} {w}]' + ct = self.active_tab - self.choose_entry('Choose a tab to switch to', ((t.id, t.title) for t in self.all_tabs if t is not ct), chosen) + st = '' + if ct is not None: + st = f'Current tab: {format_tab_title(ct)}' + self.choose_entry( + 'Choose a tab to switch to', + ((t.id, format_tab_title(t)) for t in self.all_tabs if t is not ct), + chosen, subtitle=st + ) @ac('win', ''' Detach a window, moving it to another tab or OS Window