Make loading of kitty options in kitten re-useable
This commit is contained in:
parent
d6afe6f2cb
commit
ebcbed290f
@ -32,15 +32,15 @@ from kitty.constants import (
|
|||||||
cache_dir, runtime_dir, shell_integration_dir, ssh_control_master_template,
|
cache_dir, runtime_dir, shell_integration_dir, ssh_control_master_template,
|
||||||
str_version, terminfo_dir
|
str_version, terminfo_dir
|
||||||
)
|
)
|
||||||
from kitty.options.types import Options
|
|
||||||
from kitty.shell_integration import as_str_literal
|
from kitty.shell_integration import as_str_literal
|
||||||
from kitty.shm import SharedMemory
|
from kitty.shm import SharedMemory
|
||||||
from kitty.types import run_once
|
from kitty.types import run_once
|
||||||
from kitty.utils import (
|
from kitty.utils import (
|
||||||
SSHConnectionData, expandvars, resolve_abs_or_config_path,
|
SSHConnectionData, expandvars, resolve_abs_or_config_path,
|
||||||
set_echo as turn_off_echo, suppress_error_logging
|
set_echo as turn_off_echo
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from ..tui.utils import kitty_opts
|
||||||
from .config import init_config
|
from .config import init_config
|
||||||
from .copy import CopyInstruction
|
from .copy import CopyInstruction
|
||||||
from .options.types import Options as SSHOptions
|
from .options.types import Options as SSHOptions
|
||||||
@ -110,13 +110,6 @@ def serialize_env(literal_env: Dict[str, str], env: Dict[str, str], base_env: Di
|
|||||||
return '\n'.join(lines).encode('utf-8')
|
return '\n'.join(lines).encode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
@run_once
|
|
||||||
def kitty_opts() -> Options:
|
|
||||||
from kitty.cli import create_default_opts
|
|
||||||
with suppress_error_logging():
|
|
||||||
return create_default_opts()
|
|
||||||
|
|
||||||
|
|
||||||
def make_tarfile(ssh_opts: SSHOptions, base_env: Dict[str, str], compression: str = 'gz', literal_env: Dict[str, str] = {}) -> bytes:
|
def make_tarfile(ssh_opts: SSHOptions, base_env: Dict[str, str], compression: str = 'gz', literal_env: Dict[str, str] = {}) -> bytes:
|
||||||
|
|
||||||
def normalize_tarinfo(tarinfo: tarfile.TarInfo) -> tarfile.TarInfo:
|
def normalize_tarinfo(tarinfo: tarfile.TarInfo) -> tarfile.TarInfo:
|
||||||
@ -154,6 +147,7 @@ def make_tarfile(ssh_opts: SSHOptions, base_env: Dict[str, str], compression: st
|
|||||||
if ssh_opts.shell_integration == 'inherited':
|
if ssh_opts.shell_integration == 'inherited':
|
||||||
ksi = get_effective_ksi_env_var(kitty_opts())
|
ksi = get_effective_ksi_env_var(kitty_opts())
|
||||||
else:
|
else:
|
||||||
|
from kitty.options.types import Options
|
||||||
from kitty.options.utils import shell_integration
|
from kitty.options.utils import shell_integration
|
||||||
ksi = get_effective_ksi_env_var(Options({'shell_integration': shell_integration(ssh_opts.shell_integration)}))
|
ksi = get_effective_ksi_env_var(Options({'shell_integration': shell_integration(ssh_opts.shell_integration)}))
|
||||||
|
|
||||||
|
|||||||
@ -3,10 +3,15 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from typing import Tuple
|
from typing import TYPE_CHECKING, Tuple
|
||||||
|
|
||||||
|
from kitty.types import run_once
|
||||||
|
|
||||||
from .operations import raw_mode, set_cursor_visible
|
from .operations import raw_mode, set_cursor_visible
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from kitty.options.types import Options
|
||||||
|
|
||||||
|
|
||||||
def get_key_press(allowed: str, default: str) -> str:
|
def get_key_press(allowed: str, default: str) -> str:
|
||||||
response = default
|
response = default
|
||||||
@ -50,6 +55,14 @@ def human_size(
|
|||||||
return format_number(size / 1024**exponent, max_num_of_decimals) + sep + unit_list[exponent]
|
return format_number(size / 1024**exponent, max_num_of_decimals) + sep + unit_list[exponent]
|
||||||
|
|
||||||
|
|
||||||
|
@run_once
|
||||||
|
def kitty_opts() -> Options:
|
||||||
|
from kitty.cli import create_default_opts
|
||||||
|
from kitty.utils import suppress_error_logging
|
||||||
|
with suppress_error_logging():
|
||||||
|
return create_default_opts()
|
||||||
|
|
||||||
|
|
||||||
def report_error(msg: str = '', return_code: int = 1, print_exc: bool = False) -> None:
|
def report_error(msg: str = '', return_code: int = 1, print_exc: bool = False) -> None:
|
||||||
' Report an error also sending the overlay ready message to ensure kitten is visible '
|
' Report an error also sending the overlay ready message to ensure kitten is visible '
|
||||||
from .operations import overlay_ready
|
from .operations import overlay_ready
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user