mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 16:58:09 +02:00
Make loading of kitty options in kitten re-useable
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user