parent
58bb5a7d1f
commit
4baf7b5bba
@ -24,6 +24,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
||||
multi-character ligatures under the cursor to make editing easier
|
||||
(:iss:`461`)
|
||||
|
||||
- Allow creating new OS windows in session files (:iss:`1514`)
|
||||
|
||||
- Allow specifying a value of ``none`` for the :opt:`selection_foreground`
|
||||
which will cause kitty to not change text color in selections (:iss:`1358`)
|
||||
|
||||
|
||||
@ -342,6 +342,10 @@ For example:
|
||||
# Set the current layout
|
||||
layout stack
|
||||
launch zsh
|
||||
|
||||
# Create a new OS window
|
||||
new_os_window
|
||||
launch sh
|
||||
# Make the current window the active (focused) window
|
||||
focus
|
||||
launch emacs
|
||||
|
||||
@ -30,7 +30,7 @@ from .keys import get_shortcut, shortcut_matches
|
||||
from .layout import set_draw_borders_options
|
||||
from .remote_control import handle_cmd
|
||||
from .rgb import Color, color_from_int
|
||||
from .session import create_session
|
||||
from .session import create_sessions
|
||||
from .tabs import SpecialWindow, SpecialWindowInstance, TabManager
|
||||
from .utils import (
|
||||
func_name, get_editor, get_primary_selection, is_path_in_temp_dir,
|
||||
@ -128,16 +128,18 @@ class Boss:
|
||||
)
|
||||
set_boss(self)
|
||||
self.opts, self.args = opts, args
|
||||
startup_session = create_session(opts, args, default_session=opts.startup_session)
|
||||
startup_sessions = create_sessions(opts, args, default_session=opts.startup_session)
|
||||
self.keymap = self.opts.keymap.copy()
|
||||
if new_os_window_trigger is not None:
|
||||
self.keymap.pop(new_os_window_trigger, None)
|
||||
self.add_os_window(startup_session, os_window_id=os_window_id)
|
||||
if args.start_as != 'normal':
|
||||
if args.start_as == 'fullscreen':
|
||||
self.toggle_fullscreen()
|
||||
else:
|
||||
change_os_window_state(args.start_as)
|
||||
for startup_session in startup_sessions:
|
||||
os_window_id = self.add_os_window(startup_session, os_window_id=os_window_id)
|
||||
if args.start_as != 'normal':
|
||||
if args.start_as == 'fullscreen':
|
||||
self.toggle_fullscreen()
|
||||
else:
|
||||
change_os_window_state(args.start_as)
|
||||
os_window_id = None
|
||||
if is_macos:
|
||||
from .fast_data_types import cocoa_set_notification_activated_callback
|
||||
cocoa_set_notification_activated_callback(self.notification_activated)
|
||||
@ -246,7 +248,7 @@ class Boss:
|
||||
sw = args
|
||||
else:
|
||||
sw = self.args_to_special_window(args, cwd_from) if args else None
|
||||
startup_session = create_session(self.opts, special_window=sw, cwd_from=cwd_from)
|
||||
startup_session = next(create_sessions(self.opts, special_window=sw, cwd_from=cwd_from))
|
||||
return self.add_os_window(startup_session)
|
||||
|
||||
def new_os_window(self, *args):
|
||||
@ -304,10 +306,10 @@ class Boss:
|
||||
opts = create_opts(args)
|
||||
if not os.path.isabs(args.directory):
|
||||
args.directory = os.path.join(msg['cwd'], args.directory)
|
||||
session = create_session(opts, args, respect_cwd=True)
|
||||
os_window_id = self.add_os_window(session, wclass=args.cls, wname=args.name, opts_for_size=opts, startup_id=startup_id)
|
||||
if msg.get('notify_on_os_window_death'):
|
||||
self.os_window_death_actions[os_window_id] = partial(self.notify_on_os_window_death, msg['notify_on_os_window_death'])
|
||||
for session in create_sessions(opts, args, respect_cwd=True):
|
||||
os_window_id = self.add_os_window(session, wclass=args.cls, wname=args.name, opts_for_size=opts, startup_id=startup_id)
|
||||
if msg.get('notify_on_os_window_death'):
|
||||
self.os_window_death_actions[os_window_id] = partial(self.notify_on_os_window_death, msg['notify_on_os_window_death'])
|
||||
else:
|
||||
log_error('Unknown message received from peer, ignoring')
|
||||
|
||||
|
||||
@ -78,6 +78,13 @@ def resolved_shell(opts):
|
||||
|
||||
|
||||
def parse_session(raw, opts, default_title=None):
|
||||
|
||||
def finalize_session(ans):
|
||||
for t in ans.tabs:
|
||||
if not t.windows:
|
||||
t.windows.append(resolved_shell(opts))
|
||||
return ans
|
||||
|
||||
ans = Session(default_title)
|
||||
ans.add_tab(opts)
|
||||
for line in raw.splitlines():
|
||||
@ -87,6 +94,10 @@ def parse_session(raw, opts, default_title=None):
|
||||
cmd, rest = cmd.strip(), rest.strip()
|
||||
if cmd == 'new_tab':
|
||||
ans.add_tab(opts, rest)
|
||||
elif cmd == 'new_os_window':
|
||||
yield finalize_session(ans)
|
||||
ans = Session(default_title)
|
||||
ans.add_tab(opts, rest)
|
||||
elif cmd == 'layout':
|
||||
ans.set_layout(rest)
|
||||
elif cmd == 'launch':
|
||||
@ -101,16 +112,14 @@ def parse_session(raw, opts, default_title=None):
|
||||
ans.set_next_title(rest)
|
||||
else:
|
||||
raise ValueError('Unknown command in session file: {}'.format(cmd))
|
||||
for t in ans.tabs:
|
||||
if not t.windows:
|
||||
t.windows.append(resolved_shell(opts))
|
||||
return ans
|
||||
yield finalize_session(ans)
|
||||
|
||||
|
||||
def create_session(opts, args=None, special_window=None, cwd_from=None, respect_cwd=False, default_session=None):
|
||||
def create_sessions(opts, args=None, special_window=None, cwd_from=None, respect_cwd=False, default_session=None):
|
||||
if args and args.session:
|
||||
with open(args.session) as f:
|
||||
return parse_session(f.read(), opts, getattr(args, 'title', None))
|
||||
yield from parse_session(f.read(), opts, getattr(args, 'title', None))
|
||||
return
|
||||
if default_session and default_session != 'none':
|
||||
try:
|
||||
with open(default_session) as f:
|
||||
@ -118,7 +127,8 @@ def create_session(opts, args=None, special_window=None, cwd_from=None, respect_
|
||||
except EnvironmentError:
|
||||
log_error('Failed to read from session file, ignoring: {}'.format(default_session))
|
||||
else:
|
||||
return parse_session(session_data, opts, getattr(args, 'title', None))
|
||||
yield from parse_session(session_data, opts, getattr(args, 'title', None))
|
||||
return
|
||||
ans = Session()
|
||||
current_layout = opts.enabled_layouts[0] if opts.enabled_layouts else 'tall'
|
||||
ans.add_tab(opts)
|
||||
@ -135,4 +145,4 @@ def create_session(opts, args=None, special_window=None, cwd_from=None, respect_
|
||||
k['override_title'] = args.title
|
||||
special_window = SpecialWindow(cmd, **k)
|
||||
ans.add_special_window(special_window)
|
||||
return ans
|
||||
yield ans
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user