Make loading of kitty options in kitten re-useable

This commit is contained in:
Kovid Goyal
2022-06-03 17:48:38 +05:30
parent d6afe6f2cb
commit ebcbed290f
2 changed files with 17 additions and 10 deletions

View File

@@ -3,10 +3,15 @@
import sys
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
if TYPE_CHECKING:
from kitty.options.types import Options
def get_key_press(allowed: str, default: str) -> str:
response = default
@@ -50,6 +55,14 @@ def human_size(
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:
' Report an error also sending the overlay ready message to ensure kitten is visible '
from .operations import overlay_ready