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 .keys import get_shortcut
|
||||||
from .remote_control import handle_cmd
|
from .remote_control import handle_cmd
|
||||||
from .session import create_session
|
from .session import create_session
|
||||||
from .tabs import SpecialWindow, TabManager
|
from .tabs import SpecialWindow, SpecialWindowInstance, TabManager
|
||||||
from .utils import (
|
from .utils import (
|
||||||
end_startup_notification, get_primary_selection, init_startup_notification,
|
end_startup_notification, get_primary_selection, init_startup_notification,
|
||||||
open_url, safe_print, set_primary_selection, single_instance
|
open_url, safe_print, set_primary_selection, single_instance
|
||||||
@ -452,7 +452,10 @@ class Boss:
|
|||||||
def _new_tab(self, args, cwd_from=None):
|
def _new_tab(self, args, cwd_from=None):
|
||||||
special_window = None
|
special_window = None
|
||||||
if args:
|
if args:
|
||||||
special_window = self.args_to_special_window(args, cwd_from=cwd_from)
|
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
|
tm = self.active_tab_manager
|
||||||
if tm is not None:
|
if tm is not None:
|
||||||
tm.new_tab(special_window=special_window, cwd_from=cwd_from)
|
tm.new_tab(special_window=special_window, cwd_from=cwd_from)
|
||||||
|
|||||||
@ -11,6 +11,7 @@ from functools import partial
|
|||||||
from .cli import emph, parse_args
|
from .cli import emph, parse_args
|
||||||
from .config import parse_send_text_bytes
|
from .config import parse_send_text_bytes
|
||||||
from .constants import appname, version
|
from .constants import appname, version
|
||||||
|
from .tabs import SpecialWindow
|
||||||
from .utils import read_with_timeout
|
from .utils import read_with_timeout
|
||||||
|
|
||||||
|
|
||||||
@ -225,13 +226,32 @@ program running in it.
|
|||||||
|
|
||||||
--cwd
|
--cwd
|
||||||
The initial working directory for the new window.
|
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):
|
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):
|
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']
|
match = payload['match']
|
||||||
if match:
|
if match:
|
||||||
tabs = tuple(boss.match_tabs(match))
|
tabs = tuple(boss.match_tabs(match))
|
||||||
@ -240,7 +260,7 @@ def new_window(boss, window, payload):
|
|||||||
else:
|
else:
|
||||||
tabs = [boss.active_tab]
|
tabs = [boss.active_tab]
|
||||||
tab = tabs[0]
|
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)
|
return str(w.id)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -143,7 +143,7 @@ class Tab: # {{{
|
|||||||
return window
|
return window
|
||||||
|
|
||||||
def new_special_window(self, special_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):
|
def close_window(self):
|
||||||
if self.windows:
|
if self.windows:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user