mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-19 06:54:58 +02:00
No top level typing issues for kittens
This commit is contained in:
@@ -4,12 +4,13 @@
|
||||
|
||||
import os
|
||||
import re
|
||||
from contextlib import suppress
|
||||
from functools import lru_cache
|
||||
from hashlib import md5
|
||||
from mimetypes import guess_type
|
||||
from contextlib import suppress
|
||||
from typing import Dict
|
||||
|
||||
path_name_map = {}
|
||||
path_name_map: Dict[str, str] = {}
|
||||
|
||||
|
||||
class Segment:
|
||||
@@ -146,13 +147,17 @@ def data_for_path(path):
|
||||
return ans
|
||||
|
||||
|
||||
@lru_cache(maxsize=1024)
|
||||
def lines_for_path(path):
|
||||
data = data_for_path(path).replace('\t', lines_for_path.replace_tab_by)
|
||||
return tuple(sanitize(data).splitlines())
|
||||
class LinesForPath:
|
||||
|
||||
replace_tab_by = ' ' * 4
|
||||
|
||||
@lru_cache(maxsize=1024)
|
||||
def __call__(self, path):
|
||||
data = data_for_path(path).replace('\t', self.replace_tab_by)
|
||||
return tuple(sanitize(data).splitlines())
|
||||
|
||||
|
||||
lines_for_path.replace_tab_by = ' ' * 4
|
||||
lines_for_path = LinesForPath()
|
||||
|
||||
|
||||
@lru_cache(maxsize=1024)
|
||||
|
||||
@@ -3,18 +3,17 @@
|
||||
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
from functools import partial
|
||||
# Utils {{{
|
||||
from gettext import gettext as _
|
||||
from functools import partial
|
||||
from typing import Dict, Union
|
||||
|
||||
from kitty.conf.definition import option_func
|
||||
from kitty.conf.utils import (
|
||||
positive_int, python_string, to_color
|
||||
)
|
||||
from kitty.conf.definition import Option, Shortcut, option_func
|
||||
from kitty.conf.utils import positive_int, python_string, to_color
|
||||
|
||||
# }}}
|
||||
|
||||
all_options = {}
|
||||
all_options: Dict[str, Union[Option, Shortcut]] = {}
|
||||
o, k, g, all_groups = option_func(all_options, {
|
||||
'colors': [_('Colors')],
|
||||
'diff': [_('Diffing'), ],
|
||||
@@ -121,4 +120,4 @@ k('prev_match', '<', 'scroll_to prev-match', _('Scroll to previous search match'
|
||||
k('search_forward_simple', 'f', 'start_search substring forward', _('Search forward (no regex)'))
|
||||
k('search_backward_simple', 'b', 'start_search substring backward', _('Search backward (no regex)'))
|
||||
|
||||
type_map = {o.name: o.option_type for o in all_options.values() if hasattr(o, 'option_type')}
|
||||
type_map = {o.name: o.option_type for o in all_options.values() if isinstance(o, Option)}
|
||||
|
||||
14
kittens/diff/diff_speedup.pyi
Normal file
14
kittens/diff/diff_speedup.pyi
Normal file
@@ -0,0 +1,14 @@
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
from .collect import Segment
|
||||
|
||||
|
||||
def split_with_highlights(
|
||||
line: str, truncate_points: List[int], fg_highlights: List,
|
||||
bg_highlight: Optional[Segment]
|
||||
) -> List:
|
||||
pass
|
||||
|
||||
|
||||
def changed_center(left_prefix: str, right_postfix: str) -> Tuple[int, int]:
|
||||
pass
|
||||
@@ -6,10 +6,10 @@ import concurrent
|
||||
import os
|
||||
import re
|
||||
|
||||
from pygments import highlight
|
||||
from pygments.formatter import Formatter
|
||||
from pygments.lexers import get_lexer_for_filename
|
||||
from pygments.util import ClassNotFound
|
||||
from pygments import highlight # type: ignore
|
||||
from pygments.formatter import Formatter # type: ignore
|
||||
from pygments.lexers import get_lexer_for_filename # type: ignore
|
||||
from pygments.util import ClassNotFound # type: ignore
|
||||
|
||||
from kitty.rgb import color_as_sgr, parse_sharp
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ def set_line_wrapping(yes_or_no: bool) -> str:
|
||||
|
||||
|
||||
def set_cursor_visible(yes_or_no: bool) -> str:
|
||||
return set_mode('DECTEM') if yes_or_no else reset_mode('DECTCEM')
|
||||
return set_mode('DECTCEM') if yes_or_no else reset_mode('DECTCEM')
|
||||
|
||||
|
||||
def set_cursor_position(x, y) -> str: # (0, 0) is top left
|
||||
|
||||
Reference in New Issue
Block a user