Replace isort with ruff
This commit is contained in:
parent
f15d27bb62
commit
7fe5d7b58f
@ -11,9 +11,8 @@ import sys
|
||||
import tempfile
|
||||
from contextlib import suppress
|
||||
|
||||
from bypy.constants import (
|
||||
LIBDIR, PREFIX, PYTHON, SRC as KITTY_DIR, ismacos, worker_env
|
||||
)
|
||||
from bypy.constants import LIBDIR, PREFIX, PYTHON, ismacos, worker_env
|
||||
from bypy.constants import SRC as KITTY_DIR
|
||||
from bypy.utils import run_shell, walk
|
||||
|
||||
|
||||
|
||||
@ -10,12 +10,8 @@ import subprocess
|
||||
import tarfile
|
||||
import time
|
||||
|
||||
from bypy.constants import (
|
||||
OUTPUT_DIR, PREFIX, is64bit, python_major_minor_version
|
||||
)
|
||||
from bypy.freeze import (
|
||||
extract_extension_modules, freeze_python, path_to_freeze_dir
|
||||
)
|
||||
from bypy.constants import OUTPUT_DIR, PREFIX, is64bit, python_major_minor_version
|
||||
from bypy.freeze import extract_extension_modules, freeze_python, path_to_freeze_dir
|
||||
from bypy.utils import get_dll_path, mkdtemp, py_compile, walk
|
||||
|
||||
j = os.path.join
|
||||
|
||||
@ -13,16 +13,9 @@ import tempfile
|
||||
import zipfile
|
||||
|
||||
from bypy.constants import PREFIX, PYTHON, SW, python_major_minor_version
|
||||
from bypy.freeze import (
|
||||
extract_extension_modules, freeze_python, path_to_freeze_dir
|
||||
)
|
||||
from bypy.macos_sign import (
|
||||
codesign, create_entitlements_file, make_certificate_useable, notarize_app,
|
||||
verify_signature
|
||||
)
|
||||
from bypy.utils import (
|
||||
current_dir, mkdtemp, py_compile, run_shell, timeit, walk
|
||||
)
|
||||
from bypy.freeze import extract_extension_modules, freeze_python, path_to_freeze_dir
|
||||
from bypy.macos_sign import codesign, create_entitlements_file, make_certificate_useable, notarize_app, verify_signature
|
||||
from bypy.utils import current_dir, mkdtemp, py_compile, run_shell, timeit, walk
|
||||
|
||||
iv = globals()['init_env']
|
||||
kitty_constants = iv['kitty_constants']
|
||||
|
||||
12
docs/conf.py
12
docs/conf.py
@ -18,9 +18,7 @@ from typing import Any, Callable, Dict, Iterable, List, Tuple
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst.roles import set_classes
|
||||
from pygments.lexer import RegexLexer, bygroups # type: ignore
|
||||
from pygments.token import ( # type: ignore
|
||||
Comment, Keyword, Literal, Name, Number, String, Whitespace
|
||||
)
|
||||
from pygments.token import Comment, Keyword, Literal, Name, Number, String, Whitespace # type: ignore
|
||||
from sphinx import addnodes, version_info
|
||||
from sphinx.util.logging import getLogger
|
||||
|
||||
@ -215,10 +213,10 @@ def commit_role(
|
||||
|
||||
# CLI docs {{{
|
||||
def write_cli_docs(all_kitten_names: Iterable[str]) -> None:
|
||||
from kitty.cli import option_spec_as_rst
|
||||
from kitty.launch import options_spec as launch_options_spec
|
||||
from kittens.ssh.copy import option_text
|
||||
from kittens.ssh.options.definition import copy_message
|
||||
from kitty.cli import option_spec_as_rst
|
||||
from kitty.launch import options_spec as launch_options_spec
|
||||
with open('generated/ssh-copy.rst', 'w') as f:
|
||||
f.write(option_spec_as_rst(
|
||||
appname='copy', ospec=option_text, heading_char='^',
|
||||
@ -280,9 +278,7 @@ if you specify a program-to-run you can use the special placeholder
|
||||
|
||||
|
||||
def write_remote_control_protocol_docs() -> None: # {{{
|
||||
from kitty.rc.base import (
|
||||
RemoteCommand, all_command_names, command_for_name
|
||||
)
|
||||
from kitty.rc.base import RemoteCommand, all_command_names, command_for_name
|
||||
field_pat = re.compile(r'\s*([^:]+?)\s*:\s*(.+)')
|
||||
|
||||
def format_cmd(p: Callable[..., None], name: str, cmd: RemoteCommand) -> None:
|
||||
|
||||
@ -10,10 +10,7 @@ import termios
|
||||
import time
|
||||
import tty
|
||||
from contextlib import contextmanager
|
||||
from ctypes import (
|
||||
CDLL, POINTER, byref, c_char_p, c_int, c_size_t, c_void_p,
|
||||
create_string_buffer
|
||||
)
|
||||
from ctypes import CDLL, POINTER, byref, c_char_p, c_int, c_size_t, c_void_p, create_string_buffer
|
||||
from ctypes.util import find_library
|
||||
|
||||
_plat = sys.platform.lower()
|
||||
|
||||
@ -14,7 +14,10 @@ import kitty.constants as kc
|
||||
from kittens.tui.operations import Mode
|
||||
from kittens.tui.spinners import spinners
|
||||
from kitty.cli import (
|
||||
CompletionSpec, GoOption, go_options_for_seq, parse_option_spec,
|
||||
CompletionSpec,
|
||||
GoOption,
|
||||
go_options_for_seq,
|
||||
parse_option_spec,
|
||||
serialize_as_go_string,
|
||||
)
|
||||
from kitty.key_encoding import config_mod_map
|
||||
|
||||
@ -12,8 +12,17 @@ from html.entities import html5
|
||||
from itertools import groupby
|
||||
from operator import itemgetter
|
||||
from typing import (
|
||||
Callable, DefaultDict, Dict, FrozenSet, Generator, Iterable, List, Optional, Set,
|
||||
Tuple, Union,
|
||||
Callable,
|
||||
DefaultDict,
|
||||
Dict,
|
||||
FrozenSet,
|
||||
Generator,
|
||||
Iterable,
|
||||
List,
|
||||
Optional,
|
||||
Set,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
from urllib.request import urlopen
|
||||
|
||||
|
||||
@ -8,7 +8,6 @@ import shlex
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
|
||||
cmdline = (
|
||||
'glad --out-path {dest} --api gl:core=3.3 '
|
||||
' --extensions GL_ARB_texture_storage,GL_ARB_copy_image,GL_ARB_multisample,GL_ARB_robustness,GL_KHR_debug '
|
||||
|
||||
@ -6,7 +6,14 @@ import re
|
||||
import sys
|
||||
from contextlib import suppress
|
||||
from typing import (
|
||||
TYPE_CHECKING, Callable, Dict, Iterator, List, NamedTuple, Optional, Tuple,
|
||||
TYPE_CHECKING,
|
||||
Callable,
|
||||
Dict,
|
||||
Iterator,
|
||||
List,
|
||||
NamedTuple,
|
||||
Optional,
|
||||
Tuple,
|
||||
)
|
||||
|
||||
from kitty.cli import parse_args
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
|
||||
def match(
|
||||
lines: List[bytes], levels: Tuple[str, str, str], needle: str,
|
||||
output_positions: bool, limit: int, num_threads: int, mark_before: str,
|
||||
|
||||
@ -6,9 +6,7 @@ from contextlib import suppress
|
||||
from fnmatch import fnmatch
|
||||
from functools import lru_cache
|
||||
from hashlib import md5
|
||||
from typing import (
|
||||
TYPE_CHECKING, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Union
|
||||
)
|
||||
from typing import TYPE_CHECKING, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Union
|
||||
|
||||
from kitty.guess_mime_type import guess_type
|
||||
from kitty.utils import control_codes_pat
|
||||
|
||||
@ -5,13 +5,13 @@ import os
|
||||
from typing import Any, Dict, Iterable, Optional
|
||||
|
||||
from kitty.cli_stub import DiffCLIOptions
|
||||
from kitty.conf.utils import (
|
||||
load_config as _load_config, parse_config_base, resolve_config
|
||||
)
|
||||
from kitty.conf.utils import load_config as _load_config
|
||||
from kitty.conf.utils import parse_config_base, resolve_config
|
||||
from kitty.constants import config_dir
|
||||
from kitty.rgb import color_as_sgr
|
||||
|
||||
from .options.types import Options as DiffOptions, defaults
|
||||
from .options.types import Options as DiffOptions
|
||||
from .options.types import defaults
|
||||
|
||||
formats: Dict[str, str] = {
|
||||
'title': '',
|
||||
@ -41,9 +41,7 @@ defconf = os.path.join(config_dir, 'diff.conf')
|
||||
|
||||
|
||||
def load_config(*paths: str, overrides: Optional[Iterable[str]] = None) -> DiffOptions:
|
||||
from .options.parse import (
|
||||
create_result_dict, merge_result_dicts, parse_conf_item
|
||||
)
|
||||
from .options.parse import create_result_dict, merge_result_dicts, parse_conf_item
|
||||
|
||||
def parse_config(lines: Iterable[str]) -> Dict[str, Any]:
|
||||
ans: Dict[str, Any] = create_result_dict()
|
||||
|
||||
@ -2,7 +2,6 @@ from typing import List, Optional, Tuple
|
||||
|
||||
from .collect import Segment
|
||||
|
||||
|
||||
def split_with_highlights(
|
||||
line: str, truncate_points: List[int], fg_highlights: List[Segment],
|
||||
bg_highlight: Optional[Segment]
|
||||
|
||||
@ -5,9 +5,7 @@ import concurrent
|
||||
import os
|
||||
import re
|
||||
from concurrent.futures import ProcessPoolExecutor
|
||||
from typing import (
|
||||
IO, Dict, Iterable, Iterator, List, Optional, Tuple, Union, cast
|
||||
)
|
||||
from typing import IO, Dict, Iterable, Iterator, List, Optional, Tuple, Union, cast
|
||||
|
||||
from pygments import highlight # type: ignore
|
||||
from pygments.formatter import Formatter # type: ignore
|
||||
|
||||
@ -14,7 +14,15 @@ from enum import Enum, auto
|
||||
from functools import partial
|
||||
from gettext import gettext as _
|
||||
from typing import (
|
||||
Any, DefaultDict, Dict, Iterable, Iterator, List, Optional, Tuple, Union,
|
||||
Any,
|
||||
DefaultDict,
|
||||
Dict,
|
||||
Iterable,
|
||||
Iterator,
|
||||
List,
|
||||
Optional,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
|
||||
from kitty.cli import CONFIG_HELP, CompletionSpec, parse_args
|
||||
@ -32,20 +40,32 @@ from ..tui.loop import Loop
|
||||
from ..tui.operations import styled
|
||||
from . import global_data
|
||||
from .collect import (
|
||||
Collection, add_remote_dir, create_collection, data_for_path, lines_for_path,
|
||||
sanitize, set_highlight_data,
|
||||
Collection,
|
||||
add_remote_dir,
|
||||
create_collection,
|
||||
data_for_path,
|
||||
lines_for_path,
|
||||
sanitize,
|
||||
set_highlight_data,
|
||||
)
|
||||
from .config import init_config
|
||||
from .options.types import Options as DiffOptions
|
||||
from .patch import Differ, Patch, set_diff_command, worker_processes
|
||||
from .render import (
|
||||
ImagePlacement, ImageSupportWarning, Line, LineRef, Reference, render_diff,
|
||||
ImagePlacement,
|
||||
ImageSupportWarning,
|
||||
Line,
|
||||
LineRef,
|
||||
Reference,
|
||||
render_diff,
|
||||
)
|
||||
from .search import BadRegex, Search
|
||||
|
||||
try:
|
||||
from .highlight import (
|
||||
DiffHighlight, get_highlight_processes, highlight_collection,
|
||||
DiffHighlight,
|
||||
get_highlight_processes,
|
||||
highlight_collection,
|
||||
initialize_highlighter,
|
||||
)
|
||||
has_highlighter = True
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
|
||||
from kitty.conf.types import Action, Definition
|
||||
|
||||
|
||||
definition = Definition(
|
||||
'kittens.diff',
|
||||
Action('map', 'parse_map', {'key_definitions': 'kitty.conf.utils.KittensKeyMap'}, ['kitty.types.ParsedShortcut', 'kitty.conf.utils.KeyAction']),
|
||||
|
||||
1
kittens/diff/options/parse.py
generated
1
kittens/diff/options/parse.py
generated
@ -1,6 +1,7 @@
|
||||
# generated by gen-config.py DO NOT edit
|
||||
|
||||
import typing
|
||||
|
||||
from kittens.diff.options.utils import parse_map, store_multiple, syntax_aliases
|
||||
from kitty.conf.utils import merge_dicts, positive_int, python_string, to_color, to_color_or_none
|
||||
|
||||
|
||||
@ -5,9 +5,7 @@
|
||||
|
||||
from typing import Any, Container, Dict, Iterable, Tuple, Union
|
||||
|
||||
from kitty.conf.utils import (
|
||||
KeyFuncWrapper, KittensKeyDefinition, parse_kittens_key
|
||||
)
|
||||
from kitty.conf.utils import KeyFuncWrapper, KittensKeyDefinition, parse_kittens_key
|
||||
|
||||
ReturnType = Tuple[str, Any]
|
||||
func_with_args = KeyFuncWrapper[ReturnType]()
|
||||
|
||||
@ -13,10 +13,7 @@ from kitty.types import run_once
|
||||
from kitty.utils import ScreenSize
|
||||
|
||||
from ..tui.images import ImageManager, can_display_images
|
||||
from .collect import (
|
||||
Collection, Segment, data_for_path, highlights_for_path, is_image,
|
||||
lines_for_path, path_name_map, sanitize
|
||||
)
|
||||
from .collect import Collection, Segment, data_for_path, highlights_for_path, is_image, lines_for_path, path_name_map, sanitize
|
||||
from .config import formats
|
||||
from .diff_speedup import split_with_highlights as _split_with_highlights
|
||||
from .patch import Chunk, Hunk, Patch
|
||||
|
||||
@ -5,9 +5,9 @@ import re
|
||||
from typing import TYPE_CHECKING, Callable, Dict, Iterable, List, Tuple
|
||||
|
||||
from kitty.fast_data_types import wcswidth
|
||||
from .options.types import Options as DiffOptions
|
||||
|
||||
from ..tui.operations import styled
|
||||
from .options.types import Options as DiffOptions
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .render import Line
|
||||
|
||||
@ -8,10 +8,7 @@ import sys
|
||||
from functools import lru_cache
|
||||
from gettext import gettext as _
|
||||
from itertools import repeat
|
||||
from typing import (
|
||||
Any, Callable, Dict, Generator, Iterable, Iterator, List, Optional,
|
||||
Pattern, Sequence, Set, Tuple, Type, cast
|
||||
)
|
||||
from typing import Any, Callable, Dict, Generator, Iterable, Iterator, List, Optional, Pattern, Sequence, Set, Tuple, Type, cast
|
||||
|
||||
from kitty.cli import parse_args
|
||||
from kitty.cli_stub import HintsCLIOptions
|
||||
@ -20,10 +17,7 @@ from kitty.constants import website_url
|
||||
from kitty.fast_data_types import get_options, wcswidth
|
||||
from kitty.key_encoding import KeyEvent
|
||||
from kitty.typing import BossType, KittyCommonOpts
|
||||
from kitty.utils import (
|
||||
ScreenSize, kitty_ansi_sanitizer_pat, resolve_custom_file,
|
||||
screen_size_function
|
||||
)
|
||||
from kitty.utils import ScreenSize, kitty_ansi_sanitizer_pat, resolve_custom_file, screen_size_function
|
||||
|
||||
from ..tui.handler import Handler, result_handler
|
||||
from ..tui.loop import Loop
|
||||
|
||||
@ -137,6 +137,7 @@ if __name__ == '__main__':
|
||||
raise SystemExit('This should be run as kitty-tool icat')
|
||||
elif __name__ == '__doc__':
|
||||
import sys
|
||||
|
||||
from kitty.cli import CompletionSpec
|
||||
cd = sys.cli_docs # type: ignore
|
||||
cd['usage'] = usage
|
||||
|
||||
@ -8,8 +8,8 @@ from typing import Any, Callable, Dict, List, Tuple
|
||||
from kitty.cli import parse_args
|
||||
from kitty.cli_stub import PanelCLIOptions
|
||||
from kitty.constants import appname, is_macos
|
||||
from kitty.os_window_size import WindowSizeData
|
||||
from kitty.fast_data_types import make_x11_window_a_dock_window
|
||||
from kitty.os_window_size import WindowSizeData
|
||||
|
||||
OPTIONS = r'''
|
||||
--lines
|
||||
@ -134,7 +134,8 @@ def main(sys_args: List[str]) -> None:
|
||||
for override in args.override:
|
||||
sys.argv.extend(('--override', override))
|
||||
sys.argv.extend(items)
|
||||
from kitty.main import main as real_main, run_app
|
||||
from kitty.main import main as real_main
|
||||
from kitty.main import run_app
|
||||
run_app.cached_values_name = 'panel'
|
||||
run_app.first_window_callback = setup_x11_window
|
||||
run_app.initial_window_size_func = initial_window_size_func
|
||||
|
||||
@ -5,7 +5,7 @@ import re
|
||||
import sys
|
||||
from binascii import hexlify, unhexlify
|
||||
from contextlib import suppress
|
||||
from typing import Dict, Iterable, List, Type, Optional
|
||||
from typing import Dict, Iterable, List, Optional, Type
|
||||
|
||||
from kitty.cli import parse_args
|
||||
from kitty.cli_stub import QueryTerminalCLIOptions
|
||||
|
||||
@ -16,17 +16,12 @@ from kitty.cli import parse_args
|
||||
from kitty.cli_stub import RemoteFileCLIOptions
|
||||
from kitty.constants import cache_dir
|
||||
from kitty.typing import BossType
|
||||
from kitty.utils import (
|
||||
SSHConnectionData, command_for_open, get_editor, open_cmd
|
||||
)
|
||||
from kitty.utils import SSHConnectionData, command_for_open, get_editor, open_cmd
|
||||
|
||||
from ..tui.handler import result_handler
|
||||
from ..tui.operations import (
|
||||
faint, raw_mode, reset_terminal, styled
|
||||
)
|
||||
from ..tui.operations import faint, raw_mode, reset_terminal, styled
|
||||
from ..tui.utils import get_key_press
|
||||
|
||||
|
||||
is_ssh_kitten_sentinel = '!#*&$#($ssh-kitten)(##$'
|
||||
|
||||
|
||||
|
||||
@ -93,8 +93,8 @@ def launch(args: List[str]) -> None:
|
||||
finally:
|
||||
sys.stdin = sys.__stdin__
|
||||
if result is not None:
|
||||
import json
|
||||
import base64
|
||||
import json
|
||||
data = base64.b85encode(json.dumps(result).encode('utf-8'))
|
||||
sys.stdout.buffer.write(b'\x1bP@kitty-kitten-result|')
|
||||
sys.stdout.buffer.write(data)
|
||||
|
||||
@ -33,6 +33,7 @@ def real_main(args: List[str]) -> None:
|
||||
print(error_message, flush=True)
|
||||
if data.get('tb'):
|
||||
import select
|
||||
|
||||
from kittens.tui.operations import init_state, set_cursor_visible
|
||||
fd, original_termios = open_tty()
|
||||
msg = '\n\r\x1b[1;32mPress e to see detailed traceback or any other key to exit\x1b[m'
|
||||
|
||||
@ -1,13 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
from kitty.key_encoding import (
|
||||
ALT, CAPS_LOCK, CTRL, HYPER, META, NUM_LOCK, PRESS, RELEASE, REPEAT, SHIFT,
|
||||
SUPER, KeyEvent, encode_key_event
|
||||
)
|
||||
|
||||
from kittens.tui.handler import Handler
|
||||
from kittens.tui.loop import Loop
|
||||
from kitty.key_encoding import ALT, CAPS_LOCK, CTRL, HYPER, META, NUM_LOCK, PRESS, RELEASE, REPEAT, SHIFT, SUPER, KeyEvent, encode_key_event
|
||||
|
||||
mod_names = {
|
||||
SHIFT: 'Shift',
|
||||
|
||||
@ -6,9 +6,9 @@ import os
|
||||
import sys
|
||||
from typing import List
|
||||
|
||||
from kittens.tui.operations import raw_mode, styled
|
||||
from kitty.cli import parse_args
|
||||
from kitty.cli_stub import ShowKeyCLIOptions
|
||||
from kittens.tui.operations import raw_mode, styled
|
||||
|
||||
ctrl_keys = '@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_'
|
||||
|
||||
|
||||
@ -6,12 +6,12 @@ import fnmatch
|
||||
import os
|
||||
from typing import Any, Dict, Iterable, Optional
|
||||
|
||||
from kitty.conf.utils import (
|
||||
load_config as _load_config, parse_config_base, resolve_config
|
||||
)
|
||||
from kitty.conf.utils import load_config as _load_config
|
||||
from kitty.conf.utils import parse_config_base, resolve_config
|
||||
from kitty.constants import config_dir
|
||||
|
||||
from .options.types import Options as SSHOptions, defaults
|
||||
from .options.types import Options as SSHOptions
|
||||
from .options.types import defaults
|
||||
|
||||
SYSTEM_CONF = '/etc/xdg/kitty/ssh.conf'
|
||||
defconf = os.path.join(config_dir, 'ssh.conf')
|
||||
@ -28,12 +28,8 @@ def host_matches(mpat: str, hostname: str, username: str) -> bool:
|
||||
|
||||
|
||||
def load_config(*paths: str, overrides: Optional[Iterable[str]] = None, hostname: str = '!', username: str = '') -> SSHOptions:
|
||||
from .options.parse import (
|
||||
create_result_dict, merge_result_dicts, parse_conf_item
|
||||
)
|
||||
from .options.utils import (
|
||||
first_seen_positions, get_per_hosts_dict, init_results_dict
|
||||
)
|
||||
from .options.parse import create_result_dict, merge_result_dicts, parse_conf_item
|
||||
from .options.utils import first_seen_positions, get_per_hosts_dict, init_results_dict
|
||||
|
||||
def merge_dicts(base: Dict[str, Any], vals: Dict[str, Any]) -> Dict[str, Any]:
|
||||
base_phd = get_per_hosts_dict(base)
|
||||
|
||||
@ -6,9 +6,7 @@ import glob
|
||||
import os
|
||||
import shlex
|
||||
import uuid
|
||||
from typing import (
|
||||
Dict, Iterable, Iterator, List, NamedTuple, Optional, Sequence, Tuple
|
||||
)
|
||||
from typing import Dict, Iterable, Iterator, List, NamedTuple, Optional, Sequence, Tuple
|
||||
|
||||
from kitty.cli import parse_args
|
||||
from kitty.cli_stub import CopyCLIOptions
|
||||
|
||||
@ -22,27 +22,16 @@ from base64 import standard_b64decode, standard_b64encode
|
||||
from contextlib import contextmanager, suppress
|
||||
from getpass import getuser
|
||||
from select import select
|
||||
from typing import (
|
||||
Any, Callable, Dict, Iterator, List, NoReturn, Optional, Sequence, Set,
|
||||
Tuple, Union, cast
|
||||
)
|
||||
from typing import Any, Callable, Dict, Iterator, List, NoReturn, Optional, Sequence, Set, Tuple, Union, cast
|
||||
|
||||
from kitty.constants import (
|
||||
cache_dir, runtime_dir, shell_integration_dir, ssh_control_master_template,
|
||||
str_version, terminfo_dir
|
||||
)
|
||||
from kitty.constants import cache_dir, runtime_dir, shell_integration_dir, ssh_control_master_template, str_version, terminfo_dir
|
||||
from kitty.shell_integration import as_str_literal
|
||||
from kitty.shm import SharedMemory
|
||||
from kitty.types import run_once
|
||||
from kitty.utils import (
|
||||
SSHConnectionData, expandvars, resolve_abs_or_config_path,
|
||||
set_echo as turn_off_echo
|
||||
)
|
||||
from kitty.utils import SSHConnectionData, expandvars, resolve_abs_or_config_path
|
||||
from kitty.utils import set_echo as turn_off_echo
|
||||
|
||||
from ..tui.operations import (
|
||||
RESTORE_PRIVATE_MODE_VALUES, SAVE_PRIVATE_MODE_VALUES, Mode,
|
||||
restore_colors, save_colors, set_mode
|
||||
)
|
||||
from ..tui.operations import RESTORE_PRIVATE_MODE_VALUES, SAVE_PRIVATE_MODE_VALUES, Mode, restore_colors, save_colors, set_mode
|
||||
from ..tui.utils import kitty_opts, running_in_tmux
|
||||
from .config import init_config
|
||||
from .copy import CopyInstruction
|
||||
@ -624,9 +613,7 @@ def drain_potential_tty_garbage(p: 'subprocess.Popen[bytes]', data_request: str)
|
||||
def change_colors(color_scheme: str) -> bool:
|
||||
if not color_scheme:
|
||||
return False
|
||||
from kittens.themes.collection import (
|
||||
NoCacheFound, load_themes, text_as_opts
|
||||
)
|
||||
from kittens.themes.collection import NoCacheFound, load_themes, text_as_opts
|
||||
from kittens.themes.main import colors_as_escape_codes
|
||||
if color_scheme.endswith('.conf'):
|
||||
conf_file = resolve_abs_or_config_path(color_scheme)
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
|
||||
from kitty.conf.types import Definition
|
||||
|
||||
|
||||
copy_message = '''\
|
||||
Copy files and directories from local to remote hosts. The specified files are
|
||||
assumed to be relative to the HOME directory and copied to the HOME on the
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# generated by gen-config.py DO NOT edit
|
||||
|
||||
import typing
|
||||
|
||||
from kittens.ssh.options.utils import copy, env, hostname
|
||||
from kitty.conf.utils import merge_dicts, to_bool
|
||||
|
||||
|
||||
@ -12,9 +12,7 @@ import sys
|
||||
import tempfile
|
||||
import zipfile
|
||||
from contextlib import suppress
|
||||
from typing import (
|
||||
Any, Callable, Dict, Iterator, Match, Optional, Tuple, Type, Union
|
||||
)
|
||||
from typing import Any, Callable, Dict, Iterator, Match, Optional, Tuple, Type, Union
|
||||
from urllib.error import HTTPError
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
|
||||
@ -7,9 +7,7 @@ import sys
|
||||
import traceback
|
||||
from enum import Enum, auto
|
||||
from gettext import gettext as _
|
||||
from typing import (
|
||||
Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union
|
||||
)
|
||||
from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union
|
||||
|
||||
from kitty.cli import CompletionSpec, create_default_opts, parse_args
|
||||
from kitty.cli_stub import ThemesCLIOptions
|
||||
|
||||
@ -5,10 +5,7 @@ import os
|
||||
import tempfile
|
||||
from typing import IO, TYPE_CHECKING, Iterator, Union
|
||||
|
||||
from .rsync import (
|
||||
IO_BUFFER_SIZE, RsyncError, begin_create_delta, begin_create_signature,
|
||||
begin_load_signature, begin_patch, build_hash_table, iter_job
|
||||
)
|
||||
from .rsync import IO_BUFFER_SIZE, RsyncError, begin_create_delta, begin_create_signature, begin_load_signature, begin_patch, build_hash_table, iter_job
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .rsync import JobCapsule, SignatureCapsule
|
||||
|
||||
@ -12,7 +12,6 @@ from kitty.cli_stub import TransferCLIOptions
|
||||
from .receive import receive_main
|
||||
from .send import send_main
|
||||
|
||||
|
||||
usage = 'source_files_or_directories destination_path'
|
||||
help_text = 'Transfer files over the TTY device'
|
||||
|
||||
|
||||
@ -14,9 +14,16 @@ from typing import IO, Deque, Dict, Iterator, List, Optional, Union
|
||||
from kitty.cli_stub import TransferCLIOptions
|
||||
from kitty.fast_data_types import FILE_TRANSFER_CODE, wcswidth
|
||||
from kitty.file_transmission import (
|
||||
Action, Compression, FileTransmissionCommand, FileType,
|
||||
IdentityDecompressor, NameReprEnum, TransmissionType, ZlibDecompressor,
|
||||
encode_bypass, split_for_transfer
|
||||
Action,
|
||||
Compression,
|
||||
FileTransmissionCommand,
|
||||
FileType,
|
||||
IdentityDecompressor,
|
||||
NameReprEnum,
|
||||
TransmissionType,
|
||||
ZlibDecompressor,
|
||||
encode_bypass,
|
||||
split_for_transfer,
|
||||
)
|
||||
from kitty.typing import KeyEventType, ScreenSize
|
||||
from kitty.utils import sanitize_control_codes
|
||||
@ -28,10 +35,7 @@ from ..tui.spinners import Spinner
|
||||
from ..tui.utils import human_size
|
||||
from .librsync import PatchFile, signature_of_file
|
||||
from .send import Transfer
|
||||
from .utils import (
|
||||
expand_home, print_rsync_stats, random_id, render_progress_in_width,
|
||||
safe_divide, should_be_compressed
|
||||
)
|
||||
from .utils import expand_home, print_rsync_stats, random_id, render_progress_in_width, safe_divide, should_be_compressed
|
||||
|
||||
debug
|
||||
file_counter = count(1)
|
||||
|
||||
@ -9,17 +9,11 @@ from collections import deque
|
||||
from enum import auto
|
||||
from itertools import count
|
||||
from time import monotonic
|
||||
from typing import (
|
||||
IO, Callable, Deque, Dict, Iterable, Iterator, List, Optional, Sequence,
|
||||
Set, Tuple, Union
|
||||
)
|
||||
from typing import IO, Callable, Deque, Dict, Iterable, Iterator, List, Optional, Sequence, Set, Tuple, Union
|
||||
|
||||
from kitty.cli_stub import TransferCLIOptions
|
||||
from kitty.fast_data_types import FILE_TRANSFER_CODE, wcswidth
|
||||
from kitty.file_transmission import (
|
||||
Action, Compression, FileTransmissionCommand, FileType, NameReprEnum,
|
||||
TransmissionType, encode_bypass, split_for_transfer
|
||||
)
|
||||
from kitty.file_transmission import Action, Compression, FileTransmissionCommand, FileType, NameReprEnum, TransmissionType, encode_bypass, split_for_transfer
|
||||
from kitty.typing import KeyEventType, ScreenSize
|
||||
from kitty.utils import sanitize_control_codes
|
||||
|
||||
@ -30,9 +24,16 @@ from ..tui.spinners import Spinner
|
||||
from ..tui.utils import human_size
|
||||
from .librsync import LoadSignature, delta_for_file
|
||||
from .utils import (
|
||||
IdentityCompressor, ZlibCompressor, abspath, expand_home, home_path,
|
||||
print_rsync_stats, random_id, render_progress_in_width, safe_divide,
|
||||
should_be_compressed
|
||||
IdentityCompressor,
|
||||
ZlibCompressor,
|
||||
abspath,
|
||||
expand_home,
|
||||
home_path,
|
||||
print_rsync_stats,
|
||||
random_id,
|
||||
render_progress_in_width,
|
||||
safe_divide,
|
||||
should_be_compressed,
|
||||
)
|
||||
|
||||
debug
|
||||
|
||||
@ -6,16 +6,21 @@ from collections import deque
|
||||
from contextlib import suppress
|
||||
from time import monotonic
|
||||
from types import TracebackType
|
||||
from typing import (
|
||||
TYPE_CHECKING, Any, Callable, ContextManager, Deque, Dict, NamedTuple,
|
||||
Optional, Sequence, Type, Union, cast
|
||||
)
|
||||
from typing import TYPE_CHECKING, Any, Callable, ContextManager, Deque, Dict, NamedTuple, Optional, Sequence, Type, Union, cast
|
||||
|
||||
from kitty.types import DecoratedFunc, ParsedShortcut
|
||||
from kitty.typing import (
|
||||
AbstractEventLoop, BossType, Debug, ImageManagerType, KeyActionType,
|
||||
KeyEventType, LoopType, MouseButton, MouseEvent, ScreenSize,
|
||||
TermManagerType
|
||||
AbstractEventLoop,
|
||||
BossType,
|
||||
Debug,
|
||||
ImageManagerType,
|
||||
KeyActionType,
|
||||
KeyEventType,
|
||||
LoopType,
|
||||
MouseButton,
|
||||
MouseEvent,
|
||||
ScreenSize,
|
||||
TermManagerType,
|
||||
)
|
||||
|
||||
from .operations import MouseTracking, pending_update
|
||||
|
||||
@ -9,17 +9,11 @@ from collections import defaultdict, deque
|
||||
from contextlib import suppress
|
||||
from enum import IntEnum
|
||||
from itertools import count
|
||||
from typing import (
|
||||
Any, Callable, ClassVar, DefaultDict, Deque, Dict, Generic, Iterator, List,
|
||||
Optional, Sequence, Tuple, Type, TypeVar, Union, cast
|
||||
)
|
||||
from typing import Any, Callable, ClassVar, DefaultDict, Deque, Dict, Generic, Iterator, List, Optional, Sequence, Tuple, Type, TypeVar, Union, cast
|
||||
|
||||
from kitty.conf.utils import positive_float, positive_int
|
||||
from kitty.fast_data_types import create_canvas
|
||||
from kitty.typing import (
|
||||
GRT_C, CompletedProcess, GRT_a, GRT_d, GRT_f, GRT_m, GRT_o, GRT_t,
|
||||
HandlerType
|
||||
)
|
||||
from kitty.typing import GRT_C, CompletedProcess, GRT_a, GRT_d, GRT_f, GRT_m, GRT_o, GRT_t, HandlerType
|
||||
from kitty.utils import ScreenSize, fit_image, which
|
||||
|
||||
from .operations import cursor
|
||||
|
||||
@ -6,9 +6,7 @@ from typing import Callable, Tuple
|
||||
from kitty.fast_data_types import truncate_point_for_length, wcswidth
|
||||
from kitty.key_encoding import EventType, KeyEvent
|
||||
|
||||
from .operations import (
|
||||
RESTORE_CURSOR, SAVE_CURSOR, move_cursor_by, set_cursor_shape
|
||||
)
|
||||
from .operations import RESTORE_CURSOR, SAVE_CURSOR, move_cursor_by, set_cursor_shape
|
||||
|
||||
|
||||
class LineEdit:
|
||||
|
||||
@ -16,17 +16,10 @@ from functools import partial
|
||||
from typing import Any, Callable, Dict, Generator, List, NamedTuple, Optional
|
||||
|
||||
from kitty.constants import is_macos
|
||||
from kitty.fast_data_types import (
|
||||
FILE_TRANSFER_CODE, close_tty, normal_tty, open_tty,
|
||||
parse_input_from_terminal, raw_tty
|
||||
)
|
||||
from kitty.key_encoding import (
|
||||
ALT, CTRL, SHIFT, backspace_key, decode_key_event, enter_key
|
||||
)
|
||||
from kitty.fast_data_types import FILE_TRANSFER_CODE, close_tty, normal_tty, open_tty, parse_input_from_terminal, raw_tty
|
||||
from kitty.key_encoding import ALT, CTRL, SHIFT, backspace_key, decode_key_event, enter_key
|
||||
from kitty.typing import ImageManagerType, KeyEventType, Protocol
|
||||
from kitty.utils import (
|
||||
ScreenSize, ScreenSizeGetter, screen_size_function, write_all
|
||||
)
|
||||
from kitty.utils import ScreenSize, ScreenSizeGetter, screen_size_function, write_all
|
||||
|
||||
from .handler import Handler
|
||||
from .operations import MouseTracking, init_state, reset_state
|
||||
|
||||
@ -9,9 +9,7 @@ from typing import IO, Any, Callable, Dict, Generator, Optional, TypeVar, Union
|
||||
|
||||
from kitty.fast_data_types import Color
|
||||
from kitty.rgb import color_as_sharp, to_color
|
||||
from kitty.typing import (
|
||||
GraphicsCommandType, HandlerType, ScreenSize, UnderlineLiteral
|
||||
)
|
||||
from kitty.typing import GraphicsCommandType, HandlerType, ScreenSize, UnderlineLiteral
|
||||
|
||||
from .operations_stub import CMD
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
from .operations import styled, repeat
|
||||
from .operations import repeat, styled
|
||||
|
||||
|
||||
def render_progress_bar(frac: float, width: int = 80) -> str:
|
||||
|
||||
@ -7,10 +7,7 @@ import sys
|
||||
from contextlib import suppress
|
||||
from functools import lru_cache
|
||||
from gettext import gettext as _
|
||||
from typing import (
|
||||
Any, Dict, FrozenSet, Generator, Iterable, List, Optional, Sequence, Tuple,
|
||||
Union
|
||||
)
|
||||
from typing import Any, Dict, FrozenSet, Generator, Iterable, List, Optional, Sequence, Tuple, Union
|
||||
|
||||
from kitty.cli import parse_args
|
||||
from kitty.cli_stub import UnicodeCLIOptions
|
||||
@ -24,10 +21,7 @@ from kitty.utils import ScreenSize, get_editor
|
||||
from ..tui.handler import Handler, result_handler
|
||||
from ..tui.line_edit import LineEdit
|
||||
from ..tui.loop import Loop
|
||||
from ..tui.operations import (
|
||||
clear_screen, colored, cursor, faint, set_line_wrapping, set_window_title,
|
||||
sgr, styled
|
||||
)
|
||||
from ..tui.operations import clear_screen, colored, cursor, faint, set_line_wrapping, set_window_title, sgr, styled
|
||||
from ..tui.utils import report_unhandled_error
|
||||
|
||||
HEX, NAME, EMOTICONS, FAVORITES = 'HEX', 'NAME', 'EMOTICONS', 'FAVORITES'
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
from typing import Tuple, FrozenSet, Optional
|
||||
|
||||
from typing import FrozenSet, Optional, Tuple
|
||||
|
||||
def all_words() -> Tuple[str, ...]:
|
||||
pass
|
||||
|
||||
@ -2,12 +2,9 @@
|
||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
from enum import IntFlag
|
||||
from typing import Iterable, Sequence, NamedTuple
|
||||
from typing import Iterable, NamedTuple, Sequence
|
||||
|
||||
from .fast_data_types import (
|
||||
BORDERS_PROGRAM, add_borders_rect, compile_program, get_options,
|
||||
init_borders_program, os_window_has_background_image
|
||||
)
|
||||
from .fast_data_types import BORDERS_PROGRAM, add_borders_rect, compile_program, get_options, init_borders_program, os_window_has_background_image
|
||||
from .typing import LayoutType
|
||||
from .utils import load_shaders
|
||||
from .window_list import WindowGroup, WindowList
|
||||
|
||||
128
kitty/boss.py
128
kitty/boss.py
@ -12,8 +12,18 @@ from functools import partial
|
||||
from gettext import gettext as _
|
||||
from time import monotonic, sleep
|
||||
from typing import (
|
||||
TYPE_CHECKING, Any, Callable, Container, Dict, Iterable, Iterator, List, Optional,
|
||||
Set, Tuple, Union,
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
Callable,
|
||||
Container,
|
||||
Dict,
|
||||
Iterable,
|
||||
Iterator,
|
||||
List,
|
||||
Optional,
|
||||
Set,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
from weakref import WeakValueDictionary
|
||||
|
||||
@ -21,31 +31,85 @@ from .child import cached_process_data, default_env, set_default_env
|
||||
from .cli import create_opts, parse_args
|
||||
from .cli_stub import CLIOptions
|
||||
from .clipboard import (
|
||||
Clipboard, ClipboardType, get_clipboard_string, get_primary_selection,
|
||||
set_clipboard_string, set_primary_selection,
|
||||
Clipboard,
|
||||
ClipboardType,
|
||||
get_clipboard_string,
|
||||
get_primary_selection,
|
||||
set_clipboard_string,
|
||||
set_primary_selection,
|
||||
)
|
||||
from .conf.utils import BadLine, KeyAction, to_cmdline
|
||||
from .config import common_opts_as_dict, prepare_config_file_for_editing
|
||||
from .constants import (
|
||||
RC_ENCRYPTION_PROTOCOL_VERSION, appname, cache_dir, clear_handled_signals,
|
||||
config_dir, handled_signals, is_macos, is_wayland, kitty_exe, logo_png_file,
|
||||
supports_primary_selection, website_url,
|
||||
RC_ENCRYPTION_PROTOCOL_VERSION,
|
||||
appname,
|
||||
cache_dir,
|
||||
clear_handled_signals,
|
||||
config_dir,
|
||||
handled_signals,
|
||||
is_macos,
|
||||
is_wayland,
|
||||
kitty_exe,
|
||||
logo_png_file,
|
||||
supports_primary_selection,
|
||||
website_url,
|
||||
)
|
||||
from .fast_data_types import (
|
||||
CLOSE_BEING_CONFIRMED, GLFW_MOD_ALT, GLFW_MOD_CONTROL, GLFW_MOD_SHIFT,
|
||||
GLFW_MOD_SUPER, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, GLFW_RELEASE, IMPERATIVE_CLOSE_REQUESTED,
|
||||
NO_CLOSE_REQUESTED, ChildMonitor, Color, EllipticCurveKey, KeyEvent, SingleKey,
|
||||
add_timer, apply_options_update, background_opacity_of, change_background_opacity,
|
||||
change_os_window_state, cocoa_hide_app, cocoa_hide_other_apps,
|
||||
cocoa_minimize_os_window, cocoa_set_menubar_title, create_os_window,
|
||||
current_application_quit_request, current_focused_os_window_id, current_os_window,
|
||||
destroy_global_data, focus_os_window, get_boss, get_options, get_os_window_size,
|
||||
is_modifier_key, global_font_size, last_focused_os_window_id, mark_os_window_for_close,
|
||||
os_window_font_size, patch_global_colors, redirect_mouse_handling, ring_bell,
|
||||
run_with_activation_token, safe_pipe, send_data_to_peer,
|
||||
set_application_quit_request, set_background_image, set_boss, set_in_sequence_mode,
|
||||
set_options, set_os_window_size, set_os_window_title, thread_write,
|
||||
toggle_fullscreen, toggle_maximized, toggle_secure_input,
|
||||
CLOSE_BEING_CONFIRMED,
|
||||
GLFW_MOD_ALT,
|
||||
GLFW_MOD_CONTROL,
|
||||
GLFW_MOD_SHIFT,
|
||||
GLFW_MOD_SUPER,
|
||||
GLFW_MOUSE_BUTTON_LEFT,
|
||||
GLFW_PRESS,
|
||||
GLFW_RELEASE,
|
||||
IMPERATIVE_CLOSE_REQUESTED,
|
||||
NO_CLOSE_REQUESTED,
|
||||
ChildMonitor,
|
||||
Color,
|
||||
EllipticCurveKey,
|
||||
KeyEvent,
|
||||
SingleKey,
|
||||
add_timer,
|
||||
apply_options_update,
|
||||
background_opacity_of,
|
||||
change_background_opacity,
|
||||
change_os_window_state,
|
||||
cocoa_hide_app,
|
||||
cocoa_hide_other_apps,
|
||||
cocoa_minimize_os_window,
|
||||
cocoa_set_menubar_title,
|
||||
create_os_window,
|
||||
current_application_quit_request,
|
||||
current_focused_os_window_id,
|
||||
current_os_window,
|
||||
destroy_global_data,
|
||||
focus_os_window,
|
||||
get_boss,
|
||||
get_options,
|
||||
get_os_window_size,
|
||||
global_font_size,
|
||||
is_modifier_key,
|
||||
last_focused_os_window_id,
|
||||
mark_os_window_for_close,
|
||||
os_window_font_size,
|
||||
patch_global_colors,
|
||||
redirect_mouse_handling,
|
||||
ring_bell,
|
||||
run_with_activation_token,
|
||||
safe_pipe,
|
||||
send_data_to_peer,
|
||||
set_application_quit_request,
|
||||
set_background_image,
|
||||
set_boss,
|
||||
set_in_sequence_mode,
|
||||
set_options,
|
||||
set_os_window_size,
|
||||
set_os_window_title,
|
||||
thread_write,
|
||||
toggle_fullscreen,
|
||||
toggle_maximized,
|
||||
toggle_secure_input,
|
||||
)
|
||||
from .key_encoding import get_name_to_functional_number_map
|
||||
from .keys import get_shortcut, shortcut_matches
|
||||
@ -61,10 +125,24 @@ from .tabs import SpecialWindow, SpecialWindowInstance, Tab, TabDict, TabManager
|
||||
from .types import _T, AsyncResponse, WindowSystemMouseEvent, ac
|
||||
from .typing import PopenType, TypedDict
|
||||
from .utils import (
|
||||
cleanup_ssh_control_masters, func_name, get_editor, get_new_os_window_size,
|
||||
is_path_in_temp_dir, less_version, log_error, macos_version, open_url,
|
||||
parse_address_spec, parse_uri_list, platform_window_id, remove_socket_file,
|
||||
safe_print, single_instance, startup_notification_handler, which, sanitize_url_for_dispay_to_user
|
||||
cleanup_ssh_control_masters,
|
||||
func_name,
|
||||
get_editor,
|
||||
get_new_os_window_size,
|
||||
is_path_in_temp_dir,
|
||||
less_version,
|
||||
log_error,
|
||||
macos_version,
|
||||
open_url,
|
||||
parse_address_spec,
|
||||
parse_uri_list,
|
||||
platform_window_id,
|
||||
remove_socket_file,
|
||||
safe_print,
|
||||
sanitize_url_for_dispay_to_user,
|
||||
single_instance,
|
||||
startup_notification_handler,
|
||||
which,
|
||||
)
|
||||
from .window import CommandOutput, CwdRequest, Window
|
||||
|
||||
|
||||
@ -5,17 +5,11 @@ import os
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
from contextlib import contextmanager, suppress
|
||||
from typing import (
|
||||
TYPE_CHECKING, DefaultDict, Dict, Generator, List, Optional, Sequence,
|
||||
Tuple
|
||||
)
|
||||
from typing import TYPE_CHECKING, DefaultDict, Dict, Generator, List, Optional, Sequence, Tuple
|
||||
|
||||
import kitty.fast_data_types as fast_data_types
|
||||
|
||||
from .constants import (
|
||||
handled_signals, is_freebsd, is_macos, kitty_base_dir, shell_path,
|
||||
terminfo_dir
|
||||
)
|
||||
from .constants import handled_signals, is_freebsd, is_macos, kitty_base_dir, shell_path, terminfo_dir
|
||||
from .types import run_once
|
||||
from .utils import log_error, which
|
||||
|
||||
@ -28,11 +22,10 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
if is_macos:
|
||||
from kitty.fast_data_types import (
|
||||
cmdline_of_process as cmdline_, cwd_of_process as _cwd,
|
||||
environ_of_process as _environ_of_process,
|
||||
process_group_map as _process_group_map
|
||||
)
|
||||
from kitty.fast_data_types import cmdline_of_process as cmdline_
|
||||
from kitty.fast_data_types import cwd_of_process as _cwd
|
||||
from kitty.fast_data_types import environ_of_process as _environ_of_process
|
||||
from kitty.fast_data_types import process_group_map as _process_group_map
|
||||
|
||||
def cwd_of_process(pid: int) -> str:
|
||||
return os.path.realpath(_cwd(pid))
|
||||
|
||||
@ -2,8 +2,7 @@
|
||||
# License: GPLv3 Copyright: 2019, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import re
|
||||
|
||||
from typing import List, Generator, Any, Type
|
||||
from typing import Any, Generator, List, Type
|
||||
|
||||
from .cli_stub import HintsCLIOptions
|
||||
from .typing import MarkType
|
||||
|
||||
12
kitty/cli.py
12
kitty/cli.py
@ -6,19 +6,13 @@ import re
|
||||
import shlex
|
||||
import sys
|
||||
from collections import deque
|
||||
from enum import Enum, auto
|
||||
from dataclasses import dataclass
|
||||
from typing import (
|
||||
Any, Callable, Dict, FrozenSet, Iterator, List, Match, Optional, Sequence,
|
||||
Tuple, Type, TypeVar, Union, cast
|
||||
)
|
||||
from enum import Enum, auto
|
||||
from typing import Any, Callable, Dict, FrozenSet, Iterator, List, Match, Optional, Sequence, Tuple, Type, TypeVar, Union, cast
|
||||
|
||||
from .cli_stub import CLIOptions
|
||||
from .conf.utils import resolve_config
|
||||
from .constants import (
|
||||
appname, clear_handled_signals, config_dir, default_pager_for_help,
|
||||
defconf, is_macos, str_version, website_url
|
||||
)
|
||||
from .constants import appname, clear_handled_signals, config_dir, default_pager_for_help, defconf, is_macos, str_version, website_url
|
||||
from .fast_data_types import wcswidth
|
||||
from .options.types import Options as KittyOpts
|
||||
from .types import run_once
|
||||
|
||||
@ -17,7 +17,7 @@ ThemesCLIOptions = TransferCLIOptions = CopyCLIOptions = CLIOptions
|
||||
|
||||
|
||||
def generate_stub() -> None:
|
||||
from .cli import parse_option_spec, as_type_stub
|
||||
from .cli import as_type_stub, parse_option_spec
|
||||
from .conf.utils import save_type_stub
|
||||
text = 'import typing\n\n\n'
|
||||
|
||||
|
||||
@ -11,7 +11,6 @@ import sys
|
||||
from contextlib import suppress
|
||||
from typing import Any
|
||||
|
||||
|
||||
CSI = '\x1b['
|
||||
OSC = '\x1b]'
|
||||
|
||||
|
||||
@ -11,8 +11,13 @@ from typing import IO, Callable, Dict, List, Mapping, NamedTuple, Optional, Tupl
|
||||
from .conf.utils import uniq
|
||||
from .constants import supports_primary_selection
|
||||
from .fast_data_types import (
|
||||
GLFW_CLIPBOARD, GLFW_PRIMARY_SELECTION, OSC, get_boss, get_clipboard_mime,
|
||||
get_options, set_clipboard_data_types,
|
||||
GLFW_CLIPBOARD,
|
||||
GLFW_PRIMARY_SELECTION,
|
||||
OSC,
|
||||
get_boss,
|
||||
get_clipboard_mime,
|
||||
get_options,
|
||||
set_clipboard_data_types,
|
||||
)
|
||||
from .utils import log_error
|
||||
|
||||
|
||||
@ -7,9 +7,7 @@ import os
|
||||
import pprint
|
||||
import re
|
||||
import textwrap
|
||||
from typing import (
|
||||
Any, Callable, Dict, Iterator, List, Set, Tuple, Union, get_type_hints
|
||||
)
|
||||
from typing import Any, Callable, Dict, Iterator, List, Set, Tuple, Union, get_type_hints
|
||||
|
||||
from kitty.conf.types import Definition, MultiOption, Option, unset
|
||||
from kitty.types import _T
|
||||
|
||||
@ -7,10 +7,7 @@ import textwrap
|
||||
import typing
|
||||
from functools import lru_cache
|
||||
from importlib import import_module
|
||||
from typing import (
|
||||
Any, Callable, Dict, Iterable, Iterator, List, Match, Optional, Set, Tuple,
|
||||
Union, cast
|
||||
)
|
||||
from typing import Any, Callable, Dict, Iterable, Iterator, List, Match, Optional, Set, Tuple, Union, cast
|
||||
|
||||
import kitty.conf.utils as generic_parsers
|
||||
from kitty.constants import website_url
|
||||
@ -47,6 +44,7 @@ def expand_opt_references(conf_name: str, text: str) -> str:
|
||||
@run_once
|
||||
def ref_map() -> Dict[str, Dict[str, str]]:
|
||||
import json
|
||||
|
||||
from ..fast_data_types import get_docs_ref_map
|
||||
ans: Dict[str, Dict[str, str]] = json.loads(get_docs_ref_map())
|
||||
return ans
|
||||
|
||||
@ -7,8 +7,21 @@ import shlex
|
||||
import sys
|
||||
from contextlib import contextmanager
|
||||
from typing import (
|
||||
Any, Callable, Dict, Generator, Generic, Iterable, Iterator, List, NamedTuple,
|
||||
Optional, Sequence, Set, Tuple, TypeVar, Union,
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
Generator,
|
||||
Generic,
|
||||
Iterable,
|
||||
Iterator,
|
||||
List,
|
||||
NamedTuple,
|
||||
Optional,
|
||||
Sequence,
|
||||
Set,
|
||||
Tuple,
|
||||
TypeVar,
|
||||
Union,
|
||||
)
|
||||
|
||||
from ..constants import _plat, is_macos
|
||||
|
||||
@ -7,13 +7,11 @@ from contextlib import contextmanager, suppress
|
||||
from functools import partial
|
||||
from typing import Any, Dict, Generator, Iterable, List, Optional, Tuple
|
||||
|
||||
from .conf.utils import BadLine, load_config as _load_config, parse_config_base
|
||||
from .conf.utils import BadLine, parse_config_base
|
||||
from .conf.utils import load_config as _load_config
|
||||
from .constants import cache_dir, defconf
|
||||
from .options.types import Options, defaults, option_names
|
||||
from .options.utils import (
|
||||
KeyDefinition, KeyMap, MouseMap, MouseMapping, SequenceMap,
|
||||
build_action_aliases
|
||||
)
|
||||
from .options.utils import KeyDefinition, KeyMap, MouseMap, MouseMapping, SequenceMap, build_action_aliases
|
||||
from .typing import TypedDict
|
||||
from .utils import log_error
|
||||
|
||||
|
||||
@ -15,11 +15,10 @@ from typing import IO, Callable, Dict, Iterator, Optional, Set, TypeVar
|
||||
from kittens.tui.operations import colored, styled
|
||||
|
||||
from .cli import version
|
||||
from .constants import (
|
||||
extensions_dir, is_macos, is_wayland, kitty_base_dir, kitty_exe, shell_path
|
||||
)
|
||||
from .constants import extensions_dir, is_macos, is_wayland, kitty_base_dir, kitty_exe, shell_path
|
||||
from .fast_data_types import Color, num_users
|
||||
from .options.types import Options as KittyOpts, defaults
|
||||
from .options.types import Options as KittyOpts
|
||||
from .options.types import defaults
|
||||
from .options.utils import SequenceMap
|
||||
from .rgb import color_as_sharp
|
||||
from .types import MouseEvent, Shortcut, mod_to_names
|
||||
|
||||
@ -63,6 +63,7 @@ def launch(args: List[str]) -> None:
|
||||
|
||||
def edit(args: List[str]) -> None:
|
||||
import shutil
|
||||
|
||||
from .constants import is_macos
|
||||
if is_macos:
|
||||
# On macOS vim fails to handle SIGWINCH if it occurs early, so add a small delay.
|
||||
|
||||
@ -1,7 +1,16 @@
|
||||
import termios
|
||||
from ctypes import Array, c_ubyte
|
||||
from typing import (
|
||||
Any, Callable, Dict, Iterator, List, NewType, Optional, Tuple, TypedDict, Union,
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
Iterator,
|
||||
List,
|
||||
NewType,
|
||||
Optional,
|
||||
Tuple,
|
||||
TypedDict,
|
||||
Union,
|
||||
)
|
||||
|
||||
from kitty.boss import Boss
|
||||
|
||||
@ -14,20 +14,11 @@ from functools import partial
|
||||
from gettext import gettext as _
|
||||
from itertools import count
|
||||
from time import monotonic
|
||||
from typing import (
|
||||
IO, Any, Callable, DefaultDict, Deque, Dict, Iterable, Iterator, List,
|
||||
Optional, Tuple, Union, cast
|
||||
)
|
||||
from typing import IO, Any, Callable, DefaultDict, Deque, Dict, Iterable, Iterator, List, Optional, Tuple, Union, cast
|
||||
|
||||
from kittens.transfer.librsync import (
|
||||
LoadSignature, PatchFile, delta_for_file, signature_of_file
|
||||
)
|
||||
from kittens.transfer.utils import (
|
||||
IdentityCompressor, ZlibCompressor, abspath, expand_home, home_path
|
||||
)
|
||||
from kitty.fast_data_types import (
|
||||
FILE_TRANSFER_CODE, OSC, add_timer, get_boss, get_options
|
||||
)
|
||||
from kittens.transfer.librsync import LoadSignature, PatchFile, delta_for_file, signature_of_file
|
||||
from kittens.transfer.utils import IdentityCompressor, ZlibCompressor, abspath, expand_home, home_path
|
||||
from kitty.fast_data_types import FILE_TRANSFER_CODE, OSC, add_timer, get_boss, get_options
|
||||
from kitty.types import run_once
|
||||
|
||||
from .utils import log_error, sanitize_control_codes
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
try:
|
||||
from typing import TypedDict, NamedTuple
|
||||
from typing import NamedTuple, TypedDict
|
||||
except ImportError:
|
||||
TypedDict = dict
|
||||
from enum import Enum, IntEnum, auto
|
||||
|
||||
@ -7,12 +7,10 @@
|
||||
#
|
||||
|
||||
import math
|
||||
from functools import partial as p, wraps, lru_cache
|
||||
from functools import lru_cache, wraps
|
||||
from functools import partial as p
|
||||
from itertools import repeat
|
||||
from typing import (
|
||||
Any, Callable, Dict, Iterable, Iterator, List, MutableSequence, Optional,
|
||||
Sequence, Tuple
|
||||
)
|
||||
from typing import Any, Callable, Dict, Iterable, Iterator, List, MutableSequence, Optional, Sequence, Tuple
|
||||
|
||||
scale = (0.001, 1., 1.5, 2.)
|
||||
_dpi = 96.0
|
||||
|
||||
@ -6,15 +6,23 @@ from functools import lru_cache
|
||||
from typing import Dict, Generator, List, Optional, Tuple, cast
|
||||
|
||||
from kitty.fast_data_types import (
|
||||
FC_DUAL, FC_MONO, FC_SLANT_ITALIC, FC_SLANT_ROMAN, FC_WEIGHT_BOLD,
|
||||
FC_WEIGHT_REGULAR, FC_WIDTH_NORMAL, fc_list, fc_match as fc_match_impl,
|
||||
fc_match_postscript_name, parse_font_feature
|
||||
FC_DUAL,
|
||||
FC_MONO,
|
||||
FC_SLANT_ITALIC,
|
||||
FC_SLANT_ROMAN,
|
||||
FC_WEIGHT_BOLD,
|
||||
FC_WEIGHT_REGULAR,
|
||||
FC_WIDTH_NORMAL,
|
||||
fc_list,
|
||||
fc_match_postscript_name,
|
||||
parse_font_feature,
|
||||
)
|
||||
from kitty.fast_data_types import fc_match as fc_match_impl
|
||||
from kitty.options.types import Options
|
||||
from kitty.typing import FontConfigPattern
|
||||
from kitty.utils import log_error
|
||||
|
||||
from . import ListedFont, FontFeature
|
||||
from . import FontFeature, ListedFont
|
||||
|
||||
attr_map = {(False, False): 'font_family',
|
||||
(True, False): 'bold_font',
|
||||
|
||||
@ -5,35 +5,35 @@ import ctypes
|
||||
import sys
|
||||
from functools import partial
|
||||
from math import ceil, cos, floor, pi
|
||||
from typing import (
|
||||
TYPE_CHECKING, Any, Callable, Dict, Generator, List, Optional, Tuple,
|
||||
Union, cast
|
||||
)
|
||||
from typing import TYPE_CHECKING, Any, Callable, Dict, Generator, List, Optional, Tuple, Union, cast
|
||||
|
||||
from kitty.constants import is_macos
|
||||
from kitty.fast_data_types import (
|
||||
Screen, create_test_font_group, get_fallback_font, set_font_data,
|
||||
set_options, set_send_sprite_to_gpu, sprite_map_set_limits,
|
||||
test_render_line, test_shape, NUM_UNDERLINE_STYLES
|
||||
)
|
||||
from kitty.fonts.box_drawing import (
|
||||
BufType, distribute_dots, render_box_char, render_missing_glyph
|
||||
NUM_UNDERLINE_STYLES,
|
||||
Screen,
|
||||
create_test_font_group,
|
||||
get_fallback_font,
|
||||
set_font_data,
|
||||
set_options,
|
||||
set_send_sprite_to_gpu,
|
||||
sprite_map_set_limits,
|
||||
test_render_line,
|
||||
test_shape,
|
||||
)
|
||||
from kitty.fonts.box_drawing import BufType, distribute_dots, render_box_char, render_missing_glyph
|
||||
from kitty.options.types import Options, defaults
|
||||
from kitty.typing import CoreTextFont, FontConfigPattern
|
||||
from kitty.types import _T
|
||||
from kitty.typing import CoreTextFont, FontConfigPattern
|
||||
from kitty.utils import log_error
|
||||
|
||||
if is_macos:
|
||||
from .core_text import (
|
||||
find_font_features, font_for_family as font_for_family_macos,
|
||||
get_font_files as get_font_files_coretext
|
||||
)
|
||||
from .core_text import find_font_features
|
||||
from .core_text import font_for_family as font_for_family_macos
|
||||
from .core_text import get_font_files as get_font_files_coretext
|
||||
else:
|
||||
from .fontconfig import (
|
||||
find_font_features, font_for_family as font_for_family_fontconfig,
|
||||
get_font_files as get_font_files_fontconfig
|
||||
)
|
||||
from .fontconfig import find_font_features
|
||||
from .fontconfig import font_for_family as font_for_family_fontconfig
|
||||
from .fontconfig import get_font_files as get_font_files_fontconfig
|
||||
|
||||
FontObject = Union[CoreTextFont, FontConfigPattern]
|
||||
current_faces: List[Tuple[FontObject, bool, bool]] = []
|
||||
@ -483,8 +483,9 @@ def shape_string(
|
||||
|
||||
def show(outfile: str, width: int, height: int, fmt: int) -> None:
|
||||
import os
|
||||
from kittens.tui.images import GraphicsCommand
|
||||
from base64 import standard_b64encode
|
||||
|
||||
from kittens.tui.images import GraphicsCommand
|
||||
cmd = GraphicsCommand()
|
||||
cmd.a = 'T'
|
||||
cmd.f = fmt
|
||||
|
||||
@ -3,10 +3,7 @@
|
||||
|
||||
from typing import Union
|
||||
|
||||
from .fast_data_types import (
|
||||
GLFW_MOD_ALT, GLFW_MOD_CONTROL, GLFW_MOD_HYPER, GLFW_MOD_META,
|
||||
GLFW_MOD_SHIFT, GLFW_MOD_SUPER, KeyEvent, SingleKey
|
||||
)
|
||||
from .fast_data_types import GLFW_MOD_ALT, GLFW_MOD_CONTROL, GLFW_MOD_HYPER, GLFW_MOD_META, GLFW_MOD_SHIFT, GLFW_MOD_SUPER, KeyEvent, SingleKey
|
||||
from .options.utils import KeyMap, SequenceMap, SubSequenceMap
|
||||
from .typing import ScreenType
|
||||
|
||||
|
||||
@ -5,10 +5,7 @@
|
||||
import os
|
||||
import shutil
|
||||
from contextlib import suppress
|
||||
from typing import (
|
||||
Any, Container, Dict, FrozenSet, Iterable, Iterator, List, NamedTuple,
|
||||
Optional, Sequence, Tuple
|
||||
)
|
||||
from typing import Any, Container, Dict, FrozenSet, Iterable, Iterator, List, NamedTuple, Optional, Sequence, Tuple
|
||||
|
||||
from .boss import Boss
|
||||
from .child import Child
|
||||
@ -16,9 +13,7 @@ from .cli import parse_args
|
||||
from .cli_stub import LaunchCLIOptions
|
||||
from .clipboard import set_clipboard_string, set_primary_selection
|
||||
from .constants import kitty_tool_exe, shell_path
|
||||
from .fast_data_types import (
|
||||
add_timer, get_boss, get_options, get_os_window_title, patch_color_profiles
|
||||
)
|
||||
from .fast_data_types import add_timer, get_boss, get_options, get_os_window_title, patch_color_profiles
|
||||
from .options.utils import env as parse_env
|
||||
from .tabs import Tab, TabManager
|
||||
from .types import OverlayType, run_once
|
||||
@ -833,9 +828,7 @@ def clone_and_launch(msg: str, window: Window) -> None:
|
||||
is_clone_launch = serialize_env(c.shell, env_to_serialize)
|
||||
ssh_kitten_cmdline = window.ssh_kitten_cmdline()
|
||||
if ssh_kitten_cmdline:
|
||||
from kittens.ssh.utils import (
|
||||
patch_cmdline, set_cwd_in_cmdline, set_env_in_cmdline
|
||||
)
|
||||
from kittens.ssh.utils import patch_cmdline, set_cwd_in_cmdline, set_env_in_cmdline
|
||||
cmdline = ssh_kitten_cmdline
|
||||
if c.opts.cwd:
|
||||
set_cwd_in_cmdline(c.opts.cwd, cmdline)
|
||||
|
||||
@ -3,15 +3,10 @@
|
||||
|
||||
from functools import partial
|
||||
from itertools import repeat
|
||||
from typing import (
|
||||
Any, Dict, Generator, Iterable, Iterator, List, NamedTuple, Optional,
|
||||
Sequence, Tuple, Union
|
||||
)
|
||||
from typing import Any, Dict, Generator, Iterable, Iterator, List, NamedTuple, Optional, Sequence, Tuple, Union
|
||||
|
||||
from kitty.borders import BorderColor
|
||||
from kitty.fast_data_types import (
|
||||
Region, set_active_window, viewport_for_window
|
||||
)
|
||||
from kitty.fast_data_types import Region, set_active_window, viewport_for_window
|
||||
from kitty.options.types import Options
|
||||
from kitty.types import Edges, WindowGeometry
|
||||
from kitty.typing import TypedDict, WindowType
|
||||
|
||||
@ -4,19 +4,14 @@
|
||||
from functools import lru_cache
|
||||
from itertools import repeat
|
||||
from math import ceil, floor
|
||||
from typing import (
|
||||
Any, Callable, Dict, Generator, List, Optional, Sequence, Set, Tuple
|
||||
)
|
||||
from typing import Any, Callable, Dict, Generator, List, Optional, Sequence, Set, Tuple
|
||||
|
||||
from kitty.borders import BorderColor
|
||||
from kitty.types import Edges
|
||||
from kitty.typing import WindowType
|
||||
from kitty.window_list import WindowGroup, WindowList
|
||||
|
||||
from .base import (
|
||||
BorderLine, Layout, LayoutData, LayoutDimension, ListOfWindows,
|
||||
NeighborsMap, layout_dimension, lgd
|
||||
)
|
||||
from .base import BorderLine, Layout, LayoutData, LayoutDimension, ListOfWindows, NeighborsMap, layout_dimension, lgd
|
||||
from .tall import neighbors_for_tall_window
|
||||
|
||||
|
||||
|
||||
@ -1,20 +1,14 @@
|
||||
#!/usr/bin/env python
|
||||
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
from typing import (
|
||||
Any, Collection, Dict, Generator, List, NamedTuple, Optional, Sequence, Tuple,
|
||||
Union
|
||||
)
|
||||
from typing import Any, Collection, Dict, Generator, List, NamedTuple, Optional, Sequence, Tuple, Union
|
||||
|
||||
from kitty.borders import BorderColor
|
||||
from kitty.types import Edges, WindowGeometry
|
||||
from kitty.typing import EdgeLiteral, WindowType
|
||||
from kitty.window_list import WindowGroup, WindowList
|
||||
|
||||
from .base import (
|
||||
BorderLine, Layout, LayoutOpts, NeighborsMap, blank_rects_for_window, lgd,
|
||||
window_geometry_from_layouts
|
||||
)
|
||||
from .base import BorderLine, Layout, LayoutOpts, NeighborsMap, blank_rects_for_window, lgd, window_geometry_from_layouts
|
||||
|
||||
|
||||
class Extent(NamedTuple):
|
||||
|
||||
@ -10,10 +10,7 @@ from kitty.types import Edges
|
||||
from kitty.typing import EdgeLiteral, WindowType
|
||||
from kitty.window_list import WindowGroup, WindowList
|
||||
|
||||
from .base import (
|
||||
BorderLine, Layout, LayoutData, LayoutDimension, LayoutOpts, NeighborsMap,
|
||||
lgd, normalize_biases, safe_increment_bias
|
||||
)
|
||||
from .base import BorderLine, Layout, LayoutData, LayoutDimension, LayoutOpts, NeighborsMap, lgd, normalize_biases, safe_increment_bias
|
||||
from .vertical import borders
|
||||
|
||||
|
||||
|
||||
@ -8,10 +8,7 @@ from kitty.types import Edges
|
||||
from kitty.typing import WindowType
|
||||
from kitty.window_list import WindowGroup, WindowList
|
||||
|
||||
from .base import (
|
||||
BorderLine, Layout, LayoutData, LayoutDimension, NeighborsMap,
|
||||
lgd
|
||||
)
|
||||
from .base import BorderLine, Layout, LayoutData, LayoutDimension, NeighborsMap, lgd
|
||||
|
||||
|
||||
def borders(
|
||||
|
||||
@ -16,13 +16,31 @@ from .cli_stub import CLIOptions
|
||||
from .conf.utils import BadLine
|
||||
from .config import cached_values_for
|
||||
from .constants import (
|
||||
appname, beam_cursor_data_file, clear_handled_signals, config_dir, glfw_path,
|
||||
is_macos, is_wayland, kitty_exe, logo_png_file, running_in_kitty, website_url,
|
||||
appname,
|
||||
beam_cursor_data_file,
|
||||
clear_handled_signals,
|
||||
config_dir,
|
||||
glfw_path,
|
||||
is_macos,
|
||||
is_wayland,
|
||||
kitty_exe,
|
||||
logo_png_file,
|
||||
running_in_kitty,
|
||||
website_url,
|
||||
)
|
||||
from .fast_data_types import (
|
||||
GLFW_IBEAM_CURSOR, GLFW_MOD_ALT, GLFW_MOD_SHIFT, SingleKey, create_os_window,
|
||||
free_font_data, glfw_init, glfw_terminate, load_png_data,
|
||||
mask_kitty_signals_process_wide, set_custom_cursor, set_default_window_icon,
|
||||
GLFW_IBEAM_CURSOR,
|
||||
GLFW_MOD_ALT,
|
||||
GLFW_MOD_SHIFT,
|
||||
SingleKey,
|
||||
create_os_window,
|
||||
free_font_data,
|
||||
glfw_init,
|
||||
glfw_terminate,
|
||||
load_png_data,
|
||||
mask_kitty_signals_process_wide,
|
||||
set_custom_cursor,
|
||||
set_default_window_icon,
|
||||
set_options,
|
||||
)
|
||||
from .fonts.box_drawing import set_scale
|
||||
@ -33,8 +51,13 @@ from .os_window_size import initial_window_size_func
|
||||
from .prewarm import PrewarmProcess, fork_prewarm_process
|
||||
from .session import create_sessions, get_os_window_sizing_data
|
||||
from .utils import (
|
||||
cleanup_ssh_control_masters, detach, expandvars, log_error, single_instance,
|
||||
startup_notification_handler, unix_socket_paths,
|
||||
cleanup_ssh_control_masters,
|
||||
detach,
|
||||
expandvars,
|
||||
log_error,
|
||||
single_instance,
|
||||
startup_notification_handler,
|
||||
unix_socket_paths,
|
||||
)
|
||||
from .window import load_shader_programs
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
import re
|
||||
from ctypes import POINTER, c_uint, c_void_p, cast
|
||||
from typing import Callable, Generator, Iterable, Pattern, Tuple, Union, Sequence
|
||||
from typing import Callable, Generator, Iterable, Pattern, Sequence, Tuple, Union
|
||||
|
||||
from .utils import resolve_custom_file
|
||||
|
||||
|
||||
@ -7,9 +7,8 @@
|
||||
|
||||
import os
|
||||
from concurrent.futures import ProcessPoolExecutor
|
||||
from multiprocessing import util
|
||||
from multiprocessing import context, get_all_start_methods, get_context, spawn
|
||||
from typing import Any, Callable, Sequence, Optional, Tuple, Union, TYPE_CHECKING
|
||||
from multiprocessing import context, get_all_start_methods, get_context, spawn, util
|
||||
from typing import TYPE_CHECKING, Any, Callable, Optional, Sequence, Tuple, Union
|
||||
|
||||
from .constants import kitty_exe
|
||||
|
||||
@ -17,11 +16,11 @@ orig_spawn_passfds = util.spawnv_passfds
|
||||
orig_executable = spawn.get_executable()
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pickle import PickleBuffer
|
||||
from array import array
|
||||
from mmap import mmap
|
||||
from ctypes import _CData
|
||||
from typing import SupportsInt, SupportsIndex, Protocol
|
||||
from mmap import mmap
|
||||
from pickle import PickleBuffer
|
||||
from typing import Protocol, SupportsIndex, SupportsInt
|
||||
|
||||
class SupportsTrunc(Protocol):
|
||||
def __trunc__(self) -> int: ...
|
||||
|
||||
@ -6,20 +6,17 @@ import os
|
||||
import posixpath
|
||||
import shlex
|
||||
from contextlib import suppress
|
||||
from typing import (
|
||||
Any, Dict, Iterable, Iterator, List, NamedTuple, Optional, Tuple, cast
|
||||
)
|
||||
from typing import Any, Dict, Iterable, Iterator, List, NamedTuple, Optional, Tuple, cast
|
||||
from urllib.parse import ParseResult, unquote, urlparse
|
||||
|
||||
from .conf.utils import KeyAction, to_cmdline_implementation
|
||||
from .constants import config_dir
|
||||
from .fast_data_types import get_options
|
||||
from .guess_mime_type import guess_type
|
||||
from .options.utils import ActionAlias, resolve_aliases_and_parse_actions
|
||||
from .types import run_once
|
||||
from .typing import MatchType
|
||||
from .utils import expandvars, get_editor, log_error, resolved_shell
|
||||
from .fast_data_types import get_options
|
||||
|
||||
|
||||
if not hasattr(shlex, 'join'):
|
||||
shlex.join = lambda a: ' '.join(map(shlex.quote, a))
|
||||
|
||||
@ -4,10 +4,10 @@
|
||||
# After editing this file run ./gen-config.py to apply the changes
|
||||
|
||||
import string
|
||||
|
||||
from kitty.conf.types import Action, Definition
|
||||
from kitty.constants import website_url
|
||||
|
||||
|
||||
definition = Definition(
|
||||
'kitty',
|
||||
Action('map', 'parse_map', {'keymap': 'KeyMap', 'sequence_map': 'SequenceMap', 'alias_map': 'AliasMap'},
|
||||
|
||||
72
kitty/options/parse.py
generated
72
kitty/options/parse.py
generated
@ -1,23 +1,63 @@
|
||||
# generated by gen-config.py DO NOT edit
|
||||
|
||||
import typing
|
||||
from kitty.conf.utils import (
|
||||
merge_dicts, positive_float, positive_int, to_bool, to_cmdline, to_color, to_color_or_none,
|
||||
unit_float
|
||||
)
|
||||
|
||||
from kitty.conf.utils import merge_dicts, positive_float, positive_int, to_bool, to_cmdline, to_color, to_color_or_none, unit_float
|
||||
from kitty.options.utils import (
|
||||
action_alias, active_tab_title_template, allow_hyperlinks, bell_on_tab, box_drawing_scale,
|
||||
clear_all_mouse_actions, clear_all_shortcuts, clipboard_control, clone_source_strategies,
|
||||
config_or_absolute_path, copy_on_select, cursor_text_color, deprecated_adjust_line_height,
|
||||
deprecated_hide_window_decorations_aliases, deprecated_macos_show_window_title_in_menubar_alias,
|
||||
deprecated_send_text, disable_ligatures, edge_width, env, font_features, hide_window_decorations,
|
||||
macos_option_as_alt, macos_titlebar_color, modify_font, narrow_symbols, optional_edge_width,
|
||||
parse_map, parse_mouse_map, paste_actions, remote_control_password, resize_draw_strategy,
|
||||
scrollback_lines, scrollback_pager_history_size, shell_integration, store_multiple, symbol_map,
|
||||
tab_activity_symbol, tab_bar_edge, tab_bar_margin_height, tab_bar_min_tabs, tab_fade,
|
||||
tab_font_style, tab_separator, tab_title_template, titlebar_color, to_cursor_shape, to_font_size,
|
||||
to_layout_names, to_modifiers, url_prefixes, url_style, visual_window_select_characters,
|
||||
window_border_width, window_size
|
||||
action_alias,
|
||||
active_tab_title_template,
|
||||
allow_hyperlinks,
|
||||
bell_on_tab,
|
||||
box_drawing_scale,
|
||||
clear_all_mouse_actions,
|
||||
clear_all_shortcuts,
|
||||
clipboard_control,
|
||||
clone_source_strategies,
|
||||
config_or_absolute_path,
|
||||
copy_on_select,
|
||||
cursor_text_color,
|
||||
deprecated_adjust_line_height,
|
||||
deprecated_hide_window_decorations_aliases,
|
||||
deprecated_macos_show_window_title_in_menubar_alias,
|
||||
deprecated_send_text,
|
||||
disable_ligatures,
|
||||
edge_width,
|
||||
env,
|
||||
font_features,
|
||||
hide_window_decorations,
|
||||
macos_option_as_alt,
|
||||
macos_titlebar_color,
|
||||
modify_font,
|
||||
narrow_symbols,
|
||||
optional_edge_width,
|
||||
parse_map,
|
||||
parse_mouse_map,
|
||||
paste_actions,
|
||||
remote_control_password,
|
||||
resize_draw_strategy,
|
||||
scrollback_lines,
|
||||
scrollback_pager_history_size,
|
||||
shell_integration,
|
||||
store_multiple,
|
||||
symbol_map,
|
||||
tab_activity_symbol,
|
||||
tab_bar_edge,
|
||||
tab_bar_margin_height,
|
||||
tab_bar_min_tabs,
|
||||
tab_fade,
|
||||
tab_font_style,
|
||||
tab_separator,
|
||||
tab_title_template,
|
||||
titlebar_color,
|
||||
to_cursor_shape,
|
||||
to_font_size,
|
||||
to_layout_names,
|
||||
to_modifiers,
|
||||
url_prefixes,
|
||||
url_style,
|
||||
visual_window_select_characters,
|
||||
window_border_width,
|
||||
window_size,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -5,29 +5,27 @@
|
||||
import re
|
||||
import sys
|
||||
from functools import lru_cache
|
||||
from typing import (
|
||||
Any, Callable, Container, Dict, FrozenSet, Iterable, Iterator, List,
|
||||
NamedTuple, Optional, Sequence, Tuple, Union
|
||||
)
|
||||
from typing import Any, Callable, Container, Dict, FrozenSet, Iterable, Iterator, List, NamedTuple, Optional, Sequence, Tuple, Union
|
||||
|
||||
import kitty.fast_data_types as defines
|
||||
from kitty.conf.utils import (
|
||||
CurrentlyParsing, KeyAction, KeyFuncWrapper, currently_parsing,
|
||||
positive_float, positive_int, python_string, to_bool, to_cmdline, to_color,
|
||||
uniq, unit_float
|
||||
CurrentlyParsing,
|
||||
KeyAction,
|
||||
KeyFuncWrapper,
|
||||
currently_parsing,
|
||||
positive_float,
|
||||
positive_int,
|
||||
python_string,
|
||||
to_bool,
|
||||
to_cmdline,
|
||||
to_color,
|
||||
uniq,
|
||||
unit_float,
|
||||
)
|
||||
from kitty.constants import is_macos
|
||||
from kitty.fast_data_types import (
|
||||
CURSOR_BEAM, CURSOR_BLOCK, CURSOR_UNDERLINE, Color, SingleKey
|
||||
)
|
||||
from kitty.fonts import (
|
||||
FontFeature, FontModification, ModificationType, ModificationUnit,
|
||||
ModificationValue
|
||||
)
|
||||
from kitty.key_names import (
|
||||
character_key_name_aliases, functional_key_name_aliases,
|
||||
get_key_name_lookup
|
||||
)
|
||||
from kitty.fast_data_types import CURSOR_BEAM, CURSOR_BLOCK, CURSOR_UNDERLINE, Color, SingleKey
|
||||
from kitty.fonts import FontFeature, FontModification, ModificationType, ModificationUnit, ModificationValue
|
||||
from kitty.key_names import character_key_name_aliases, functional_key_name_aliases, get_key_name_lookup
|
||||
from kitty.rgb import color_as_int
|
||||
from kitty.types import FloatEdges, MouseEvent
|
||||
from kitty.utils import expandvars, log_error, resolve_abs_or_config_path
|
||||
|
||||
@ -16,17 +16,22 @@ from contextlib import suppress
|
||||
from dataclasses import dataclass
|
||||
from importlib import import_module
|
||||
from itertools import count
|
||||
from typing import (
|
||||
IO, TYPE_CHECKING, Any, Callable, Dict, Iterator, List, NoReturn, Optional,
|
||||
Tuple, TypeVar, Union, cast
|
||||
)
|
||||
from typing import IO, TYPE_CHECKING, Any, Callable, Dict, Iterator, List, NoReturn, Optional, Tuple, TypeVar, Union, cast
|
||||
|
||||
from kitty.constants import kitty_exe, running_in_kitty
|
||||
from kitty.entry_points import main as main_entry_point
|
||||
from kitty.fast_data_types import (
|
||||
CLD_EXITED, CLD_KILLED, CLD_STOPPED, clearenv, get_options,
|
||||
install_signal_handlers, read_signals, remove_signal_handlers, safe_pipe,
|
||||
set_options, set_use_os_log
|
||||
CLD_EXITED,
|
||||
CLD_KILLED,
|
||||
CLD_STOPPED,
|
||||
clearenv,
|
||||
get_options,
|
||||
install_signal_handlers,
|
||||
read_signals,
|
||||
remove_signal_handlers,
|
||||
safe_pipe,
|
||||
set_options,
|
||||
set_use_os_log,
|
||||
)
|
||||
from kitty.options.types import Options
|
||||
from kitty.shm import SharedMemory
|
||||
|
||||
@ -4,12 +4,9 @@
|
||||
import tempfile
|
||||
from contextlib import suppress
|
||||
from dataclasses import dataclass, field
|
||||
from typing import (
|
||||
TYPE_CHECKING, Any, Callable, Dict, FrozenSet, Iterable, Iterator,
|
||||
List, NoReturn, Optional, Set, Tuple, Type, Union, cast
|
||||
)
|
||||
from typing import TYPE_CHECKING, Any, Callable, Dict, FrozenSet, Iterable, Iterator, List, NoReturn, Optional, Set, Tuple, Type, Union, cast
|
||||
|
||||
from kitty.cli import get_defaults_from_seq, parse_args, parse_option_spec, CompletionSpec
|
||||
from kitty.cli import CompletionSpec, get_defaults_from_seq, parse_args, parse_option_spec
|
||||
from kitty.cli_stub import RCOptions as R
|
||||
from kitty.constants import appname, list_kitty_resources, running_in_kitty
|
||||
from kitty.types import AsyncResponse
|
||||
|
||||
@ -4,10 +4,7 @@
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .base import (
|
||||
MATCH_TAB_OPTION, ArgsType, Boss, MatchError, PayloadGetType, PayloadType,
|
||||
RCOptions, RemoteCommand, ResponseType, Window
|
||||
)
|
||||
from .base import MATCH_TAB_OPTION, ArgsType, Boss, MatchError, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kitty.cli_stub import CloseTabRCOptions as CLIOptions
|
||||
|
||||
@ -4,10 +4,7 @@
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .base import (
|
||||
MATCH_WINDOW_OPTION, ArgsType, Boss, PayloadGetType, PayloadType,
|
||||
RCOptions, RemoteCommand, ResponseType, Window, MatchError
|
||||
)
|
||||
from .base import MATCH_WINDOW_OPTION, ArgsType, Boss, MatchError, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kitty.cli_stub import CloseWindowRCOptions as CLIOptions
|
||||
|
||||
@ -5,10 +5,7 @@ from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from kitty.options.utils import parse_marker_spec
|
||||
|
||||
from .base import (
|
||||
MATCH_WINDOW_OPTION, ArgsType, Boss, PayloadGetType,
|
||||
PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
)
|
||||
from .base import MATCH_WINDOW_OPTION, ArgsType, Boss, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kitty.cli_stub import CreateMarkerRCOptions as CLIOptions
|
||||
|
||||
@ -3,10 +3,7 @@
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .base import (
|
||||
MATCH_TAB_OPTION, ArgsType, Boss, MatchError, PayloadGetType,
|
||||
PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
)
|
||||
from .base import MATCH_TAB_OPTION, ArgsType, Boss, MatchError, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kitty.cli_stub import DetachTabRCOptions as CLIOptions
|
||||
|
||||
@ -3,11 +3,7 @@
|
||||
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from .base import (
|
||||
MATCH_TAB_OPTION, MATCH_WINDOW_OPTION, ArgsType, Boss, MatchError,
|
||||
PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType,
|
||||
Window
|
||||
)
|
||||
from .base import MATCH_TAB_OPTION, MATCH_WINDOW_OPTION, ArgsType, Boss, MatchError, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kitty.cli_stub import DetachWindowRCOptions as CLIOptions
|
||||
|
||||
@ -4,10 +4,7 @@
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .base import (
|
||||
MATCH_TAB_OPTION, MATCH_WINDOW_OPTION, ArgsType, Boss, PayloadGetType,
|
||||
PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
)
|
||||
from .base import MATCH_TAB_OPTION, MATCH_WINDOW_OPTION, ArgsType, Boss, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kitty.cli_stub import DisableLigaturesRCOptions as CLIOptions
|
||||
|
||||
@ -3,10 +3,7 @@
|
||||
|
||||
from typing import Any, Optional
|
||||
|
||||
from .base import (
|
||||
ArgsType, Boss, PayloadGetType, PayloadType, RCOptions, RemoteCommand,
|
||||
ResponseType, Window
|
||||
)
|
||||
from .base import ArgsType, Boss, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
|
||||
|
||||
class Env(RemoteCommand):
|
||||
|
||||
@ -4,10 +4,7 @@
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .base import (
|
||||
MATCH_TAB_OPTION, ArgsType, Boss, PayloadGetType, PayloadType, RCOptions,
|
||||
RemoteCommand, ResponseType, Window
|
||||
)
|
||||
from .base import MATCH_TAB_OPTION, ArgsType, Boss, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kitty.cli_stub import FocusTabRCOptions as CLIOptions
|
||||
|
||||
@ -6,10 +6,7 @@ from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from kitty.fast_data_types import focus_os_window
|
||||
|
||||
from .base import (
|
||||
MATCH_WINDOW_OPTION, ArgsType, Boss, PayloadGetType, PayloadType,
|
||||
RCOptions, RemoteCommand, ResponseType, Window
|
||||
)
|
||||
from .base import MATCH_WINDOW_OPTION, ArgsType, Boss, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kitty.cli_stub import FocusWindowRCOptions as CLIOptions
|
||||
|
||||
@ -7,10 +7,7 @@ from kitty.fast_data_types import Color
|
||||
from kitty.rgb import color_as_sharp, color_from_int
|
||||
from kitty.utils import natsort_ints
|
||||
|
||||
from .base import (
|
||||
MATCH_WINDOW_OPTION, ArgsType, Boss, PayloadGetType, PayloadType,
|
||||
RCOptions, RemoteCommand, ResponseType, Window
|
||||
)
|
||||
from .base import MATCH_WINDOW_OPTION, ArgsType, Boss, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kitty.cli_stub import GetColorsRCOptions as CLIOptions
|
||||
|
||||
@ -4,10 +4,7 @@
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .base import (
|
||||
MATCH_WINDOW_OPTION, ArgsType, Boss, PayloadGetType, PayloadType,
|
||||
RCOptions, RemoteCommand, ResponseType, Window
|
||||
)
|
||||
from .base import MATCH_WINDOW_OPTION, ArgsType, Boss, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kitty.cli_stub import GetTextRCOptions as CLIOptions
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
#!/usr/bin/env python
|
||||
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
from typing import TYPE_CHECKING, Optional, Iterable
|
||||
from typing import TYPE_CHECKING, Iterable, Optional
|
||||
|
||||
from .base import (
|
||||
MATCH_TAB_OPTION, ArgsType, Boss, PayloadGetType, PayloadType, RCOptions,
|
||||
RemoteCommand, ResponseType, UnknownLayout, Window
|
||||
)
|
||||
from .base import MATCH_TAB_OPTION, ArgsType, Boss, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, UnknownLayout, Window
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kitty.cli_stub import GotoLayoutRCOptions as CLIOptions
|
||||
|
||||
@ -3,10 +3,7 @@
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .base import (
|
||||
MATCH_WINDOW_OPTION, ArgsType, Boss, PayloadGetType, PayloadType, RCOptions,
|
||||
RemoteCommand, ResponseType, Window
|
||||
)
|
||||
from .base import MATCH_WINDOW_OPTION, ArgsType, Boss, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kitty.cli_stub import KittenRCOptions as CLIOptions
|
||||
|
||||
@ -4,10 +4,7 @@
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .base import (
|
||||
MATCH_TAB_OPTION, ArgsType, Boss, PayloadGetType, PayloadType, RCOptions,
|
||||
RemoteCommand, ResponseType, Window
|
||||
)
|
||||
from .base import MATCH_TAB_OPTION, ArgsType, Boss, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kitty.cli_stub import LastUsedLayoutRCOptions as CLIOptions
|
||||
|
||||
@ -5,15 +5,11 @@
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from kitty.cli_stub import LaunchCLIOptions
|
||||
from kitty.launch import (
|
||||
launch as do_launch, options_spec as launch_options_spec,
|
||||
parse_launch_args
|
||||
)
|
||||
from kitty.launch import launch as do_launch
|
||||
from kitty.launch import options_spec as launch_options_spec
|
||||
from kitty.launch import parse_launch_args
|
||||
|
||||
from .base import (
|
||||
MATCH_TAB_OPTION, ArgsType, Boss, PayloadGetType, PayloadType, RCOptions,
|
||||
RemoteCommand, ResponseType, Window
|
||||
)
|
||||
from .base import MATCH_TAB_OPTION, ArgsType, Boss, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kitty.cli_stub import LaunchRCOptions as CLIOptions
|
||||
|
||||
@ -6,10 +6,7 @@ from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple
|
||||
|
||||
from kitty.constants import appname
|
||||
|
||||
from .base import (
|
||||
ArgsType, Boss, PayloadGetType, PayloadType, RCOptions, RemoteCommand,
|
||||
ResponseType, Window
|
||||
)
|
||||
from .base import ArgsType, Boss, PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kitty.cli_stub import LSRCOptions as CLIOptions
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user