Add a remote control command for detach_tab
This commit is contained in:
parent
95e36cece1
commit
83932c8099
@ -425,6 +425,50 @@ def detach_window(boss, window, payload):
|
||||
# }}}
|
||||
|
||||
|
||||
# detach_tab {{{
|
||||
@cmd(
|
||||
'Detach a tab and place it in a different/new OS Window',
|
||||
'Detach the specified tab and either move it into a new OS window'
|
||||
' or add it to the OS Window containing the tab specified by --target-tab',
|
||||
options_spec=MATCH_TAB_OPTION + '\n\n' + MATCH_TAB_OPTION.replace('--match -m', '--target-tab -t') + '''\n
|
||||
--self
|
||||
type=bool-set
|
||||
If specified detach the tab this command is run in, rather than the active tab.
|
||||
''',
|
||||
argspec=''
|
||||
)
|
||||
def cmd_detach_tab(global_opts, opts, args):
|
||||
'''
|
||||
match: Which tab to detach
|
||||
target: Which OS Window to move the detached tab to
|
||||
self: Boolean indicating whether to detach the tab the command is run in
|
||||
'''
|
||||
return {'match': opts.match, 'target': opts.target_tab, 'self': opts.self}
|
||||
|
||||
|
||||
def detach_tab(boss, window, payload):
|
||||
pg = cmd_detach_tab.payload_get
|
||||
match = pg(payload, 'match')
|
||||
if match:
|
||||
tabs = tuple(boss.match_tabs(match))
|
||||
if not tabs:
|
||||
raise MatchError(match)
|
||||
else:
|
||||
tabs = [window.tabref() if pg(payload, 'self') and window and window.tabref() else boss.active_tab]
|
||||
match = pg(payload, 'target_tab')
|
||||
kwargs = {}
|
||||
if match:
|
||||
targets = tuple(boss.match_tabs(match))
|
||||
if not targets:
|
||||
raise MatchError(match, 'tabs')
|
||||
kwargs['target_os_window_id'] = targets[0].os_window_id
|
||||
|
||||
for tab in tabs:
|
||||
boss._move_tab_to(tab=tab, **kwargs)
|
||||
|
||||
# }}}
|
||||
|
||||
|
||||
# goto_layout {{{
|
||||
@cmd(
|
||||
'Set the window layout',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user