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
python-prompt-toolkit
examples/choices/default.py
.py
from __future__ import annotations from prompt_toolkit.formatted_text import HTML from prompt_toolkit.shortcuts import choice def main() -> None: result = choice( message=HTML("<u>Please select a dish</u>:"), options=[ ("pizza", "Pizza with mushrooms"), ("salad", "Salad wi...
22
467
python-prompt-toolkit
examples/choices/gray-frame-on-accept.py
.py
from __future__ import annotations from prompt_toolkit.formatted_text import HTML from prompt_toolkit.shortcuts import choice from prompt_toolkit.styles import Style def main() -> None: style = Style.from_dict( { "selected-option": "bold", "frame.border": "#ff4444", "a...
32
710
python-prompt-toolkit
examples/choices/color.py
.py
from __future__ import annotations from prompt_toolkit.formatted_text import HTML from prompt_toolkit.shortcuts import choice from prompt_toolkit.styles import Style def main() -> None: style = Style.from_dict( { "input-selection": "fg:#ff0000", "number": "fg:#884444 bold", ...
35
823
python-prompt-toolkit
examples/choices/frame-and-bottom-toolbar.py
.py
from __future__ import annotations from prompt_toolkit.filters import is_done from prompt_toolkit.formatted_text import HTML from prompt_toolkit.shortcuts import choice from prompt_toolkit.styles import Style def main() -> None: style = Style.from_dict( { "frame.border": "#ff4444", ...
41
1,190
python-prompt-toolkit
examples/choices/mouse-support.py
.py
from __future__ import annotations from prompt_toolkit.formatted_text import HTML from prompt_toolkit.shortcuts import choice def main() -> None: result = choice( message=HTML("<u>Please select a dish</u>:"), options=[ ("pizza", "Pizza with mushrooms"), ("salad", "Salad wi...
22
470
python-prompt-toolkit
examples/choices/simple-selection.py
.py
from __future__ import annotations from prompt_toolkit.shortcuts import choice def main() -> None: result = choice( message="Please select a dish:", options=[ ("pizza", "Pizza with mushrooms"), ("salad", "Salad with tomatoes"), ("sushi", "Sushi"), ], ...
20
382
python-prompt-toolkit
examples/choices/with-frame.py
.py
from __future__ import annotations from prompt_toolkit.filters import is_done from prompt_toolkit.formatted_text import HTML from prompt_toolkit.shortcuts import choice from prompt_toolkit.styles import Style def main() -> None: style = Style.from_dict( { "frame.border": "#884444", ...
35
904
python-prompt-toolkit
examples/choices/many-choices.py
.py
from __future__ import annotations from prompt_toolkit.shortcuts import choice def main() -> None: result = choice( message="Please select an option:", options=[(i, f"Option {i}") for i in range(1, 100)], ) print(result) if __name__ == "__main__": main()
16
292
python-prompt-toolkit
src/prompt_toolkit/renderer.py
.py
""" Renders the command line on the console. (Redraws parts of the input line that were changed.) """ from __future__ import annotations from asyncio import FIRST_COMPLETED, Future, ensure_future, sleep, wait from collections import deque from collections.abc import Callable, Hashable from enum import Enum from typin...
822
29,419
python-prompt-toolkit
src/prompt_toolkit/patch_stdout.py
.py
""" patch_stdout ============ This implements a context manager that ensures that print statements within it won't destroy the user interface. The context manager will replace `sys.stdout` by something that draws the output above the current prompt, rather than overwriting the UI. Usage:: with patch_stdout(appli...
302
9,646
python-prompt-toolkit
src/prompt_toolkit/selection.py
.py
""" Data structures for the selection. """ from __future__ import annotations from enum import Enum __all__ = [ "SelectionType", "PasteMode", "SelectionState", ] class SelectionType(Enum): """ Type of selection. """ #: Characters. (Visual in Vi.) CHARACTERS = "CHARACTERS" #: W...
59
1,274
python-prompt-toolkit
src/prompt_toolkit/utils.py
.py
from __future__ import annotations import os import signal import sys import threading from collections import deque from collections.abc import Callable, Generator from contextlib import AbstractContextManager from typing import ( Generic, TypeVar, ) from wcwidth import wcwidth __all__ = [ "Event", ...
325
8,657
python-prompt-toolkit
src/prompt_toolkit/mouse_events.py
.py
""" Mouse events. How it works ------------ The renderer has a 2 dimensional grid of mouse event handlers. (`prompt_toolkit.layout.MouseHandlers`.) When the layout is rendered, the `Window` class will make sure that this grid will also be filled with callbacks. For vt100 terminals, mouse events are received through ...
86
2,473
python-prompt-toolkit
src/prompt_toolkit/token.py
.py
""" """ from __future__ import annotations __all__ = [ "ZeroWidthEscape", ] ZeroWidthEscape = "[ZeroWidthEscape]"
10
121
python-prompt-toolkit
src/prompt_toolkit/cursor_shapes.py
.py
from __future__ import annotations from abc import ABC, abstractmethod from collections.abc import Callable from enum import Enum from typing import TYPE_CHECKING, Any from prompt_toolkit.enums import EditingMode from prompt_toolkit.key_binding.vi_state import InputMode if TYPE_CHECKING: from .application import...
119
3,736
python-prompt-toolkit
src/prompt_toolkit/win32_types.py
.py
from __future__ import annotations from ctypes import Structure, Union, c_char, c_long, c_short, c_ulong from ctypes.wintypes import BOOL, DWORD, LPVOID, WCHAR, WORD from typing import TYPE_CHECKING # Input/Output standard device numbers. Note that these are not handle objects. # It's the `windll.kernel32.GetStdHandl...
230
5,551
python-prompt-toolkit
src/prompt_toolkit/__init__.py
.py
""" prompt_toolkit ============== Author: Jonathan Slenders Description: prompt_toolkit is a Library for building powerful interactive command lines in Python. It can be a replacement for GNU Readline, but it can be much more than that. See the examples directory to learn about the usage. ...
88
2,088
python-prompt-toolkit
src/prompt_toolkit/keys.py
.py
from __future__ import annotations from enum import Enum __all__ = [ "Keys", "ALL_KEYS", ] class Keys(str, Enum): """ List of keys for use in key bindings. Note that this is an "StrEnum", all values can be compared against strings. """ value: str Escape = "escape" # Also Cont...
223
4,916
python-prompt-toolkit
src/prompt_toolkit/enums.py
.py
from __future__ import annotations from enum import Enum class EditingMode(Enum): # The set of key bindings that is active. VI = "VI" EMACS = "EMACS" #: Name of the search buffer. SEARCH_BUFFER = "SEARCH_BUFFER" #: Name of the default buffer. DEFAULT_BUFFER = "DEFAULT_BUFFER" #: Name of the system bu...
20
358
python-prompt-toolkit
src/prompt_toolkit/buffer.py
.py
""" Data structures for the Buffer. It holds the text, cursor position, history, etc... """ from __future__ import annotations import asyncio import logging import os import re import shlex import shutil import subprocess import tempfile from collections import deque from collections.abc import Callable, Coroutine, I...
2,031
74,540
python-prompt-toolkit
src/prompt_toolkit/auto_suggest.py
.py
""" `Fish-style <http://fishshell.com/>`_ like auto-suggestion. While a user types input in a certain buffer, suggestions are generated (asynchronously.) Usually, they are displayed after the input. When the cursor presses the right arrow and the cursor is at the end of the input, the suggestion will be inserted. If...
179
5,825
python-prompt-toolkit
src/prompt_toolkit/data_structures.py
.py
from __future__ import annotations from typing import NamedTuple __all__ = [ "Point", "Size", ] class Point(NamedTuple): x: int y: int class Size(NamedTuple): rows: int columns: int
19
212
python-prompt-toolkit
src/prompt_toolkit/search.py
.py
""" Search operations. For the key bindings implementation with attached filters, check `prompt_toolkit.key_binding.bindings.search`. (Use these for new key bindings instead of calling these function directly.) """ from __future__ import annotations from enum import Enum from typing import TYPE_CHECKING from .appli...
227
6,951
python-prompt-toolkit
src/prompt_toolkit/history.py
.py
""" Implementations for the history of a `Buffer`. NOTE: There is no `DynamicHistory`: This doesn't work well, because the `Buffer` needs to be able to attach an event handler to the event when a history entry is loaded. This loading can be done asynchronously and making the history swappable would ...
308
9,486
python-prompt-toolkit
src/prompt_toolkit/log.py
.py
""" Logging configuration. """ from __future__ import annotations import logging __all__ = [ "logger", ] logger = logging.getLogger(__package__)
14
153
python-prompt-toolkit
src/prompt_toolkit/document.py
.py
""" The `Document` that implements all the text operations/querying. """ from __future__ import annotations import bisect import re import string import weakref from collections.abc import Callable, Iterable from re import Pattern from typing import NoReturn, cast from .clipboard import ClipboardData from .filters i...
1,184
40,568
python-prompt-toolkit
src/prompt_toolkit/cache.py
.py
from __future__ import annotations from collections import deque from collections.abc import Callable, Hashable from functools import wraps from typing import Any, Generic, TypeVar, cast __all__ = [ "SimpleCache", "FastDictCache", "memoized", ] _T = TypeVar("_T", bound=Hashable) _U = TypeVar("_U") clas...
129
3,837
python-prompt-toolkit
src/prompt_toolkit/validation.py
.py
""" Input validation for a `Buffer`. (Validators will be called before accepting input.) """ from __future__ import annotations from abc import ABCMeta, abstractmethod from collections.abc import Callable from prompt_toolkit.eventloop import run_in_executor_with_context from .document import Document from .filters ...
193
5,816
python-prompt-toolkit
src/prompt_toolkit/application/application.py
.py
from __future__ import annotations import asyncio import contextvars import os import re import signal import sys import threading import time from asyncio import ( AbstractEventLoop, Future, Task, ensure_future, get_running_loop, sleep, ) from collections.abc import Callable, Coroutine, Genera...
1,632
63,381
python-prompt-toolkit
src/prompt_toolkit/application/__init__.py
.py
from __future__ import annotations from .application import Application from .current import ( AppSession, create_app_session, create_app_session_from_tty, get_app, get_app_or_none, get_app_session, set_app, ) from .dummy import DummyApplication from .run_in_terminal import in_terminal, run...
33
657
python-prompt-toolkit
src/prompt_toolkit/application/dummy.py
.py
from __future__ import annotations from collections.abc import Callable from prompt_toolkit.eventloop import InputHook from prompt_toolkit.formatted_text import AnyFormattedText from prompt_toolkit.input import DummyInput from prompt_toolkit.output import DummyOutput from .application import Application __all__ = [...
56
1,628
python-prompt-toolkit
src/prompt_toolkit/application/run_in_terminal.py
.py
""" Tools for running functions on the terminal above the current application or prompt. """ from __future__ import annotations from asyncio import Future, ensure_future from collections.abc import AsyncGenerator, Awaitable, Callable from contextlib import asynccontextmanager from typing import TypeVar from prompt_t...
119
3,794
python-prompt-toolkit
src/prompt_toolkit/application/current.py
.py
from __future__ import annotations from collections.abc import Generator from contextlib import contextmanager from contextvars import ContextVar from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from prompt_toolkit.input.base import Input from prompt_toolkit.output.base import Output from .applica...
197
6,236
python-prompt-toolkit
src/prompt_toolkit/shortcuts/utils.py
.py
from __future__ import annotations from asyncio.events import AbstractEventLoop from typing import TYPE_CHECKING, Any, TextIO from prompt_toolkit.application import Application from prompt_toolkit.application.current import get_app_or_none, get_app_session from prompt_toolkit.application.run_in_terminal import run_in...
240
6,950
python-prompt-toolkit
src/prompt_toolkit/shortcuts/__init__.py
.py
from __future__ import annotations from .choice_input import choice from .dialogs import ( button_dialog, checkboxlist_dialog, input_dialog, message_dialog, progress_dialog, radiolist_dialog, yes_no_dialog, ) from .progress_bar import ProgressBar, ProgressBarCounter from .prompt import ( ...
50
1,020
python-prompt-toolkit
src/prompt_toolkit/shortcuts/dialogs.py
.py
from __future__ import annotations import functools from collections.abc import Callable, Sequence from typing import Any, TypeVar from prompt_toolkit.application import Application from prompt_toolkit.application.current import get_app from prompt_toolkit.buffer import Buffer from prompt_toolkit.completion import Co...
332
9,049
python-prompt-toolkit
src/prompt_toolkit/shortcuts/prompt.py
.py
""" Line editing functionality. --------------------------- This provides a UI for a line input, similar to GNU Readline, libedit and linenoise. Either call the `prompt` function for every line input. Or create an instance of the :class:`.PromptSession` class and call the `prompt` method from that class. In the secon...
1,548
61,006
python-prompt-toolkit
src/prompt_toolkit/shortcuts/choice_input.py
.py
from __future__ import annotations from collections.abc import Sequence from typing import Generic, TypeVar from prompt_toolkit.application import Application from prompt_toolkit.filters import ( Condition, FilterOrBool, is_done, renderer_height_is_known, to_filter, ) from prompt_toolkit.formatted...
316
10,724
python-prompt-toolkit
src/prompt_toolkit/shortcuts/progress_bar/formatters.py
.py
""" Formatter classes for the progress bar. Each progress bar consists of a list of these formatters. """ from __future__ import annotations import datetime import time from abc import ABCMeta, abstractmethod from typing import TYPE_CHECKING from prompt_toolkit.formatted_text import ( HTML, AnyFormattedText,...
432
11,739
python-prompt-toolkit
src/prompt_toolkit/shortcuts/progress_bar/__init__.py
.py
from __future__ import annotations from .base import ProgressBar, ProgressBarCounter from .formatters import ( Bar, Formatter, IterationsPerSecond, Label, Percentage, Progress, Rainbow, SpinningWheel, Text, TimeElapsed, TimeLeft, ) __all__ = [ "ProgressBar", "Progre...
34
540
python-prompt-toolkit
src/prompt_toolkit/shortcuts/progress_bar/base.py
.py
""" Progress bar implementation on top of prompt_toolkit. :: with ProgressBar(...) as pb: for item in pb(data): ... """ from __future__ import annotations import contextvars import datetime import functools import os import signal import threading import traceback from collections.abc import...
446
14,409
python-prompt-toolkit
src/prompt_toolkit/widgets/menus.py
.py
from __future__ import annotations from collections.abc import Callable, Iterable, Sequence from prompt_toolkit.application.current import get_app from prompt_toolkit.filters import Condition from prompt_toolkit.formatted_text.base import OneStyleAndTextTuple, StyleAndTextTuples from prompt_toolkit.key_binding.key_bi...
375
13,428
python-prompt-toolkit
src/prompt_toolkit/widgets/toolbars.py
.py
from __future__ import annotations from typing import Any from prompt_toolkit.application.current import get_app from prompt_toolkit.buffer import Buffer from prompt_toolkit.enums import SYSTEM_BUFFER from prompt_toolkit.filters import ( Condition, FilterOrBool, emacs_mode, has_arg, has_completion...
371
12,178
python-prompt-toolkit
src/prompt_toolkit/widgets/__init__.py
.py
""" Collection of reusable components for building full screen applications. These are higher level abstractions on top of the `prompt_toolkit.layout` module. Most of these widgets implement the ``__pt_container__`` method, which makes it possible to embed these in the layout like any other container. """ from __futu...
64
1,218
python-prompt-toolkit
src/prompt_toolkit/widgets/dialogs.py
.py
""" Collection of reusable components for building full screen applications. """ from __future__ import annotations from collections.abc import Sequence from prompt_toolkit.filters import has_completions, has_focus from prompt_toolkit.formatted_text import AnyFormattedText from prompt_toolkit.key_binding.bindings.fo...
109
3,389
python-prompt-toolkit
src/prompt_toolkit/widgets/base.py
.py
""" Collection of reusable components for building full screen applications. All of these widgets implement the ``__pt_container__`` method, which makes them usable in any situation where we are expecting a `prompt_toolkit` container object. .. warning:: At this point, the API for these widgets is considered uns...
1,082
35,572
python-prompt-toolkit
src/prompt_toolkit/output/color_depth.py
.py
from __future__ import annotations import os from enum import Enum __all__ = [ "ColorDepth", ] class ColorDepth(str, Enum): """ Possible color depth values for the output. """ value: str #: One color only. DEPTH_1_BIT = "DEPTH_1_BIT" #: ANSI Colors. DEPTH_4_BIT = "DEPTH_4_BIT"...
65
1,569
python-prompt-toolkit
src/prompt_toolkit/output/__init__.py
.py
from __future__ import annotations from .base import DummyOutput, Output from .color_depth import ColorDepth from .defaults import create_output __all__ = [ # Base. "Output", "DummyOutput", # Color depth. "ColorDepth", # Defaults. "create_output", ]
16
280
python-prompt-toolkit
src/prompt_toolkit/output/vt100.py
.py
""" Output for vt100 terminals. A lot of thanks, regarding outputting of colors, goes to the Pygments project: (We don't rely on Pygments anymore, because many things are very custom, and everything has been highly optimized.) http://pygments.org/ """ from __future__ import annotations import io import os import sys...
762
23,485
python-prompt-toolkit
src/prompt_toolkit/output/plain_text.py
.py
from __future__ import annotations from typing import TextIO from prompt_toolkit.cursor_shapes import CursorShape from prompt_toolkit.data_structures import Size from prompt_toolkit.styles import Attrs from .base import Output from .color_depth import ColorDepth from .flush_stdout import flush_stdout __all__ = ["Pl...
144
3,296
python-prompt-toolkit
src/prompt_toolkit/output/flush_stdout.py
.py
from __future__ import annotations import errno import os import sys from collections.abc import Iterator from contextlib import contextmanager from typing import IO, TextIO __all__ = ["flush_stdout"] def flush_stdout(stdout: TextIO, data: str) -> None: # If the IO object has an `encoding` and `buffer` attribut...
89
3,263
python-prompt-toolkit
src/prompt_toolkit/output/defaults.py
.py
from __future__ import annotations import sys from typing import TYPE_CHECKING, TextIO, cast from prompt_toolkit.utils import ( get_bell_environment_variable, get_term_environment_variable, is_conemu_ansi, ) from .base import DummyOutput, Output from .color_depth import ColorDepth from .plain_text import...
107
3,689
python-prompt-toolkit
src/prompt_toolkit/output/conemu.py
.py
from __future__ import annotations import sys assert sys.platform == "win32" from typing import Any, TextIO from prompt_toolkit.data_structures import Size from .base import Output from .color_depth import ColorDepth from .vt100 import Vt100_Output from .win32 import Win32Output __all__ = [ "ConEmuOutput", ] ...
66
1,865
python-prompt-toolkit
src/prompt_toolkit/output/windows10.py
.py
from __future__ import annotations import sys assert sys.platform == "win32" from ctypes import byref, windll from ctypes.wintypes import DWORD, HANDLE from typing import Any, TextIO from prompt_toolkit.data_structures import Size from prompt_toolkit.win32_types import STD_OUTPUT_HANDLE from .base import Output fr...
134
4,362
python-prompt-toolkit
src/prompt_toolkit/output/base.py
.py
""" Interface for an output. """ from __future__ import annotations from abc import ABCMeta, abstractmethod from typing import TextIO from prompt_toolkit.cursor_shapes import CursorShape from prompt_toolkit.data_structures import Size from prompt_toolkit.styles import Attrs from .color_depth import ColorDepth __al...
333
8,348
python-prompt-toolkit
src/prompt_toolkit/output/win32.py
.py
from __future__ import annotations import sys assert sys.platform == "win32" import os from collections.abc import Callable from ctypes import ArgumentError, byref, c_char, c_long, c_uint, c_ulong, pointer from ctypes.wintypes import DWORD, HANDLE from typing import TextIO, TypeVar from prompt_toolkit.cursor_shapes...
686
22,666
python-prompt-toolkit
src/prompt_toolkit/lexers/pygments.py
.py
""" Adaptor classes for using Pygments lexers within prompt_toolkit. This includes syntax synchronization code, so that we don't have to start lexing at the beginning of a document, when displaying a very large text. """ from __future__ import annotations import re from abc import ABCMeta, abstractmethod from collec...
330
11,942
python-prompt-toolkit
src/prompt_toolkit/lexers/__init__.py
.py
""" Lexer interface and implementations. Used for syntax highlighting. """ from __future__ import annotations from .base import DynamicLexer, Lexer, SimpleLexer from .pygments import PygmentsLexer, RegexSync, SyncFromStart, SyntaxSync __all__ = [ # Base. "Lexer", "SimpleLexer", "DynamicLexer", # ...
22
409
python-prompt-toolkit
src/prompt_toolkit/lexers/base.py
.py
""" Base classes for prompt_toolkit lexers. """ from __future__ import annotations from abc import ABCMeta, abstractmethod from collections.abc import Callable, Hashable from prompt_toolkit.document import Document from prompt_toolkit.formatted_text.base import StyleAndTextTuples __all__ = [ "Lexer", "Simpl...
86
2,359
python-prompt-toolkit
src/prompt_toolkit/clipboard/__init__.py
.py
from __future__ import annotations from .base import Clipboard, ClipboardData, DummyClipboard, DynamicClipboard from .in_memory import InMemoryClipboard # We are not importing `PyperclipClipboard` here, because it would require the # `pyperclip` module to be present. # from .pyperclip import PyperclipClipboard __al...
18
439
python-prompt-toolkit
src/prompt_toolkit/clipboard/in_memory.py
.py
from __future__ import annotations from collections import deque from .base import Clipboard, ClipboardData __all__ = [ "InMemoryClipboard", ] class InMemoryClipboard(Clipboard): """ Default clipboard implementation. Just keep the data in memory. This implements a kill-ring, for Emacs mode. ...
45
1,060
python-prompt-toolkit
src/prompt_toolkit/clipboard/pyperclip.py
.py
from __future__ import annotations import pyperclip from prompt_toolkit.selection import SelectionType from .base import Clipboard, ClipboardData __all__ = [ "PyperclipClipboard", ] class PyperclipClipboard(Clipboard): """ Clipboard that synchronizes with the Windows/Mac/Linux system clipboard, us...
43
1,160
python-prompt-toolkit
src/prompt_toolkit/clipboard/base.py
.py
""" Clipboard for command line interface. """ from __future__ import annotations from abc import ABCMeta, abstractmethod from collections.abc import Callable from prompt_toolkit.selection import SelectionType __all__ = [ "Clipboard", "ClipboardData", "DummyClipboard", "DynamicClipboard", ] class C...
110
2,524
python-prompt-toolkit
src/prompt_toolkit/eventloop/utils.py
.py
from __future__ import annotations import asyncio import contextvars import sys import time from asyncio import get_running_loop from collections.abc import Awaitable, Callable from types import TracebackType from typing import Any, TypeVar, cast __all__ = [ "run_in_executor_with_context", "call_soon_threadsa...
103
3,227
python-prompt-toolkit
src/prompt_toolkit/eventloop/__init__.py
.py
from __future__ import annotations from .async_generator import aclosing, generator_to_async_generator from .inputhook import ( InputHook, InputHookContext, InputHookSelector, new_eventloop_with_inputhook, set_eventloop_with_inputhook, ) from .utils import ( call_soon_threadsafe, get_traceb...
32
730
python-prompt-toolkit
src/prompt_toolkit/eventloop/inputhook.py
.py
""" Similar to `PyOS_InputHook` of the Python API, we can plug in an input hook in the asyncio event loop. The way this works is by using a custom 'selector' that runs the other event loop until the real selector is ready. It's the responsibility of this event hook to return when there is input ready. There are two w...
194
6,148
python-prompt-toolkit
src/prompt_toolkit/eventloop/win32.py
.py
from __future__ import annotations import sys assert sys.platform == "win32" from ctypes import pointer from ..utils import SPHINX_AUTODOC_RUNNING # Do not import win32-specific stuff when generating documentation. # Otherwise RTD would be unable to generate docs for this module. if not SPHINX_AUTODOC_RUNNING: ...
73
2,286
python-prompt-toolkit
src/prompt_toolkit/eventloop/async_generator.py
.py
""" Implementation for async generators. """ from __future__ import annotations from asyncio import get_running_loop from collections.abc import AsyncGenerator, Callable, Iterable from contextlib import asynccontextmanager from queue import Empty, Full, Queue from typing import Any, TypeVar from .utils import run_in...
127
3,960
python-prompt-toolkit
src/prompt_toolkit/completion/filesystem.py
.py
from __future__ import annotations import os from collections.abc import Callable, Iterable from prompt_toolkit.completion import CompleteEvent, Completer, Completion from prompt_toolkit.document import Document __all__ = [ "PathCompleter", "ExecutableCompleter", ] class PathCompleter(Completer): """ ...
119
3,958
python-prompt-toolkit
src/prompt_toolkit/completion/deduplicate.py
.py
from __future__ import annotations from collections.abc import Iterable from prompt_toolkit.document import Document from .base import CompleteEvent, Completer, Completion __all__ = ["DeduplicateCompleter"] class DeduplicateCompleter(Completer): """ Wrapper around a completer that removes duplicates. Only...
46
1,445
python-prompt-toolkit
src/prompt_toolkit/completion/__init__.py
.py
from __future__ import annotations from .base import ( CompleteEvent, Completer, Completion, ConditionalCompleter, DummyCompleter, DynamicCompleter, ThreadedCompleter, get_common_complete_suffix, merge_completers, ) from .deduplicate import DeduplicateCompleter from .filesystem impo...
44
992
python-prompt-toolkit
src/prompt_toolkit/completion/word_completer.py
.py
from __future__ import annotations from collections.abc import Callable, Iterable, Mapping, Sequence from re import Pattern from prompt_toolkit.completion import CompleteEvent, Completer, Completion from prompt_toolkit.document import Document from prompt_toolkit.formatted_text import AnyFormattedText __all__ = [ ...
96
3,458
python-prompt-toolkit
src/prompt_toolkit/completion/nested.py
.py
""" Nestedcompleter for completion of hierarchical data structures. """ from __future__ import annotations from collections.abc import Iterable, Mapping from typing import Any from prompt_toolkit.completion import CompleteEvent, Completer, Completion from prompt_toolkit.completion.word_completer import WordCompleter...
111
3,855
python-prompt-toolkit
src/prompt_toolkit/completion/base.py
.py
""" """ from __future__ import annotations from abc import ABCMeta, abstractmethod from collections.abc import AsyncGenerator, Callable, Iterable, Sequence from prompt_toolkit.document import Document from prompt_toolkit.eventloop import aclosing, generator_to_async_generator from prompt_toolkit.filters import Filte...
439
16,112
python-prompt-toolkit
src/prompt_toolkit/completion/fuzzy_completer.py
.py
from __future__ import annotations import re from collections.abc import Callable, Iterable, Mapping, Sequence from typing import NamedTuple from prompt_toolkit.document import Document from prompt_toolkit.filters import FilterOrBool, to_filter from prompt_toolkit.formatted_text import AnyFormattedText, StyleAndTextT...
215
7,790
python-prompt-toolkit
src/prompt_toolkit/input/win32_pipe.py
.py
from __future__ import annotations import sys assert sys.platform == "win32" from collections.abc import Callable, Iterator from contextlib import AbstractContextManager, contextmanager from ctypes import windll from ctypes.wintypes import HANDLE from prompt_toolkit.eventloop.win32 import create_win32_event from ....
159
4,763
python-prompt-toolkit
src/prompt_toolkit/input/posix_pipe.py
.py
from __future__ import annotations import sys assert sys.platform != "win32" import os from collections.abc import Iterator from contextlib import AbstractContextManager, contextmanager from typing import TextIO, cast from ..utils import DummyContext from .base import PipeInput from .vt100 import Vt100Input __all_...
120
3,209
python-prompt-toolkit
src/prompt_toolkit/input/ansi_escape_sequences.py
.py
""" Mappings from VT100 (ANSI) escape sequences to the corresponding prompt_toolkit keys. We are not using the terminfo/termcap databases to detect the ANSI escape sequences for the input. Instead, we recognize 99% of the most common sequences. This works well, because in practice, every modern terminal is mostly Xter...
345
13,663
python-prompt-toolkit
src/prompt_toolkit/input/__init__.py
.py
from __future__ import annotations from .base import DummyInput, Input, PipeInput from .defaults import create_input, create_pipe_input __all__ = [ # Base. "Input", "PipeInput", "DummyInput", # Defaults. "create_input", "create_pipe_input", ]
15
273
python-prompt-toolkit
src/prompt_toolkit/input/vt100.py
.py
from __future__ import annotations import sys assert sys.platform != "win32" import contextlib import io import termios import tty from asyncio import AbstractEventLoop, get_running_loop from collections.abc import Callable, Generator from contextlib import AbstractContextManager from typing import TextIO from ..ke...
316
10,765
python-prompt-toolkit
src/prompt_toolkit/input/vt100_parser.py
.py
""" Parser for VT100 input stream. """ from __future__ import annotations import re from collections.abc import Callable, Generator from ..key_binding.key_processor import KeyPress from ..keys import Keys from .ansi_escape_sequences import ANSI_SEQUENCES __all__ = [ "Vt100Parser", ] # Regex matching any CPR r...
251
8,410
python-prompt-toolkit
src/prompt_toolkit/input/posix_utils.py
.py
from __future__ import annotations import os import select from codecs import getincrementaldecoder __all__ = [ "PosixStdinReader", ] class PosixStdinReader: """ Wrapper around stdin which reads (nonblocking) the next available 1024 bytes and decodes it. Note that you can't be sure that the inp...
98
3,973
python-prompt-toolkit
src/prompt_toolkit/input/defaults.py
.py
from __future__ import annotations import io import sys from contextlib import AbstractContextManager from typing import TextIO from .base import DummyInput, Input, PipeInput __all__ = [ "create_input", "create_pipe_input", ] def create_input(stdin: TextIO | None = None, always_prefer_tty: bool = False) ->...
81
2,538
python-prompt-toolkit
src/prompt_toolkit/input/typeahead.py
.py
r""" Store input key strokes if we did read more than was required. The input classes `Vt100Input` and `Win32Input` read the input text in chunks of a few kilobytes. This means that if we read input from stdin, it could be that we read a couple of lines (with newlines in between) at once. This creates a problem: pote...
79
2,545
python-prompt-toolkit
src/prompt_toolkit/input/base.py
.py
""" Abstraction of CLI Input. """ from __future__ import annotations from abc import ABCMeta, abstractmethod from collections.abc import Callable, Generator from contextlib import AbstractContextManager, contextmanager from prompt_toolkit.key_binding import KeyPress __all__ = [ "Input", "PipeInput", "Du...
159
4,139
python-prompt-toolkit
src/prompt_toolkit/input/win32.py
.py
from __future__ import annotations import os import sys from abc import abstractmethod from asyncio import get_running_loop from contextlib import AbstractContextManager, contextmanager from ..utils import SPHINX_AUTODOC_RUNNING assert sys.platform == "win32" # Do not import win32-specific stuff when generating doc...
908
31,491
python-prompt-toolkit
src/prompt_toolkit/key_binding/__init__.py
.py
from __future__ import annotations from .key_bindings import ( ConditionalKeyBindings, DynamicKeyBindings, KeyBindings, KeyBindingsBase, merge_key_bindings, ) from .key_processor import KeyPress, KeyPressEvent __all__ = [ # key_bindings. "ConditionalKeyBindings", "DynamicKeyBindings", ...
23
447
python-prompt-toolkit
src/prompt_toolkit/key_binding/key_bindings.py
.py
""" Key bindings registry. A `KeyBindings` object is a container that holds a list of key bindings. It has a very efficient internal data structure for checking which key bindings apply for a pressed key. Typical usage:: kb = KeyBindings() @kb.add(Keys.ControlX, Keys.ControlC, filter=INSERT) def handler...
669
20,915
python-prompt-toolkit
src/prompt_toolkit/key_binding/defaults.py
.py
""" Default key bindings.:: key_bindings = load_key_bindings() app = Application(key_bindings=key_bindings) """ from __future__ import annotations from prompt_toolkit.filters import buffer_has_focus from prompt_toolkit.key_binding.bindings.basic import load_basic_bindings from prompt_toolkit.key_binding.bind...
64
1,975
python-prompt-toolkit
src/prompt_toolkit/key_binding/digraphs.py
.py
""" Vi Digraphs. This is a list of special characters that can be inserted in Vi insert mode by pressing Control-K followed by to normal characters. Taken from Neovim and translated to Python: https://raw.githubusercontent.com/neovim/neovim/master/src/nvim/digraph.c """ from __future__ import annotations __all__ = [...
1,379
32,785
python-prompt-toolkit
src/prompt_toolkit/key_binding/vi_state.py
.py
from __future__ import annotations from collections.abc import Callable from enum import Enum from typing import TYPE_CHECKING from prompt_toolkit.clipboard import ClipboardData if TYPE_CHECKING: from .bindings.vi import TextObject from .key_processor import KeyPressEvent __all__ = [ "InputMode", "C...
109
3,364
python-prompt-toolkit
src/prompt_toolkit/key_binding/emacs_state.py
.py
from __future__ import annotations from .key_processor import KeyPress __all__ = [ "EmacsState", ] class EmacsState: """ Mutable class to hold Emacs specific state. """ def __init__(self) -> None: # Simple macro recording. (Like Readline does.) # (For Emacs mode.) self.m...
37
884
python-prompt-toolkit
src/prompt_toolkit/key_binding/key_processor.py
.py
""" An :class:`~.KeyProcessor` receives callbacks for the keystrokes parsed from the input in the :class:`~prompt_toolkit.inputstream.InputStream` instance. The `KeyProcessor` will according to the implemented keybindings call the correct callbacks when new key presses are feed through `feed`. """ from __future__ imp...
528
17,582
python-prompt-toolkit
src/prompt_toolkit/key_binding/bindings/page_navigation.py
.py
""" Key bindings for extra page navigation: bindings for up/down scrolling through long pages, like in Emacs or Vi. """ from __future__ import annotations from prompt_toolkit.filters import buffer_has_focus, emacs_mode, vi_mode from prompt_toolkit.key_binding.key_bindings import ( ConditionalKeyBindings, KeyB...
86
2,392
python-prompt-toolkit
src/prompt_toolkit/key_binding/bindings/scroll.py
.py
""" Key bindings, for scrolling up and down through pages. This are separate bindings, because GNU readline doesn't have them, but they are very useful for navigating through long multiline buffers, like in Vi, Emacs, etc... """ from __future__ import annotations from prompt_toolkit.key_binding.key_processor import ...
191
5,613
python-prompt-toolkit
src/prompt_toolkit/key_binding/bindings/mouse.py
.py
from __future__ import annotations import sys from typing import TYPE_CHECKING from prompt_toolkit.data_structures import Point from prompt_toolkit.key_binding.key_processor import KeyPress, KeyPressEvent from prompt_toolkit.keys import Keys from prompt_toolkit.mouse_events import ( MouseButton, MouseEvent, ...
349
18,586
python-prompt-toolkit
src/prompt_toolkit/key_binding/bindings/named_commands.py
.py
""" Key bindings which are also known by GNU Readline by the given names. See: http://www.delorie.com/gnu/docs/readline/rlman_13.html """ from __future__ import annotations from collections.abc import Callable from typing import TypeVar, cast from prompt_toolkit.document import Document from prompt_toolkit.enums im...
693
18,421
python-prompt-toolkit
src/prompt_toolkit/key_binding/bindings/completion.py
.py
""" Key binding handlers for displaying completions. """ from __future__ import annotations import asyncio import math from typing import TYPE_CHECKING from prompt_toolkit.application.run_in_terminal import in_terminal from prompt_toolkit.completion import ( CompleteEvent, Completion, get_common_complete...
207
6,903
python-prompt-toolkit
src/prompt_toolkit/key_binding/bindings/auto_suggest.py
.py
""" Key bindings for auto suggestion (for fish-style auto suggestion). """ from __future__ import annotations import re from prompt_toolkit.application.current import get_app from prompt_toolkit.filters import Condition, emacs_mode from prompt_toolkit.key_binding.key_bindings import KeyBindings from prompt_toolkit.k...
67
1,855
python-prompt-toolkit
src/prompt_toolkit/key_binding/bindings/open_in_editor.py
.py
""" Open in editor key bindings. """ from __future__ import annotations from prompt_toolkit.filters import emacs_mode, has_selection, vi_navigation_mode from ..key_bindings import KeyBindings, KeyBindingsBase, merge_key_bindings from .named_commands import get_by_name __all__ = [ "load_open_in_editor_bindings",...
53
1,356