repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
kitty | kittens/quick_access_terminal/main.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net>
import re
import sys
from kitty.conf.types import Definition
from kitty.constants import appname
from kitty.simple_cli_definitions import CONFIG_HELP, get_option_maps, grab_keyboard_docs, panel_options_spec, parse_option_spe... | 174 | 5,018 |
kitty | kittens/notify/main.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
import sys
def OPTIONS() -> str:
from kitty.constants import standard_icon_names
return f"""
--icon -n
type=list
The name of the icon to use for the notification. An icon with this name
will be searched for on the... | 123 | 4,578 |
kitty | kittens/clipboard/main.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
import sys
OPTIONS = r"""
--get-clipboard -g
type=bool-set
Output the current contents of the clipboard to STDOUT. Note that by default
kitty will prompt for permission to access the clipboard. Can be controlled
by :opt:`cl... | 105 | 4,195 |
kitty | kittens/dnd/main.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
import sys
OPTIONS = r"""
--drag
type=list
When starting a drag, use the specified file as the data source for the specified
MIME type. Syntax is: mime-type:path/to/file. For example image/jpeg:mypic.jpg
Can be specified mu... | 94 | 3,547 |
kitty | kittens/choose_fonts/main.py | .py | if __name__ == '__main__':
import os
import sys
from kitty.constants import kitten_exe
os.execlp(kitten_exe(), 'kitten', *sys.argv)
| 8 | 150 |
kitty | kittens/choose_fonts/backend.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2024, Kovid Goyal <kovid at kovidgoyal.net>
import json
import os
import string
import sys
import tempfile
from typing import TYPE_CHECKING, Any, Literal, Optional, TypedDict
from kitty.cli import create_default_opts
from kitty.conf.utils import to_color
from kitty.co... | 267 | 9,197 |
kitty | kittens/panel/main.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
import os
import sys
from collections.abc import Iterable, Mapping, Sequence
from contextlib import suppress
from functools import partial
from types import MappingProxyType
from typing import Any
from kitty.cli import pars... | 255 | 9,805 |
kitty | kittens/show_key/main.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
import sys
OPTIONS = r"""
--key-mode -m
default=normal
type=choices
choices=normal,application,kitty,unchanged
The keyboard mode to use when showing keys. :code:`normal` mode is with DECCKM
reset and :code:`application` mod... | 32 | 851 |
kitty | kittens/ask/main.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
import sys
from kitty.typing_compat import BossType, TypedDict
from ..tui.handler import result_handler
def option_text() -> str:
return """\
--type -t
choices=line,yesno,choices,password,file
default=line
Type of in... | 91 | 2,455 |
kitty | kittens/tui/operations.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
import os
import sys
from collections.abc import Callable, Generator
from contextlib import contextmanager
from enum import Enum, auto
from functools import wraps
from typing import Any, Optional, TypeVar, Union
from kitty.... | 491 | 12,958 |
kitty | kittens/tui/progress.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
from .operations import repeat, styled
def render_progress_bar(frac: float, width: int = 80) -> str:
if frac >= 1:
return styled('🬋' * width, fg='green')
if frac <= 0:
return styled('🬋' * width, d... | 40 | 1,052 |
kitty | kittens/tui/spinners.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
from collections.abc import Sequence
from kitty.fast_data_types import monotonic
from kitty.typing_compat import TypedDict
class SpinnerDef(TypedDict):
interval: int
frames: Sequence[str]
# Spinner definitions ar... | 688 | 25,828 |
kitty | kittens/tui/utils.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
import os
import sys
from collections.abc import Sequence
from contextlib import suppress
from typing import TYPE_CHECKING, Optional, cast
from kitty.types import run_once
from .operations import raw_mode, set_cursor_visibl... | 130 | 3,882 |
kitty | kittens/tui/line_edit.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
from collections.abc import Callable
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... | 155 | 5,365 |
kitty | kittens/tui/dircolors.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
import os
import stat
from collections.abc import Generator
from contextlib import suppress
DEFAULT_DIRCOLORS = r"""# {{{
# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable use... | 385 | 10,343 |
kitty | kittens/tui/images.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
import codecs
import os
import sys
from base64 import standard_b64encode
from collections import defaultdict, deque
from collections.abc import Callable, Iterator, Sequence
from contextlib import suppress
from enum import In... | 612 | 22,324 |
kitty | kittens/tui/path_completer.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
import os
from collections.abc import Callable, Generator, Sequence
from typing import Any
from kitty.fast_data_types import wcswidth
from kitty.utils import ScreenSize, screen_size_function
from .operations import styled
... | 159 | 4,904 |
kitty | kittens/tui/operations_stub.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
class CMD:
pass
def generate_stub() -> None:
from kittens.tui.operations import as_type_stub
from kitty.conf.utils import save_type_stub
text = as_type_stub()
save_type_stub(text, __file__)
| 15 | 309 |
kitty | kittens/tui/loop.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
import asyncio
import codecs
import io
import os
import re
import selectors
import signal
import sys
import termios
from collections.abc import Callable, Generator
from contextlib import contextmanager, suppress
from enum im... | 465 | 17,000 |
kitty | kittens/tui/handler.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
import os
from collections import deque
from collections.abc import Callable, Sequence
from contextlib import suppress
from types import TracebackType
from typing import TYPE_CHECKING, Any, ContextManager, Deque, NamedTuple... | 355 | 11,969 |
kitty | kittens/resize_window/main.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
import sys
from typing import Any
from kitty.cli import parse_args
from kitty.cli_stub import RCOptions, ResizeCLIOptions
from kitty.constants import version
from kitty.key_encoding import CTRL, EventType, KeyEvent
from ki... | 132 | 4,857 |
kitty | kittens/desktop_ui/main.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net>
import sys
from kitty.conf.types import Definition
definition = Definition(
'!kittens.choose_files',
)
agr = definition.add_group
egr = definition.end_group
opt = definition.add_option
map = definition.add_map
mma = d... | 64 | 2,052 |
kitty | kittens/icat/main.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
OPTIONS = """\
--align
type=choices
choices=center,left,right
default=center
Horizontal alignment for the displayed image.
--place
Choose where on the screen to display the image. The image will be scaled to fit
into the s... | 205 | 6,976 |
kitty | kittens/ssh/main.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
import sys
from kitty.conf.types import Definition
from kitty.types import run_once
copy_message = """\
Copy files and directories from local to remote hosts. The specified files are
assumed to be relative to the HOME dire... | 352 | 11,807 |
kitty | kittens/ssh/utils.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
import os
import subprocess
import traceback
from collections.abc import Iterator, Sequence
from contextlib import suppress
from typing import Any
from kitty.types import run_once
from kitty.utils import SSHConnectionData
... | 404 | 13,501 |
kitty | kittens/hyperlinked_grep/main.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
import sys
if __name__ == '__main__':
raise SystemExit('This should be run as kitten hyperlinked_grep')
elif __name__ == '__wrapper_of__':
cd = sys.cli_docs # type: ignore
cd['wrapper_of'] = 'rg'
| 11 | 305 |
kitty | kittens/unicode_input/main.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
from kitty.typing_compat import BossType
from ..tui.handler import result_handler
help_text = 'Input a Unicode character'
usage = ''
OPTIONS = """
--emoji-variation
type=choices
default=none
choices=none,graphic,text
Whet... | 51 | 1,294 |
kitty | kittens/pager/main.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2024, Kovid Goyal <kovid at kovidgoyal.net>
import sys
from kitty.simple_cli_definitions import CompletionSpec
OPTIONS = """
--role
default=pager
choices=pager,scrollback
The role the pager is used for. The default is a standard less like pager.
--follow
type=bool... | 42 | 1,131 |
kitty | kittens/remote_file/main.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
import json
import os
import shlex
import shutil
import subprocess
import sys
import tempfile
import time
from typing import Any, Optional
from kitty.cli import parse_args
from kitty.cli_stub import RemoteFileCLIOptions
fro... | 359 | 13,833 |
kitty | kittens/transfer/main.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
import sys
usage = 'source_files_or_directories destination_path'
help_text = """\
Transfer files over the TTY device. Can be used to send files between any two
computers provided there is a TTY connection between them, suc... | 138 | 5,011 |
kitty | kittens/transfer/utils.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
import os
from collections.abc import Generator
from contextlib import contextmanager
_cwd = _home = ''
def abspath(path: str, use_home: bool = False) -> str:
base = home_path() if use_home else (_cwd or os.getcwd())
... | 60 | 1,399 |
kitty | kittens/hints/main.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
import sys
from collections.abc import Sequence
from functools import lru_cache
from typing import Any
from kitty.cli_stub import HintsCLIOptions
from kitty.clipboard import set_clipboard_string, set_primary_selection
from ... | 444 | 16,470 |
kitty | kittens/broadcast/main.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
import sys
from base64 import standard_b64encode
from gettext import gettext as _
from typing import Any
from kitty.cli import parse_args
from kitty.cli_stub import BroadcastCLIOptions
from kitty.key_encoding import encode_k... | 168 | 5,832 |
kitty | kittens/command_palette/main.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2024, Kovid Goyal <kovid at kovidgoyal.net>
# Entry point: collect_keys_data(opts) — collects all keybinding, alias, and
# mouse data into a JSON-serializable dict consumed by the Go TUI.
import sys
from functools import partial
from typing import Any
from kitty.conf... | 340 | 12,705 |
kitty | kitty_tests/layout.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
from kitty.config import defaults
from kitty.fast_data_types import BOTTOM_EDGE, LEFT_EDGE, RIGHT_EDGE, TOP_EDGE, Region
from kitty.layout.base import layout_dimension, lgd
from kitty.layout.interface import Grid, Horizontal... | 830 | 33,700 |
kitty | kitty_tests/open_actions.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
import os
from contextlib import contextmanager
from kitty.utils import get_editor
from .base import BaseTest
@contextmanager
def patch_env(**kw):
orig = os.environ.copy()
for k, v in kw.items():
if v is... | 60 | 1,379 |
kitty | kitty_tests/parser.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
from binascii import hexlify
from functools import partial
from kitty.fast_data_types import (
CURSOR_BLOCK,
VT_PARSER_BUFFER_SIZE,
base64_decode,
base64_encode,
has_avx2,
has_sse4_2,
test_find_e... | 1,007 | 47,046 |
kitty | kitty_tests/options.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
import os
import shutil
import subprocess
import tempfile
from kitty.constants import kitty_exe
from kitty.fast_data_types import Color, test_cursor_blink_easing_function
from kitty.options.utils import DELETE_ENV_VAR, Easi... | 496 | 20,889 |
kitty | kitty_tests/notifications.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2024, Kovid Goyal <kovid at kovidgoyal.net>
import os
import re
import tempfile
from base64 import standard_b64encode
from kitty.notifications import Channel, DesktopIntegration, IconDataCache, NotificationManager, UIState, Urgency
from .base import BaseTest
def n... | 365 | 10,668 |
kitty | kitty_tests/search_query_parser.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
from .base import BaseTest
class TestSQP(BaseTest):
def test_search_query_parser(self):
from kitty.search_query_parser import ParseException, search
locations = 'id'
universal_set = {1, 2, 3, 4... | 31 | 917 |
kitty | kitty_tests/clipboard.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
from base64 import standard_b64decode, standard_b64encode
from kitty.clipboard import WriteRequest
from kitty.fast_data_types import StreamingBase64Decoder
from .base import BaseTest
class TestClipboard(BaseTest):
def... | 55 | 2,007 |
kitty | kitty_tests/main.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
import importlib
import json
import os
import re
import select
import shutil
import subprocess
import sys
import time
import unittest
from collections.abc import Callable, Generator, Iterator, Sequence
from contextlib import ... | 776 | 28,954 |
kitty | kitty_tests/child.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2026, Kovid Goyal <kovid at kovidgoyal.net>
import os
import subprocess
from kitty.child import memory_used_by_process_tree_rooted_at
from kitty.constants import is_macos, kitty_exe
from .base import BaseTest
class ChildMemoryTest(BaseTest):
def _spawn_allocat... | 106 | 4,057 |
kitty | kitty_tests/datatypes.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
import json
import os
import shutil
import subprocess
import sys
import tempfile
from kitty.constants import is_macos, kitty_exe, read_kitty_resource
from kitty.fast_data_types import (
Color,
HistoryBuf,
LineBu... | 1,082 | 42,109 |
kitty | kitty_tests/dnd_kitten.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2026, Kovid Goyal <kovid at kovidgoyal.net>
import errno
import fnmatch
import itertools
import os
import random
import shutil
import stat
import tempfile
import time
import uuid
from base64 import standard_b64encode
from functools import partial
from urllib.parse impo... | 511 | 24,803 |
kitty | kitty_tests/glfw.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
import sys
import unittest
from .base import BaseTest
_plat = sys.platform.lower()
is_macos = 'darwin' in _plat
class TestGLFW(BaseTest):
def test_os_window_size_calculation(self):
from kitty.utils import get... | 92 | 3,664 |
kitty | kitty_tests/screen.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
from kitty.fast_data_types import DECAWM, DECCOLM, DECOM, IRM, VT_PARSER_BUFFER_SIZE, Color, ColorProfile, Cursor
from kitty.marks import marker_from_function, marker_from_regex, marker_from_text
from kitty.window import pag... | 2,013 | 74,128 |
kitty | kitty_tests/mouse.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
from functools import partial
from kitty.fast_data_types import (
GLFW_MOD_ALT,
GLFW_MOD_CONTROL,
GLFW_MOUSE_BUTTON_LEFT,
GLFW_MOUSE_BUTTON_RIGHT,
MOUSE_SELECTION_WORD_AND_LINE_FROM_POINT,
create_moc... | 456 | 15,325 |
kitty | kitty_tests/completion.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
import json
import os
import shlex
import subprocess
import tempfile
from kitty.constants import kitten_exe as kitten
from kitty.session import SESSION_FILE_EXTENSIONS
from .base import BaseTest
class TestCompletion(Base... | 183 | 6,717 |
kitty | kitty_tests/keys.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
from functools import partial
from types import SimpleNamespace
import kitty.fast_data_types as defines
from kitty.key_encoding import EventType, KeyEvent, decode_key_event, encode_key_event
from kitty.keys import Mappings
... | 940 | 49,792 |
kitty | kitty_tests/fonts.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
import array
import os
import tempfile
import unittest
from collections.abc import Iterable
from functools import lru_cache, partial
from itertools import repeat
from math import ceil
from kitty.constants import is_macos, r... | 1,326 | 37,389 |
kitty | kitty_tests/remote_control.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2026 Kovid Goyal <kovid at kovidgoyal.net>
from unittest.mock import patch
from kitty.rc.base import PayloadGetter, all_command_names, command_for_name
from .base import BaseTest
class Window:
def __init__(self, id: int, os_window_id: int):
self.id = id... | 55 | 1,943 |
kitty | kitty_tests/slang.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2026, Kovid Goyal <kovid at kovidgoyal.net>
import hashlib
import importlib.resources as ir
import json
import os
import shutil
import subprocess
import tempfile
from kitty.constants import slangc
from kitty.shaders.slang import (
EntryPoint,
SlangFile,
St... | 483 | 17,867 |
kitty | kitty_tests/gr.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
import os
import sys
import zlib
from base64 import standard_b64encode
from contextlib import suppress
write = getattr(sys.stdout, 'buffer', sys.stdout).write
def clear_screen():
write(b'\033[2J')
def move_cursor(x,... | 73 | 1,957 |
kitty | kitty_tests/file_transmission.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
import os
import shutil
import stat
import tempfile
from collections import namedtuple
from contextlib import contextmanager
from pathlib import Path
from kittens.transfer.rsync import Differ, Hasher, Patcher, parse_ftc
fro... | 545 | 20,731 |
kitty | kitty_tests/choose_files.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2026, Kovid Goyal <kovid at kovidgoyal.net>
import shlex
from .base import BaseTest
class TestChooseFiles(BaseTest):
def test_format_selection_for_paste(self) -> None:
from kittens.choose_files.main import format_selection_for_paste
paths = ['/... | 17 | 720 |
kitty | kitty_tests/ssh.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
import glob
import json
import os
import shutil
import subprocess
import tempfile
from contextlib import suppress
from functools import lru_cache
from kittens.ssh.utils import get_connection_data
from kitty.constants import... | 340 | 16,060 |
kitty | kitty_tests/shm.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2023, Kovid Goyal <kovid at kovidgoyal.net>
import os
import subprocess
from kitty.constants import kitten_exe
from kitty.fast_data_types import shm_unlink
from kitty.shm import SharedMemory
from .base import BaseTest
class SHMTest(BaseTest):
def test_shm_with... | 30 | 1,069 |
kitty | kitty_tests/multicell.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2024, Kovid Goyal <kovid at kovidgoyal.net>
from functools import partial
from kitty.fast_data_types import EXTEND_CELL, TEXT_SIZE_CODE, test_ch_and_idx, wcswidth
from .base import BaseTest, parse_bytes
from .base import draw_multicell as multicell
class TestMultic... | 800 | 26,726 |
kitty | kitty_tests/dnd.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2026, Kovid Goyal <kovid at kovidgoyal.net>
import errno
import os
import re
from base64 import standard_b64encode
from contextlib import contextmanager
from functools import partial
from kitty.fast_data_types import (
DND_CODE,
Screen,
StreamingBase64Dec... | 3,167 | 156,192 |
kitty | kitty_tests/utmp.py | .py | import subprocess
from kitty.fast_data_types import num_users
from .base import BaseTest
class UTMPTest(BaseTest):
def test_num_users(self):
# who is the control
try:
expected = subprocess.check_output(['who']).decode('utf-8').count('\n')
except FileNotFoundError:
... | 17 | 437 |
kitty | kitty_tests/command_palette.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2024, Kovid Goyal <kovid at kovidgoyal.net>
from .base import BaseTest
class TestCommandPalette(BaseTest):
def test_collect_keys_data(self):
from kittens.command_palette.main import collect_keys_data
from kitty.actions import groups
opts ... | 240 | 11,221 |
kitty | kitty_tests/tab_bar.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2026, Kovid Goyal <kovid at kovidgoyal.net>
from unittest.mock import patch
from kitty.fast_data_types import LEFT_EDGE, Color, Region
from kitty.options.utils import tab_title_wrap
from kitty.tab_bar import CellRange, TabBar, TabBarData, truncate_line, wrap_title
f... | 416 | 20,587 |
kitty | kitty_tests/shell_integration.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
import errno
import os
import shlex
import shutil
import subprocess
import tempfile
import unittest
from contextlib import contextmanager
from functools import lru_cache, partial
from kitty.bash import decode_ansi_c_quoted_... | 581 | 28,948 |
kitty | kitty_tests/tui.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
from .base import BaseTest
class TestTUI(BaseTest):
def test_line_edit(self):
from kittens.tui.line_edit import LineEdit
le = LineEdit()
le.on_text('abcd', False)
self.ae(le.cursor_pos... | 49 | 1,565 |
kitty | kitty_tests/atexit.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net>
import os
import select
import shutil
import signal
import subprocess
import tempfile
from kitty.constants import kitten_exe, kitty_exe
from kitty.shm import SharedMemory
from .base import BaseTest
class Atexit(BaseTest)... | 105 | 3,214 |
kitty | kitty_tests/graphics.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
import os
import random
import tempfile
import time
import unittest
import zlib
from contextlib import suppress
from dataclasses import dataclass
from io import BytesIO
from kitty.fast_data_types import base64_decode, base6... | 1,406 | 58,251 |
kitty | kitty_tests/base.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
import fcntl
import io
import os
import select
import shlex
import shutil
import signal
import struct
import sys
import termios
import time
from contextlib import contextmanager, suppress
from functools import wraps
from pty... | 556 | 18,603 |
kitty | kitty_tests/panels.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net>
import shlex
import subprocess
def r(msg: str, cmdline: str) -> None:
try:
q = input('Test ' + msg + '? (y/n): ').lower()
if q in ('y', 'yes'):
try:
subprocess.run(['kitten'] ... | 38 | 1,379 |
kitty | kitty_tests/crypto.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
import os
from .base import BaseTest
def is_rlimit_memlock_too_low() -> bool:
"""On supported systems, return true if the MEMLOCK limit is too low to
run the crypto test."""
try:
import resource
ex... | 64 | 2,362 |
kitty | kitty_tests/check_build.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
import json
import os
import shutil
import stat
import subprocess
import sys
import tempfile
import textwrap
import unittest
from functools import partial
from .base import BaseTest
class TestBuild(BaseTest):
def test... | 245 | 10,764 |
kitty | kitty/types.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
from collections.abc import Callable, Iterator, Mapping, Sequence
from enum import Enum
from functools import update_wrapper
from typing import TYPE_CHECKING, Any, Literal, NamedTuple, TypedDict, TypeVar, Union, cast
if TYPE... | 277 | 7,038 |
kitty | kitty/open_actions.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
import os
import posixpath
import shlex
from collections.abc import Iterable, Iterator
from contextlib import suppress
from typing import Any, NamedTuple
from urllib.parse import ParseResult, unquote, urlparse
from .conf.ut... | 315 | 9,385 |
kitty | kitty/notifications.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2024, Kovid Goyal <kovid at kovidgoyal.net>
import os
import re
from collections import OrderedDict
from collections.abc import Callable, Iterator, Sequence
from contextlib import suppress
from enum import Enum
from functools import partial
from itertools import count
... | 1,113 | 47,959 |
kitty | kitty/search_query_parser.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
import re
from collections.abc import Callable, Iterator, Sequence
from enum import Enum
from functools import lru_cache
from gettext import gettext as _
from typing import NamedTuple, TypeVar, cast
from .types import run_onc... | 301 | 9,976 |
kitty | kitty/clipboard.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
import io
import os
from collections.abc import Callable, Mapping
from enum import Enum, IntEnum
from gettext import gettext as _
from tempfile import TemporaryFile
from typing import IO, NamedTuple, Union
from .conf.utils i... | 686 | 26,707 |
kitty | kitty/progress.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net>
from enum import Enum
from .fast_data_types import monotonic
from .utils import log_error
class ProgressState(Enum):
unset = 0
set = 1
error = 2
indeterminate = 3
paused = 4
class Progress:
state... | 55 | 1,622 |
kitty | kitty/main.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
import json
import locale
import os
import shutil
import sys
from collections.abc import Generator, Sequence
from contextlib import contextmanager, suppress
from gettext import gettext as _
from .boss import Boss
from .chil... | 667 | 26,459 |
kitty | kitty/update_check.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2019, Kovid Goyal <kovid at kovidgoyal.net>
import os
import subprocess
import time
from contextlib import suppress
from typing import NamedTuple
from urllib.request import urlopen
from .config import atomic_save
from .constants import Version, cache_dir, clear_handle... | 126 | 4,020 |
kitty | kitty/utils.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
import fcntl
import math
import os
import re
import string
import sys
from collections.abc import Callable, Generator, Iterable, Iterator, Mapping, Sequence
from contextlib import contextmanager, suppress
from functools impo... | 1,270 | 37,498 |
kitty | kitty/child.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
import os
import sys
import termios
from collections import defaultdict
from collections.abc import Generator, Iterable, Mapping, Sequence
from contextlib import contextmanager, suppress
from itertools import count
from time... | 710 | 26,536 |
kitty | kitty/marks.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
import re
from collections.abc import Callable, Generator, Iterable, Sequence
from re import Pattern
from typing import Union
from .fast_data_types import set_uint_at_address
from .utils import resolve_custom_file
MarkerFun... | 81 | 2,978 |
kitty | kitty/rgb.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
from .fast_data_types import Color
def alpha_blend_channel(top_color: int, bottom_color: int, alpha: float) -> int:
return int(alpha * top_color + (1 - alpha) * bottom_color)
def alpha_blend(top_color: Color, bottom_... | 39 | 1,065 |
kitty | kitty/borders.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
from collections.abc import Iterable
from enum import IntFlag
from functools import partial
from typing import NamedTuple
from .fast_data_types import current_focused_os_window_id, get_options, set_borders_rects
from .typin... | 125 | 4,772 |
kitty | kitty/window.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
import json
import os
import re
import sys
import weakref
from collections import deque
from collections.abc import Callable, Generator, Iterable, Iterator, Sequence
from contextlib import contextmanager, suppress
from enum ... | 2,882 | 114,602 |
kitty | kitty/tabs.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
import json
import math
import os
import re
import stat
import weakref
from collections import deque
from collections.abc import Callable, Generator, Iterable, Iterator, Sequence
from contextlib import suppress
from functool... | 2,272 | 94,691 |
kitty | kitty/window_list.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
import weakref
from collections import deque
from collections.abc import Iterator, Sequence
from contextlib import suppress
from itertools import count
from typing import Any, Deque, Union
from .fast_data_types import Color,... | 569 | 20,581 |
kitty | kitty/keys.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
from collections.abc import Callable, Iterable, Iterator
from gettext import gettext as _
from typing import TYPE_CHECKING, Any, Optional
from .constants import is_macos
from .fast_data_types import (
GLFW_MOD_ALT,
... | 325 | 13,728 |
kitty | kitty/cli_stub.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
from collections.abc import Sequence
class CLIOptions:
def __repr__(self) -> str:
return repr(vars(self))
LaunchCLIOptions = AskCLIOptions = ClipboardCLIOptions = DiffCLIOptions = CLIOptions
HintsCLIOptions =... | 112 | 3,120 |
kitty | kitty/constants.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
import os
import pwd
import sys
from collections.abc import Iterator
from contextlib import suppress
from typing import TYPE_CHECKING, Any, NamedTuple, Optional
from .types import run_once
if TYPE_CHECKING:
from .optio... | 337 | 10,471 |
kitty | kitty/boss.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
# Imports {{{
import base64
import json
import os
import re
import socket
import subprocess
import sys
from collections import deque
from collections.abc import Callable, Container, Generator, Iterable, Iterator, Sequence
fr... | 4,034 | 169,297 |
kitty | kitty/bash.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
from .utils import shlex_split
def decode_ansi_c_quoted_string(text: str) -> str:
return next(shlex_split(text, True))
def decode_double_quoted_string(text: str, pos: int) -> tuple[str, int]:
escapes = r'"\$`'
... | 67 | 1,742 |
kitty | kitty/simple_cli_definitions.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net>
# This module must be runnable by a vanilla python interpreter
# as it is used to generate C code when building kitty
import re
import sys
from collections.abc import Iterator, Sequence
from enum import Enum, auto
from funct... | 818 | 30,246 |
kitty | kitty/remote_control.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
import base64
import hmac
import json
import os
import re
import sys
from collections.abc import Iterable, Iterator, Sequence
from contextlib import suppress
from functools import lru_cache, partial
from time import time_ns
... | 532 | 19,467 |
kitty | kitty/debug_config.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
import os
import re
import socket
import sys
import termios
import time
from collections.abc import Callable, Iterator, Sequence
from contextlib import suppress
from functools import partial
from pprint import pformat
from ty... | 353 | 13,460 |
kitty | kitty/client.py | .py | #!/usr/bin/env python
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
# Replay the log from --dump-commands. To use first run
# kitty --dump-commands > file.txt
# then run
# kitty --replay-commands file.txt
# will replay the commands and pause at the end waiting for user to press enter
import... | 363 | 8,199 |
kitty | kitty/file_transmission.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
import errno
import hmac
import inspect
import io
import json
import os
import re
import stat
import tempfile
from base64 import b85decode
from collections import defaultdict, deque
from collections.abc import Callable, Itera... | 1,266 | 50,896 |
kitty | kitty/guess_mime_type.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
import os
import stat
from contextlib import suppress
known_extensions = {
'asciidoc': 'text/asciidoctor',
'conf': 'text/config',
'md': 'text/markdown',
'pyj': 'text/rapydscript-ng',
'recipe': 'text/pytho... | 110 | 2,890 |
kitty | kitty/multiprocessing.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
# Monkeypatch the stdlib multiprocessing module to work with the embedded python
# in kitty, when using the spawn launcher.
import os
from collections.abc import Callable, Sequence
from concurrent.futures import ProcessPool... | 84 | 2,982 |
kitty | kitty/shm.py | .py | #!/usr/bin/env python
# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
# This is present in the python stdlib (version 3.7) in
# multiprocessing.shared_memory. However, it is crippled in various ways, most
# notably using extremely small filenames.
import errno
import mmap
import os
import secr... | 192 | 5,918 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.