Move toggle_tab into Boss

actions arent supported on TabManager
This commit is contained in:
Kovid Goyal 2024-03-07 11:57:07 +05:30
parent 76a4840a0f
commit d33afd4e96
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 16 additions and 11 deletions

View file

@ -2930,3 +2930,19 @@ def sanitize_url_for_dispay_to_user(self, url: str) -> str:
def on_system_color_scheme_change(self, appearance: int) -> None:
log_error('system color theme changed:', appearance)
@ac('win', '''
Toggle to the tab matching the specified expression
Switches to the matching tab if another tab is current, otherwise
switches to the last used tab. Useful to easily switch to and back from a
tab using a single shortcut. Note that toggling works only between
tabs in the same OS window. See :ref:`search_syntax` for details
on the match expression. For example::
map f1 toggle_tab title:mytab
''')
def toggle_tab(self, match_expression: str) -> None:
tm = self.active_tab_manager
if tm is not None:
tm.toggle_tab(match_expression)

View file

@ -990,17 +990,6 @@ def next_tab(self, delta: int = 1) -> None:
if len(self.tabs) > 1:
self.set_active_tab_idx((self.active_tab_idx + len(self.tabs) + delta) % len(self.tabs))
@ac('win', '''
Toggle to the tab matching the specified expression
Switches to the matching tab if another tab is current, otherwise
switches to the last used tab. Useful to easily switch to and back from a
tab using a single shortcut. Note that toggling works only between
tabs in the same OS window. See :ref:`search_syntax` for details
on the match expression. For example::
map f1 toggle_tab title:mytab
''')
def toggle_tab(self, match_expression: str) -> None:
tabs = set(get_boss().match_tabs(match_expression)) & set(self)
if not tabs: