mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 16:37:27 +00:00
Store creation spec on windows
Will come in handy when serializing them
This commit is contained in:
parent
0b8782d0fe
commit
e797ad746e
3 changed files with 38 additions and 1 deletions
|
|
@ -779,6 +779,8 @@ def _launch(
|
|||
env=env or None, watchers=watchers or None, is_clone_launch=is_clone_launch, next_to=next_to, **kw)
|
||||
if child_death_callback is not None:
|
||||
boss.monitor_pid(new_window.child.pid or 0, child_death_callback)
|
||||
if new_window.creation_spec and opts.watcher:
|
||||
new_window.creation_spec = new_window.creation_spec._replace(watchers=tuple(opts.watcher))
|
||||
if spacing:
|
||||
patch_window_edges(new_window, spacing)
|
||||
tab.relayout()
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ from .tab_bar import TabBar, TabBarData
|
|||
from .types import ac
|
||||
from .typing_compat import EdgeLiteral, SessionTab, SessionType, TypedDict
|
||||
from .utils import cmdline_for_hold, log_error, platform_window_id, resolved_shell, shlex_split, which
|
||||
from .window import CwdRequest, Watchers, Window, WindowDict, global_watchers
|
||||
from .window import CwdRequest, Watchers, Window, WindowCreationSpec, WindowDict, global_watchers
|
||||
from .window_list import WindowList
|
||||
|
||||
|
||||
|
|
@ -584,6 +584,15 @@ class Tab: # {{{
|
|||
next_to: Window | None = None,
|
||||
hold_after_ssh: bool = False
|
||||
) -> Window:
|
||||
cs = WindowCreationSpec(
|
||||
use_shell=use_shell, cmd=cmd, has_stdin=bool(stdin), override_title=override_title, cwd_from=cwd_from,
|
||||
cwd=cwd, overlay_for=overlay_for, env=None if env is None else tuple(env.items()), location=location,
|
||||
copy_colors_from=None if copy_colors_from is None else copy_colors_from.id,
|
||||
allow_remote_control=allow_remote_control,
|
||||
remote_control_passwords=None if remote_control_passwords is None else remote_control_passwords.copy(),
|
||||
marker=marker, overlay_behind=overlay_behind, is_clone_launch=is_clone_launch, hold=hold, bias=bias,
|
||||
hold_after_ssh=hold_after_ssh,
|
||||
)
|
||||
child = self.launch_child(
|
||||
use_shell=use_shell, cmd=cmd, stdin=stdin, cwd_from=cwd_from, cwd=cwd, env=env,
|
||||
is_clone_launch=is_clone_launch, add_listen_on_env_var=False if allow_remote_control and remote_control_passwords else True,
|
||||
|
|
@ -594,6 +603,7 @@ class Tab: # {{{
|
|||
copy_colors_from=copy_colors_from, watchers=watchers,
|
||||
allow_remote_control=allow_remote_control, remote_control_passwords=remote_control_passwords
|
||||
)
|
||||
window.creation_spec = cs
|
||||
# Must add child before laying out so that resize_pty succeeds
|
||||
get_boss().add_child(window)
|
||||
self._add_window(window, location=location, overlay_for=overlay_for, overlay_behind=overlay_behind, bias=bias, next_to=next_to)
|
||||
|
|
|
|||
|
|
@ -358,6 +358,30 @@ def call_watchers(windowref: Callable[[], Optional['Window']], which: str, data:
|
|||
add_timer(callback, 0, False)
|
||||
|
||||
|
||||
class WindowCreationSpec(NamedTuple):
|
||||
use_shell: bool = True
|
||||
cmd: list[str] | None = None
|
||||
has_stdin: bool = False
|
||||
override_title: str | None = None
|
||||
cwd_from: CwdRequest | None = None
|
||||
cwd: str | None = None
|
||||
overlay_for: int | None = None
|
||||
env: tuple[tuple[str, str], ...] | None = None
|
||||
location: str | None = None
|
||||
copy_colors_from: int | None = None
|
||||
allow_remote_control: bool = False
|
||||
marker: str | None = None
|
||||
watchers: tuple[str, ...] = ()
|
||||
overlay_behind: bool = False
|
||||
is_clone_launch: str = ''
|
||||
remote_control_passwords: dict[str, Sequence[str]] | None = None
|
||||
hold: bool = False
|
||||
bias: float | None = None
|
||||
pass_fds: tuple[int, ...] = ()
|
||||
remote_control_fd: int = -1
|
||||
hold_after_ssh: bool = False
|
||||
|
||||
|
||||
def pagerhist(screen: Screen, as_ansi: bool = False, add_wrap_markers: bool = True, upto_output_start: bool = False) -> str:
|
||||
pht = screen.historybuf.pagerhist_as_text(upto_output_start)
|
||||
if pht and (not as_ansi or not add_wrap_markers):
|
||||
|
|
@ -614,6 +638,7 @@ class Window:
|
|||
overlay_type = OverlayType.transient
|
||||
initial_ignore_focus_changes: bool = False
|
||||
initial_ignore_focus_changes_context_manager_in_operation: bool = False
|
||||
creation_spec: WindowCreationSpec | None = None
|
||||
|
||||
@classmethod
|
||||
@contextmanager
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue