Start adding typing info

This commit is contained in:
Kovid Goyal 2020-03-03 14:31:25 +05:30
parent ee48fd7151
commit 64b497589f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 71 additions and 14 deletions

1
.gitignore vendored
View File

@ -14,4 +14,5 @@ __pycache__/
/glfw/wayland-*-client-protocol.[ch] /glfw/wayland-*-client-protocol.[ch]
/docs/_build/ /docs/_build/
/docs/generated/ /docs/generated/
/.mypy_cache
.DS_Store .DS_Store

View File

@ -145,6 +145,7 @@ def main(sys_args):
if __name__ == '__main__': if __name__ == '__main__':
main(sys.argv) main(sys.argv)
elif __name__ == '__doc__': elif __name__ == '__doc__':
sys.cli_docs['usage'] = usage cd: dict = sys.cli_docs # type: ignore
sys.cli_docs['options'] = OPTIONS cd['usage'] = usage
sys.cli_docs['help_text'] = help_text cd['options'] = OPTIONS
cd['help_text'] = help_text

50
kitty/fast_data_types.pyi Normal file
View File

@ -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

View File

@ -137,19 +137,24 @@ def _run_app(opts, args, bad_lines=()):
boss.destroy() boss.destroy()
def run_app(opts, args, bad_lines=()): class AppRunner:
set_scale(opts.box_drawing_scale)
set_options(opts, is_wayland(), args.debug_gl, args.debug_font_fallback) def __init__(self):
set_font_family(opts, debug_font_matching=args.debug_font_fallback) self.cached_values_name = 'main'
try: self.first_window_callback = lambda window_handle: None
_run_app(opts, args, bad_lines) self.initial_window_size_func = initial_window_size_func
finally:
free_font_data() # must free font data before glfw/freetype/fontconfig/opengl etc are finalized 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 = AppRunner()
run_app.first_window_callback = lambda window_handle: None
run_app.initial_window_size_func = initial_window_size_func
def ensure_macos_locale(): def ensure_macos_locale():