mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
@@ -124,7 +124,10 @@ class Boss:
|
|||||||
}
|
}
|
||||||
|
|
||||||
def match_windows(self, match):
|
def match_windows(self, match):
|
||||||
|
try:
|
||||||
field, exp = match.split(':', 1)
|
field, exp = match.split(':', 1)
|
||||||
|
except ValueError:
|
||||||
|
return
|
||||||
pat = re.compile(exp)
|
pat = re.compile(exp)
|
||||||
for tm in self.os_window_map.values():
|
for tm in self.os_window_map.values():
|
||||||
for tab in tm:
|
for tab in tm:
|
||||||
@@ -140,7 +143,10 @@ class Boss:
|
|||||||
return tab
|
return tab
|
||||||
|
|
||||||
def match_tabs(self, match):
|
def match_tabs(self, match):
|
||||||
|
try:
|
||||||
field, exp = match.split(':', 1)
|
field, exp = match.split(':', 1)
|
||||||
|
except ValueError:
|
||||||
|
return
|
||||||
pat = re.compile(exp)
|
pat = re.compile(exp)
|
||||||
tms = tuple(self.os_window_map.values())
|
tms = tuple(self.os_window_map.values())
|
||||||
found = False
|
found = False
|
||||||
@@ -516,6 +522,11 @@ class Boss:
|
|||||||
if tm is not None:
|
if tm is not None:
|
||||||
tm.goto_tab(tab_num - 1)
|
tm.goto_tab(tab_num - 1)
|
||||||
|
|
||||||
|
def set_active_tab(self, tab):
|
||||||
|
tm = self.active_tab_manager
|
||||||
|
if tm is not None:
|
||||||
|
tm.set_active_tab(tab)
|
||||||
|
|
||||||
def next_tab(self):
|
def next_tab(self):
|
||||||
tm = self.active_tab_manager
|
tm = self.active_tab_manager
|
||||||
if tm is not None:
|
if tm is not None:
|
||||||
|
|||||||
@@ -401,6 +401,27 @@ def focus_window(boss, window, payload):
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
# focus_tab {{{
|
||||||
|
@cmd(
|
||||||
|
'Focus the specified tab',
|
||||||
|
'The active window in the specified tab will be focused.',
|
||||||
|
options_spec=MATCH_TAB_OPTION,
|
||||||
|
argspec='',
|
||||||
|
)
|
||||||
|
def cmd_focus_tab(global_opts, opts, args):
|
||||||
|
return {'match': opts.match}
|
||||||
|
|
||||||
|
|
||||||
|
def focus_tab(boss, window, payload):
|
||||||
|
match = payload['match']
|
||||||
|
tabs = tuple(boss.match_tabs(match))
|
||||||
|
if not tabs:
|
||||||
|
raise MatchError(match, 'tabs')
|
||||||
|
tab = tabs[0]
|
||||||
|
boss.set_active_tab(tab)
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
# get_text {{{
|
# get_text {{{
|
||||||
@cmd(
|
@cmd(
|
||||||
'Get text from the specified window',
|
'Get text from the specified window',
|
||||||
|
|||||||
@@ -57,9 +57,14 @@ Let's change the title of the current tab:
|
|||||||
|
|
||||||
kitty @ set-tab-title Master Tab
|
kitty @ set-tab-title Master Tab
|
||||||
|
|
||||||
Now lets switch to the newly opened tab.
|
Now lets switch to the newly opened tab:
|
||||||
|
|
||||||
kitty @ focus-window --match title:New
|
kitty @ focus-tab --match title:New
|
||||||
|
|
||||||
|
Similarly, to focus the previously opened output window (which will also switch
|
||||||
|
back to the old tab, automatically):
|
||||||
|
|
||||||
|
kitty @ focus-window --match title:Output
|
||||||
|
|
||||||
You can get a listing of available tabs and windows, by running:
|
You can get a listing of available tabs and windows, by running:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user