mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-10 18:48:54 +02:00
Change to pass window specs.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
import shlex
|
||||
import sys
|
||||
from typing import TYPE_CHECKING, Generator, Iterator, List, Optional, Union, NamedTuple
|
||||
from typing import TYPE_CHECKING, Generator, Iterator, List, Optional, Union, NamedTuple, Tuple
|
||||
|
||||
from .cli_stub import CLIOptions
|
||||
from .constants import kitty_exe
|
||||
@@ -26,16 +26,17 @@ def get_os_window_sizing_data(opts: Options, session: Optional['Session'] = None
|
||||
return WindowSizeData(sizes, opts.remember_window_size, opts.single_window_margin_width, opts.window_margin_width, opts.window_padding_width)
|
||||
|
||||
|
||||
class SessionResizeWindow(NamedTuple):
|
||||
direction: str
|
||||
steps: int
|
||||
class WindowSpecs:
|
||||
def __init__(self, launch_spec):
|
||||
from .launch import LaunchSpec
|
||||
self.launch_spec: Union[LaunchSpec, 'SpecialWindowInstance'] = launch_spec
|
||||
self.resize_spec: Optional[Tuple[str,int]] = None
|
||||
|
||||
|
||||
class Tab:
|
||||
|
||||
def __init__(self, opts: Options, name: str):
|
||||
from .launch import LaunchSpec
|
||||
self.windows: List[Union[LaunchSpec, SessionResizeWindow, 'SpecialWindowInstance']] = []
|
||||
self.windows: List[WindowSpecs] = []
|
||||
self.name = name.strip()
|
||||
self.active_window_idx = 0
|
||||
self.enabled_layouts = opts.enabled_layouts
|
||||
@@ -75,7 +76,7 @@ class Session:
|
||||
if t.next_title and not spec.opts.window_title:
|
||||
spec.opts.window_title = t.next_title
|
||||
spec.opts.cwd = spec.opts.cwd or t.cwd
|
||||
t.windows.append(spec)
|
||||
t.windows.append(WindowSpecs(spec))
|
||||
t.next_title = None
|
||||
|
||||
def resize_window(self, args: List[str]) -> None:
|
||||
@@ -83,7 +84,7 @@ class Session:
|
||||
if len(args) > 1:
|
||||
steps = int(args[1])
|
||||
t = self.tabs[-1]
|
||||
t.windows.append(SessionResizeWindow(args[0], steps))
|
||||
t.windows[-1].resize_spec = (args[0], steps)
|
||||
|
||||
def add_special_window(self, sw: 'SpecialWindowInstance') -> None:
|
||||
self.tabs[-1].windows.append(sw)
|
||||
|
||||
@@ -27,7 +27,6 @@ from .fast_data_types import (
|
||||
)
|
||||
from .layout.base import Layout
|
||||
from .layout.interface import create_layout_object_for, evict_cached_layouts
|
||||
from .session import SessionResizeWindow
|
||||
from .tab_bar import TabBar, TabBarData
|
||||
from .types import ac
|
||||
from .typing import EdgeLiteral, SessionTab, SessionType, TypedDict
|
||||
@@ -169,14 +168,16 @@ class Tab: # {{{
|
||||
self.mark_tab_bar_dirty()
|
||||
|
||||
def startup(self, session_tab: 'SessionTab') -> None:
|
||||
for cmd in session_tab.windows:
|
||||
if isinstance(cmd, SessionResizeWindow):
|
||||
self.resize_window(*cmd)
|
||||
elif isinstance(cmd, SpecialWindowInstance):
|
||||
self.new_special_window(cmd)
|
||||
for window in session_tab.windows:
|
||||
spec = window.launch_spec
|
||||
if isinstance(window.launch_spec, SpecialWindowInstance):
|
||||
self.new_special_window(spec)
|
||||
else:
|
||||
from .launch import launch
|
||||
launch(get_boss(), cmd.opts, cmd.args, target_tab=self, force_target_tab=True)
|
||||
launch(get_boss(), spec.opts, spec.args, target_tab=self, force_target_tab=True)
|
||||
if window.resize_spec is not None:
|
||||
self.resize_window(*window.resize_spec)
|
||||
|
||||
self.windows.set_active_window_group_for(self.windows.all_windows[session_tab.active_window_idx])
|
||||
|
||||
def serialize_state(self) -> Dict[str, Any]:
|
||||
|
||||
Reference in New Issue
Block a user