diff --git a/.gitignore b/.gitignore index 635731cad..47b8844d5 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ __pycache__/ /glfw/wayland-*-client-protocol.[ch] /docs/_build/ /docs/generated/ +/.mypy_cache .DS_Store diff --git a/kittens/panel/main.py b/kittens/panel/main.py index 2c2f9b871..7e7abe3e9 100644 --- a/kittens/panel/main.py +++ b/kittens/panel/main.py @@ -145,6 +145,7 @@ def main(sys_args): if __name__ == '__main__': main(sys.argv) elif __name__ == '__doc__': - sys.cli_docs['usage'] = usage - sys.cli_docs['options'] = OPTIONS - sys.cli_docs['help_text'] = help_text + cd: dict = sys.cli_docs # type: ignore + cd['usage'] = usage + cd['options'] = OPTIONS + cd['help_text'] = help_text diff --git a/kitty/fast_data_types.pyi b/kitty/fast_data_types.pyi new file mode 100644 index 000000000..f52ddc935 --- /dev/null +++ b/kitty/fast_data_types.pyi @@ -0,0 +1,50 @@ +from typing import Callable, Optional, Tuple +from kitty.cli import Namespace + +GLFW_IBEAM_CURSOR: int + + +def create_os_window( + get_window_size: Callable[[int, int, int, int, float, float], Tuple[int, int]], + pre_show_callback: Callable[[object], None], + title: str, + wm_class_name: str, + wm_class_class: str, + load_programs: Optional[Callable[[bool], None]] = None, + x: int = -1, + y: int = -1 +) -> int: + pass + + +def set_options( + opts: Namespace, + is_wayland: bool = False, + debug_gl: bool = False, + debug_font_fallback: bool = False +) -> None: + pass + + +def set_default_window_icon(data: bytes, width: int, height: int) -> None: + pass + + +def set_custom_cursor(cursor_type: int, images: Tuple[Tuple[bytes, int, int], ...], x: int = 0, y: int = 0) -> None: + pass + + +def load_png_data(data: bytes) -> Tuple[bytes, int, int]: + pass + + +def glfw_terminate() -> None: + pass + + +def glfw_init(path: str, debug_keyboard: bool = False) -> bool: + pass + + +def free_font_data() -> None: + pass diff --git a/kitty/main.py b/kitty/main.py index 68cbb973d..a69867244 100644 --- a/kitty/main.py +++ b/kitty/main.py @@ -137,19 +137,24 @@ def _run_app(opts, args, bad_lines=()): boss.destroy() -def run_app(opts, args, bad_lines=()): - set_scale(opts.box_drawing_scale) - set_options(opts, is_wayland(), args.debug_gl, args.debug_font_fallback) - set_font_family(opts, debug_font_matching=args.debug_font_fallback) - try: - _run_app(opts, args, bad_lines) - finally: - free_font_data() # must free font data before glfw/freetype/fontconfig/opengl etc are finalized +class AppRunner: + + def __init__(self): + self.cached_values_name = 'main' + self.first_window_callback = lambda window_handle: None + self.initial_window_size_func = initial_window_size_func + + def __call__(self, opts, args, bad_lines=()): + set_scale(opts.box_drawing_scale) + set_options(opts, is_wayland(), args.debug_gl, args.debug_font_fallback) + set_font_family(opts, debug_font_matching=args.debug_font_fallback) + try: + _run_app(opts, args, bad_lines) + finally: + free_font_data() # must free font data before glfw/freetype/fontconfig/opengl etc are finalized -run_app.cached_values_name = 'main' -run_app.first_window_callback = lambda window_handle: None -run_app.initial_window_size_func = initial_window_size_func +run_app = AppRunner() def ensure_macos_locale():