Add --new-tab to @new-window
This commit is contained in:
parent
e5b9bd2e5a
commit
c11a20f1ec
@ -19,7 +19,7 @@ from .fonts.render import prerender, resize_fonts, set_font_family
|
||||
from .keys import get_shortcut
|
||||
from .remote_control import handle_cmd
|
||||
from .session import create_session
|
||||
from .tabs import SpecialWindow, TabManager
|
||||
from .tabs import SpecialWindow, SpecialWindowInstance, TabManager
|
||||
from .utils import (
|
||||
end_startup_notification, get_primary_selection, init_startup_notification,
|
||||
open_url, safe_print, set_primary_selection, single_instance
|
||||
@ -452,6 +452,9 @@ class Boss:
|
||||
def _new_tab(self, args, cwd_from=None):
|
||||
special_window = None
|
||||
if args:
|
||||
if isinstance(args, SpecialWindowInstance):
|
||||
special_window = args
|
||||
else:
|
||||
special_window = self.args_to_special_window(args, cwd_from=cwd_from)
|
||||
tm = self.active_tab_manager
|
||||
if tm is not None:
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
|
||||
@ -143,7 +143,7 @@ class Tab: # {{{
|
||||
return window
|
||||
|
||||
def new_special_window(self, special_window):
|
||||
self.new_window(False, *special_window)
|
||||
return self.new_window(False, *special_window)
|
||||
|
||||
def close_window(self):
|
||||
if self.windows:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user