Add --new-tab to @new-window

This commit is contained in:
Kovid Goyal
2018-01-09 23:09:57 +05:30
parent e5b9bd2e5a
commit c11a20f1ec
3 changed files with 28 additions and 5 deletions

View File

@@ -11,6 +11,7 @@ from functools import partial
from .cli import emph, parse_args
from .config import parse_send_text_bytes
from .constants import appname, version
from .tabs import SpecialWindow
from .utils import read_with_timeout
@@ -225,13 +226,32 @@ program running in it.
--cwd
The initial working directory for the new window.
--new-tab
type=bool-set
Open a new tab
--tab-title
When using --new-tab set the title of the tab.
'''
)
def cmd_new_window(global_opts, opts, args):
return {'match': opts.match, 'title': opts.title, 'cwd': opts.cwd, 'args': args or []}
return {'match': opts.match, 'title': opts.title, 'cwd': opts.cwd,
'new_tab': opts.new_tab, 'tab_title': opts.tab_title,
'args': args or []}
def new_window(boss, window, payload):
w = SpecialWindow(cmd=payload['args'] or None, override_title=payload['title'], cwd=payload['cwd'])
if payload['new_tab']:
boss._new_tab(w)
tab = boss.active_tab
if payload['tab_title']:
tab.set_title(payload['tab_title'])
return str(boss.active_window.id)
match = payload['match']
if match:
tabs = tuple(boss.match_tabs(match))
@@ -240,7 +260,7 @@ def new_window(boss, window, payload):
else:
tabs = [boss.active_tab]
tab = tabs[0]
w = tab.new_window(use_shell=True, cmd=payload['args'] or None, override_title=payload['title'], cwd=payload['cwd'])
w = tab.new_special_window(w)
return str(w.id)