diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2023-12-11 10:59:41 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2023-12-11 11:40:57 +0300 |
commit | 708e84a1342eccd8b69c761dd2916e33503a883a (patch) | |
tree | ee90cd4ab26e843c00724b957ef247cc3d1b6f9f /contrib/python/prompt-toolkit/py3/prompt_toolkit | |
parent | 425d65a76c5bda62894f93d32f1f5e32f7439539 (diff) | |
download | ydb-708e84a1342eccd8b69c761dd2916e33503a883a.tar.gz |
Update contrib/python/prompt-toolkit/py3 to 3.0.41
Diffstat (limited to 'contrib/python/prompt-toolkit/py3/prompt_toolkit')
31 files changed, 249 insertions, 207 deletions
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py index 0f75070459..2d408152fe 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py @@ -27,7 +27,7 @@ from .formatted_text import ANSI, HTML from .shortcuts import PromptSession, print_formatted_text, prompt # Don't forget to update in `docs/conf.py`! -__version__ = "3.0.39" +__version__ = "3.0.41" assert pep440.match(__version__) diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py index bcc819095c..726fc0a067 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py @@ -40,7 +40,9 @@ from prompt_toolkit.cursor_shapes import AnyCursorShapeConfig, to_cursor_shape_c from prompt_toolkit.data_structures import Size from prompt_toolkit.enums import EditingMode from prompt_toolkit.eventloop import ( + InputHook, get_traceback_from_context, + new_eventloop_with_inputhook, run_in_executor_with_context, ) from prompt_toolkit.eventloop.utils import call_soon_threadsafe @@ -655,7 +657,7 @@ class Application(Generic[_AppResult]): # See: https://github.com/prompt-toolkit/python-prompt-toolkit/issues/1553 handle_sigint = False - async def _run_async(f: "asyncio.Future[_AppResult]") -> _AppResult: + async def _run_async(f: asyncio.Future[_AppResult]) -> _AppResult: context = contextvars.copy_context() self.context = context @@ -898,13 +900,12 @@ class Application(Generic[_AppResult]): set_exception_handler: bool = True, handle_sigint: bool = True, in_thread: bool = False, + inputhook: InputHook | None = None, ) -> _AppResult: """ A blocking 'run' call that waits until the UI is finished. - This will start the current asyncio event loop. If no loop is set for - the current thread, then it will create a new loop. If a new loop was - created, this won't close the new loop (if `in_thread=False`). + This will run the application in a fresh asyncio event loop. :param pre_run: Optional callable, which is called right after the "reset" of the application. @@ -937,6 +938,7 @@ class Application(Generic[_AppResult]): set_exception_handler=set_exception_handler, # Signal handling only works in the main thread. handle_sigint=False, + inputhook=inputhook, ) except BaseException as e: exception = e @@ -954,17 +956,46 @@ class Application(Generic[_AppResult]): set_exception_handler=set_exception_handler, handle_sigint=handle_sigint, ) - try: - # See whether a loop was installed already. If so, use that. That's - # required for the input hooks to work, they are installed using - # `set_event_loop`. - loop = asyncio.get_event_loop() - except RuntimeError: + + def _called_from_ipython() -> bool: + try: + return ( + "IPython/terminal/interactiveshell.py" + in sys._getframe(3).f_code.co_filename + ) + except BaseException: + return False + + if inputhook is not None: + # Create new event loop with given input hook and run the app. + # In Python 3.12, we can use asyncio.run(loop_factory=...) + # For now, use `run_until_complete()`. + loop = new_eventloop_with_inputhook(inputhook) + result = loop.run_until_complete(coro) + loop.run_until_complete(loop.shutdown_asyncgens()) + loop.close() + return result + + elif _called_from_ipython(): + # workaround to make input hooks work for IPython until + # https://github.com/ipython/ipython/pull/14241 is merged. + # IPython was setting the input hook by installing an event loop + # previously. + try: + # See whether a loop was installed already. If so, use that. + # That's required for the input hooks to work, they are + # installed using `set_event_loop`. + loop = asyncio.get_event_loop() + except RuntimeError: + # No loop installed. Run like usual. + return asyncio.run(coro) + else: + # Use existing loop. + return loop.run_until_complete(coro) + + else: # No loop installed. Run like usual. return asyncio.run(coro) - else: - # Use existing loop. - return loop.run_until_complete(coro) def _handle_exception( self, loop: AbstractEventLoop, context: dict[str, Any] @@ -999,7 +1030,7 @@ class Application(Generic[_AppResult]): manager. (We will only install the hook if no other custom hook was set.) """ - if sys.version_info >= (3, 7) and sys.breakpointhook == sys.__breakpointhook__: + if sys.breakpointhook == sys.__breakpointhook__: sys.breakpointhook = self._breakpointhook try: diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/current.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/current.py index 33828024f4..908141a476 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/current.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/current.py @@ -1,6 +1,5 @@ from __future__ import annotations -import sys from contextlib import contextmanager from contextvars import ContextVar from typing import TYPE_CHECKING, Any, Generator @@ -145,12 +144,8 @@ def create_app_session( Create a separate AppSession. This is useful if there can be multiple individual `AppSession`s going on. - Like in the case of an Telnet/SSH server. This functionality uses - contextvars and requires at least Python 3.7. + Like in the case of an Telnet/SSH server. """ - if sys.version_info <= (3, 6): - raise RuntimeError("Application sessions require Python 3.7.") - # If no input/output is specified, fall back to the current input/output, # whatever that is. if input is None: diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/dummy.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/dummy.py index 4107d05780..43819e1e71 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/dummy.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/dummy.py @@ -2,6 +2,7 @@ from __future__ import annotations from typing 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 @@ -28,6 +29,7 @@ class DummyApplication(Application[None]): set_exception_handler: bool = True, handle_sigint: bool = True, in_thread: bool = False, + inputhook: InputHook | None = None, ) -> None: raise NotImplementedError("A DummyApplication is not supposed to run.") diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/auto_suggest.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/auto_suggest.py index 1049d1a451..98cb4ddd92 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/auto_suggest.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/auto_suggest.py @@ -72,7 +72,7 @@ class AutoSuggest(metaclass=ABCMeta): """ async def get_suggestion_async( - self, buff: "Buffer", document: Document + self, buff: Buffer, document: Document ) -> Suggestion | None: """ Return a :class:`.Future` which is set when the suggestions are ready. @@ -96,7 +96,7 @@ class ThreadedAutoSuggest(AutoSuggest): return self.auto_suggest.get_suggestion(buff, document) async def get_suggestion_async( - self, buff: "Buffer", document: Document + self, buff: Buffer, document: Document ) -> Suggestion | None: """ Run the `get_suggestion` function in a thread. @@ -170,7 +170,7 @@ class DynamicAutoSuggest(AutoSuggest): return auto_suggest.get_suggestion(buff, document) async def get_suggestion_async( - self, buff: "Buffer", document: Document + self, buff: Buffer, document: Document ) -> Suggestion | None: auto_suggest = self.get_auto_suggest() or DummyAutoSuggest() return await auto_suggest.get_suggestion_async(buff, document) diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/buffer.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/buffer.py index 8edc01d1ef..7dbc7a6fb3 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/buffer.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/buffer.py @@ -15,7 +15,7 @@ import tempfile from collections import deque from enum import Enum from functools import wraps -from typing import Any, Awaitable, Callable, Coroutine, Deque, Iterable, TypeVar, cast +from typing import Any, Awaitable, Callable, Coroutine, Iterable, TypeVar, cast from .application.current import get_app from .application.run_in_terminal import run_in_terminal @@ -56,6 +56,7 @@ class EditReadOnlyBuffer(Exception): class ValidationState(Enum): "The validation state of a buffer. This is set after the validation." + VALID = "VALID" INVALID = "INVALID" UNKNOWN = "UNKNOWN" @@ -366,7 +367,7 @@ class Buffer: #: Ctrl-C should reset this, and copy the whole history back in here. #: Enter should process the current command and append to the real #: history. - self._working_lines: Deque[str] = deque([document.text]) + self._working_lines: deque[str] = deque([document.text]) self.__working_index = 0 def load_history_if_not_yet_loaded(self) -> None: @@ -1936,18 +1937,18 @@ def indent(buffer: Buffer, from_row: int, to_row: int, count: int = 1) -> None: Indent text of a :class:`.Buffer` object. """ current_row = buffer.document.cursor_position_row + current_col = buffer.document.cursor_position_col line_range = range(from_row, to_row) # Apply transformation. - new_text = buffer.transform_lines(line_range, lambda l: " " * count + l) + indent_content = " " * count + new_text = buffer.transform_lines(line_range, lambda l: indent_content + l) buffer.document = Document( new_text, Document(new_text).translate_row_col_to_index(current_row, 0) ) - # Go to the start of the line. - buffer.cursor_position += buffer.document.get_start_of_line_position( - after_whitespace=True - ) + # Place cursor in the same position in text after indenting + buffer.cursor_position += current_col + len(indent_content) def unindent(buffer: Buffer, from_row: int, to_row: int, count: int = 1) -> None: @@ -1955,10 +1956,13 @@ def unindent(buffer: Buffer, from_row: int, to_row: int, count: int = 1) -> None Unindent text of a :class:`.Buffer` object. """ current_row = buffer.document.cursor_position_row + current_col = buffer.document.cursor_position_col line_range = range(from_row, to_row) + indent_content = " " * count + def transform(text: str) -> str: - remove = " " * count + remove = indent_content if text.startswith(remove): return text[len(remove) :] else: @@ -1970,10 +1974,8 @@ def unindent(buffer: Buffer, from_row: int, to_row: int, count: int = 1) -> None new_text, Document(new_text).translate_row_col_to_index(current_row, 0) ) - # Go to the start of the line. - buffer.cursor_position += buffer.document.get_start_of_line_position( - after_whitespace=True - ) + # Place cursor in the same position in text after dedent + buffer.cursor_position += current_col - len(indent_content) def reshape_text(buffer: Buffer, from_row: int, to_row: int) -> None: diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/cache.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/cache.py index ada8d9856a..01dd1f79d6 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/cache.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/cache.py @@ -2,7 +2,7 @@ from __future__ import annotations from collections import deque from functools import wraps -from typing import Any, Callable, Deque, Dict, Generic, Hashable, Tuple, TypeVar, cast +from typing import Any, Callable, Dict, Generic, Hashable, Tuple, TypeVar, cast __all__ = [ "SimpleCache", @@ -26,7 +26,7 @@ class SimpleCache(Generic[_T, _U]): assert maxsize > 0 self._data: dict[_T, _U] = {} - self._keys: Deque[_T] = deque() + self._keys: deque[_T] = deque() self.maxsize: int = maxsize def get(self, key: _T, getter_func: Callable[[], _U]) -> _U: @@ -86,7 +86,7 @@ class FastDictCache(Dict[_K, _V]): def __init__(self, get_value: Callable[..., _V], size: int = 1000000) -> None: assert size > 0 - self._keys: Deque[_K] = deque() + self._keys: deque[_K] = deque() self.get_value = get_value self.size = size diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/clipboard/in_memory.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/clipboard/in_memory.py index d6e010e232..d9ae0817b7 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/clipboard/in_memory.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/clipboard/in_memory.py @@ -1,7 +1,6 @@ from __future__ import annotations from collections import deque -from typing import Deque from .base import Clipboard, ClipboardData @@ -22,7 +21,7 @@ class InMemoryClipboard(Clipboard): assert max_size >= 1 self.max_size = max_size - self._ring: Deque[ClipboardData] = deque() + self._ring: deque[ClipboardData] = deque() if data is not None: self.set_data(data) diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/filesystem.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/filesystem.py index 10e2f7ca69..8e7f87e00b 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/filesystem.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/filesystem.py @@ -115,4 +115,4 @@ class ExecutableCompleter(PathCompleter): get_paths=lambda: os.environ.get("PATH", "").split(os.pathsep), file_filter=lambda name: os.access(name, os.X_OK), expanduser=True, - ), + ) diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/compiler.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/compiler.py index a56bc698fb..474f6cfd10 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/compiler.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/compiler.py @@ -41,9 +41,8 @@ Partial matches are possible:: from __future__ import annotations import re -from typing import Callable, Dict, Iterable, Iterator +from typing import Callable, Dict, Iterable, Iterator, Pattern from typing import Match as RegexMatch -from typing import Pattern from .regex_parser import ( AnyNode, @@ -170,10 +169,7 @@ class _CompiledGrammar: # A `Variable` wraps the children into a named group. elif isinstance(node, Variable): - return "(?P<{}>{})".format( - create_group_func(node), - transform(node.childnode), - ) + return f"(?P<{create_group_func(node)}>{transform(node.childnode)})" # `Repeat`. elif isinstance(node, Repeat): diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/server.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/server.py index 5730a3b0bb..81c19f6c88 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/server.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/server.py @@ -186,7 +186,7 @@ class TelnetConnection: self.feed(data) else: # Connection closed by client. - logger.info("Connection closed by client. %r %r" % self.addr) + logger.info("Connection closed by client. {!r} {!r}".format(*self.addr)) self.close() # Add reader. diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/__init__.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/__init__.py index 89eb71c318..5df623bff1 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/__init__.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/__init__.py @@ -2,6 +2,7 @@ from __future__ import annotations from .async_generator import aclosing, generator_to_async_generator from .inputhook import ( + InputHook, InputHookContext, InputHookSelector, new_eventloop_with_inputhook, @@ -22,6 +23,7 @@ __all__ = [ "call_soon_threadsafe", "get_traceback_from_context", # Inputhooks. + "InputHook", "new_eventloop_with_inputhook", "set_eventloop_with_inputhook", "InputHookSelector", diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/inputhook.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/inputhook.py index 8d6f6a4ffe..5731573f52 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/inputhook.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/inputhook.py @@ -39,14 +39,32 @@ __all__ = [ "set_eventloop_with_inputhook", "InputHookSelector", "InputHookContext", + "InputHook", ] if TYPE_CHECKING: from _typeshed import FileDescriptorLike + from typing_extensions import TypeAlias _EventMask = int +class InputHookContext: + """ + Given as a parameter to the inputhook. + """ + + def __init__(self, fileno: int, input_is_ready: Callable[[], bool]) -> None: + self._fileno = fileno + self.input_is_ready = input_is_ready + + def fileno(self) -> int: + return self._fileno + + +InputHook: TypeAlias = Callable[[InputHookContext], None] + + def new_eventloop_with_inputhook( inputhook: Callable[[InputHookContext], None] ) -> AbstractEventLoop: @@ -64,6 +82,8 @@ def set_eventloop_with_inputhook( """ Create a new event loop with the given inputhook, and activate it. """ + # Deprecated! + loop = new_eventloop_with_inputhook(inputhook) asyncio.set_event_loop(loop) return loop @@ -168,16 +188,3 @@ class InputHookSelector(BaseSelector): def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: return self.selector.get_map() - - -class InputHookContext: - """ - Given as a parameter to the inputhook. - """ - - def __init__(self, fileno: int, input_is_ready: Callable[[], bool]) -> None: - self._fileno = fileno - self.input_is_ready = input_is_ready - - def fileno(self) -> int: - return self._fileno diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/base.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/base.py index cec6debcfb..92de353577 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/base.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/base.py @@ -86,7 +86,7 @@ def to_formatted_text( else: raise ValueError( "No formatted text. Expecting a unicode object, " - "HTML, ANSI or a FormattedText instance. Got %r" % (value,) + f"HTML, ANSI or a FormattedText instance. Got {value!r}" ) # Apply extra style. diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/win32.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/win32.py index 9ad72aee16..35e8948d22 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/win32.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/win32.py @@ -314,10 +314,10 @@ class ConsoleInputReader: # Process if this is a key event. (We also have mouse, menu and # focus events.) - if type(ev) == KEY_EVENT_RECORD and ev.KeyDown: + if isinstance(ev, KEY_EVENT_RECORD) and ev.KeyDown: yield from self._event_to_key_presses(ev) - elif type(ev) == MOUSE_EVENT_RECORD: + elif isinstance(ev, MOUSE_EVENT_RECORD): yield from self._handle_mouse(ev) @staticmethod @@ -379,7 +379,7 @@ class ConsoleInputReader: """ For this `KEY_EVENT_RECORD`, return a list of `KeyPress` instances. """ - assert type(ev) == KEY_EVENT_RECORD and ev.KeyDown + assert isinstance(ev, KEY_EVENT_RECORD) and ev.KeyDown result: KeyPress | None = None diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/auto_suggest.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/auto_suggest.py index 32006f13aa..3d8a843d4a 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/auto_suggest.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/auto_suggest.py @@ -59,7 +59,7 @@ def load_auto_suggest_bindings() -> KeyBindings: suggestion = b.suggestion if suggestion: - t = re.split(r"(\S+\s+)", suggestion.text) + t = re.split(r"([^\s/]+(?:\s+|/))", suggestion.text) b.insert_text(next(x for x in t if x)) return key_bindings diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/mouse.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/mouse.py index af589aba77..cb426ce7bc 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/mouse.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/mouse.py @@ -25,7 +25,6 @@ __all__ = [ E = KeyPressEvent # fmt: off -# flake8: noqa E201 SCROLL_UP = MouseEventType.SCROLL_UP SCROLL_DOWN = MouseEventType.SCROLL_DOWN MOUSE_DOWN = MouseEventType.MOUSE_DOWN @@ -49,113 +48,113 @@ NO_BUTTON = MouseButton.NONE UNKNOWN_BUTTON = MouseButton.UNKNOWN xterm_sgr_mouse_events = { - ( 0, 'm') : (LEFT, MOUSE_UP, NO_MODIFIER), # left_up 0+ + + =0 - ( 4, 'm') : (LEFT, MOUSE_UP, SHIFT), # left_up Shift 0+4+ + =4 - ( 8, 'm') : (LEFT, MOUSE_UP, ALT), # left_up Alt 0+ +8+ =8 - (12, 'm') : (LEFT, MOUSE_UP, SHIFT_ALT), # left_up Shift Alt 0+4+8+ =12 - (16, 'm') : (LEFT, MOUSE_UP, CONTROL), # left_up Control 0+ + +16=16 - (20, 'm') : (LEFT, MOUSE_UP, SHIFT_CONTROL), # left_up Shift Control 0+4+ +16=20 - (24, 'm') : (LEFT, MOUSE_UP, ALT_CONTROL), # left_up Alt Control 0+ +8+16=24 - (28, 'm') : (LEFT, MOUSE_UP, SHIFT_ALT_CONTROL), # left_up Shift Alt Control 0+4+8+16=28 - - ( 1, 'm') : (MIDDLE, MOUSE_UP, NO_MODIFIER), # middle_up 1+ + + =1 - ( 5, 'm') : (MIDDLE, MOUSE_UP, SHIFT), # middle_up Shift 1+4+ + =5 - ( 9, 'm') : (MIDDLE, MOUSE_UP, ALT), # middle_up Alt 1+ +8+ =9 - (13, 'm') : (MIDDLE, MOUSE_UP, SHIFT_ALT), # middle_up Shift Alt 1+4+8+ =13 - (17, 'm') : (MIDDLE, MOUSE_UP, CONTROL), # middle_up Control 1+ + +16=17 - (21, 'm') : (MIDDLE, MOUSE_UP, SHIFT_CONTROL), # middle_up Shift Control 1+4+ +16=21 - (25, 'm') : (MIDDLE, MOUSE_UP, ALT_CONTROL), # middle_up Alt Control 1+ +8+16=25 - (29, 'm') : (MIDDLE, MOUSE_UP, SHIFT_ALT_CONTROL), # middle_up Shift Alt Control 1+4+8+16=29 - - ( 2, 'm') : (RIGHT, MOUSE_UP, NO_MODIFIER), # right_up 2+ + + =2 - ( 6, 'm') : (RIGHT, MOUSE_UP, SHIFT), # right_up Shift 2+4+ + =6 - (10, 'm') : (RIGHT, MOUSE_UP, ALT), # right_up Alt 2+ +8+ =10 - (14, 'm') : (RIGHT, MOUSE_UP, SHIFT_ALT), # right_up Shift Alt 2+4+8+ =14 - (18, 'm') : (RIGHT, MOUSE_UP, CONTROL), # right_up Control 2+ + +16=18 - (22, 'm') : (RIGHT, MOUSE_UP, SHIFT_CONTROL), # right_up Shift Control 2+4+ +16=22 - (26, 'm') : (RIGHT, MOUSE_UP, ALT_CONTROL), # right_up Alt Control 2+ +8+16=26 - (30, 'm') : (RIGHT, MOUSE_UP, SHIFT_ALT_CONTROL), # right_up Shift Alt Control 2+4+8+16=30 - - ( 0, 'M') : (LEFT, MOUSE_DOWN, NO_MODIFIER), # left_down 0+ + + =0 - ( 4, 'M') : (LEFT, MOUSE_DOWN, SHIFT), # left_down Shift 0+4+ + =4 - ( 8, 'M') : (LEFT, MOUSE_DOWN, ALT), # left_down Alt 0+ +8+ =8 - (12, 'M') : (LEFT, MOUSE_DOWN, SHIFT_ALT), # left_down Shift Alt 0+4+8+ =12 - (16, 'M') : (LEFT, MOUSE_DOWN, CONTROL), # left_down Control 0+ + +16=16 - (20, 'M') : (LEFT, MOUSE_DOWN, SHIFT_CONTROL), # left_down Shift Control 0+4+ +16=20 - (24, 'M') : (LEFT, MOUSE_DOWN, ALT_CONTROL), # left_down Alt Control 0+ +8+16=24 - (28, 'M') : (LEFT, MOUSE_DOWN, SHIFT_ALT_CONTROL), # left_down Shift Alt Control 0+4+8+16=28 - - ( 1, 'M') : (MIDDLE, MOUSE_DOWN, NO_MODIFIER), # middle_down 1+ + + =1 - ( 5, 'M') : (MIDDLE, MOUSE_DOWN, SHIFT), # middle_down Shift 1+4+ + =5 - ( 9, 'M') : (MIDDLE, MOUSE_DOWN, ALT), # middle_down Alt 1+ +8+ =9 - (13, 'M') : (MIDDLE, MOUSE_DOWN, SHIFT_ALT), # middle_down Shift Alt 1+4+8+ =13 - (17, 'M') : (MIDDLE, MOUSE_DOWN, CONTROL), # middle_down Control 1+ + +16=17 - (21, 'M') : (MIDDLE, MOUSE_DOWN, SHIFT_CONTROL), # middle_down Shift Control 1+4+ +16=21 - (25, 'M') : (MIDDLE, MOUSE_DOWN, ALT_CONTROL), # middle_down Alt Control 1+ +8+16=25 - (29, 'M') : (MIDDLE, MOUSE_DOWN, SHIFT_ALT_CONTROL), # middle_down Shift Alt Control 1+4+8+16=29 - - ( 2, 'M') : (RIGHT, MOUSE_DOWN, NO_MODIFIER), # right_down 2+ + + =2 - ( 6, 'M') : (RIGHT, MOUSE_DOWN, SHIFT), # right_down Shift 2+4+ + =6 - (10, 'M') : (RIGHT, MOUSE_DOWN, ALT), # right_down Alt 2+ +8+ =10 - (14, 'M') : (RIGHT, MOUSE_DOWN, SHIFT_ALT), # right_down Shift Alt 2+4+8+ =14 - (18, 'M') : (RIGHT, MOUSE_DOWN, CONTROL), # right_down Control 2+ + +16=18 - (22, 'M') : (RIGHT, MOUSE_DOWN, SHIFT_CONTROL), # right_down Shift Control 2+4+ +16=22 - (26, 'M') : (RIGHT, MOUSE_DOWN, ALT_CONTROL), # right_down Alt Control 2+ +8+16=26 - (30, 'M') : (RIGHT, MOUSE_DOWN, SHIFT_ALT_CONTROL), # right_down Shift Alt Control 2+4+8+16=30 - - (32, 'M') : (LEFT, MOUSE_MOVE, NO_MODIFIER), # left_drag 32+ + + =32 - (36, 'M') : (LEFT, MOUSE_MOVE, SHIFT), # left_drag Shift 32+4+ + =36 - (40, 'M') : (LEFT, MOUSE_MOVE, ALT), # left_drag Alt 32+ +8+ =40 - (44, 'M') : (LEFT, MOUSE_MOVE, SHIFT_ALT), # left_drag Shift Alt 32+4+8+ =44 - (48, 'M') : (LEFT, MOUSE_MOVE, CONTROL), # left_drag Control 32+ + +16=48 - (52, 'M') : (LEFT, MOUSE_MOVE, SHIFT_CONTROL), # left_drag Shift Control 32+4+ +16=52 - (56, 'M') : (LEFT, MOUSE_MOVE, ALT_CONTROL), # left_drag Alt Control 32+ +8+16=56 - (60, 'M') : (LEFT, MOUSE_MOVE, SHIFT_ALT_CONTROL), # left_drag Shift Alt Control 32+4+8+16=60 - - (33, 'M') : (MIDDLE, MOUSE_MOVE, NO_MODIFIER), # middle_drag 33+ + + =33 - (37, 'M') : (MIDDLE, MOUSE_MOVE, SHIFT), # middle_drag Shift 33+4+ + =37 - (41, 'M') : (MIDDLE, MOUSE_MOVE, ALT), # middle_drag Alt 33+ +8+ =41 - (45, 'M') : (MIDDLE, MOUSE_MOVE, SHIFT_ALT), # middle_drag Shift Alt 33+4+8+ =45 - (49, 'M') : (MIDDLE, MOUSE_MOVE, CONTROL), # middle_drag Control 33+ + +16=49 - (53, 'M') : (MIDDLE, MOUSE_MOVE, SHIFT_CONTROL), # middle_drag Shift Control 33+4+ +16=53 - (57, 'M') : (MIDDLE, MOUSE_MOVE, ALT_CONTROL), # middle_drag Alt Control 33+ +8+16=57 - (61, 'M') : (MIDDLE, MOUSE_MOVE, SHIFT_ALT_CONTROL), # middle_drag Shift Alt Control 33+4+8+16=61 - - (34, 'M') : (RIGHT, MOUSE_MOVE, NO_MODIFIER), # right_drag 34+ + + =34 - (38, 'M') : (RIGHT, MOUSE_MOVE, SHIFT), # right_drag Shift 34+4+ + =38 - (42, 'M') : (RIGHT, MOUSE_MOVE, ALT), # right_drag Alt 34+ +8+ =42 - (46, 'M') : (RIGHT, MOUSE_MOVE, SHIFT_ALT), # right_drag Shift Alt 34+4+8+ =46 - (50, 'M') : (RIGHT, MOUSE_MOVE, CONTROL), # right_drag Control 34+ + +16=50 - (54, 'M') : (RIGHT, MOUSE_MOVE, SHIFT_CONTROL), # right_drag Shift Control 34+4+ +16=54 - (58, 'M') : (RIGHT, MOUSE_MOVE, ALT_CONTROL), # right_drag Alt Control 34+ +8+16=58 - (62, 'M') : (RIGHT, MOUSE_MOVE, SHIFT_ALT_CONTROL), # right_drag Shift Alt Control 34+4+8+16=62 - - (35, 'M') : (NO_BUTTON, MOUSE_MOVE, NO_MODIFIER), # none_drag 35+ + + =35 - (39, 'M') : (NO_BUTTON, MOUSE_MOVE, SHIFT), # none_drag Shift 35+4+ + =39 - (43, 'M') : (NO_BUTTON, MOUSE_MOVE, ALT), # none_drag Alt 35+ +8+ =43 - (47, 'M') : (NO_BUTTON, MOUSE_MOVE, SHIFT_ALT), # none_drag Shift Alt 35+4+8+ =47 - (51, 'M') : (NO_BUTTON, MOUSE_MOVE, CONTROL), # none_drag Control 35+ + +16=51 - (55, 'M') : (NO_BUTTON, MOUSE_MOVE, SHIFT_CONTROL), # none_drag Shift Control 35+4+ +16=55 - (59, 'M') : (NO_BUTTON, MOUSE_MOVE, ALT_CONTROL), # none_drag Alt Control 35+ +8+16=59 - (63, 'M') : (NO_BUTTON, MOUSE_MOVE, SHIFT_ALT_CONTROL), # none_drag Shift Alt Control 35+4+8+16=63 - - (64, 'M') : (NO_BUTTON, SCROLL_UP, NO_MODIFIER), # scroll_up 64+ + + =64 - (68, 'M') : (NO_BUTTON, SCROLL_UP, SHIFT), # scroll_up Shift 64+4+ + =68 - (72, 'M') : (NO_BUTTON, SCROLL_UP, ALT), # scroll_up Alt 64+ +8+ =72 - (76, 'M') : (NO_BUTTON, SCROLL_UP, SHIFT_ALT), # scroll_up Shift Alt 64+4+8+ =76 - (80, 'M') : (NO_BUTTON, SCROLL_UP, CONTROL), # scroll_up Control 64+ + +16=80 - (84, 'M') : (NO_BUTTON, SCROLL_UP, SHIFT_CONTROL), # scroll_up Shift Control 64+4+ +16=84 - (88, 'M') : (NO_BUTTON, SCROLL_UP, ALT_CONTROL), # scroll_up Alt Control 64+ +8+16=88 - (92, 'M') : (NO_BUTTON, SCROLL_UP, SHIFT_ALT_CONTROL), # scroll_up Shift Alt Control 64+4+8+16=92 - - (65, 'M') : (NO_BUTTON, SCROLL_DOWN, NO_MODIFIER), # scroll_down 64+ + + =65 - (69, 'M') : (NO_BUTTON, SCROLL_DOWN, SHIFT), # scroll_down Shift 64+4+ + =69 - (73, 'M') : (NO_BUTTON, SCROLL_DOWN, ALT), # scroll_down Alt 64+ +8+ =73 - (77, 'M') : (NO_BUTTON, SCROLL_DOWN, SHIFT_ALT), # scroll_down Shift Alt 64+4+8+ =77 - (81, 'M') : (NO_BUTTON, SCROLL_DOWN, CONTROL), # scroll_down Control 64+ + +16=81 - (85, 'M') : (NO_BUTTON, SCROLL_DOWN, SHIFT_CONTROL), # scroll_down Shift Control 64+4+ +16=85 - (89, 'M') : (NO_BUTTON, SCROLL_DOWN, ALT_CONTROL), # scroll_down Alt Control 64+ +8+16=89 - (93, 'M') : (NO_BUTTON, SCROLL_DOWN, SHIFT_ALT_CONTROL), # scroll_down Shift Alt Control 64+4+8+16=93 + ( 0, "m") : (LEFT, MOUSE_UP, NO_MODIFIER), # left_up 0+ + + =0 + ( 4, "m") : (LEFT, MOUSE_UP, SHIFT), # left_up Shift 0+4+ + =4 + ( 8, "m") : (LEFT, MOUSE_UP, ALT), # left_up Alt 0+ +8+ =8 + (12, "m") : (LEFT, MOUSE_UP, SHIFT_ALT), # left_up Shift Alt 0+4+8+ =12 + (16, "m") : (LEFT, MOUSE_UP, CONTROL), # left_up Control 0+ + +16=16 + (20, "m") : (LEFT, MOUSE_UP, SHIFT_CONTROL), # left_up Shift Control 0+4+ +16=20 + (24, "m") : (LEFT, MOUSE_UP, ALT_CONTROL), # left_up Alt Control 0+ +8+16=24 + (28, "m") : (LEFT, MOUSE_UP, SHIFT_ALT_CONTROL), # left_up Shift Alt Control 0+4+8+16=28 + + ( 1, "m") : (MIDDLE, MOUSE_UP, NO_MODIFIER), # middle_up 1+ + + =1 + ( 5, "m") : (MIDDLE, MOUSE_UP, SHIFT), # middle_up Shift 1+4+ + =5 + ( 9, "m") : (MIDDLE, MOUSE_UP, ALT), # middle_up Alt 1+ +8+ =9 + (13, "m") : (MIDDLE, MOUSE_UP, SHIFT_ALT), # middle_up Shift Alt 1+4+8+ =13 + (17, "m") : (MIDDLE, MOUSE_UP, CONTROL), # middle_up Control 1+ + +16=17 + (21, "m") : (MIDDLE, MOUSE_UP, SHIFT_CONTROL), # middle_up Shift Control 1+4+ +16=21 + (25, "m") : (MIDDLE, MOUSE_UP, ALT_CONTROL), # middle_up Alt Control 1+ +8+16=25 + (29, "m") : (MIDDLE, MOUSE_UP, SHIFT_ALT_CONTROL), # middle_up Shift Alt Control 1+4+8+16=29 + + ( 2, "m") : (RIGHT, MOUSE_UP, NO_MODIFIER), # right_up 2+ + + =2 + ( 6, "m") : (RIGHT, MOUSE_UP, SHIFT), # right_up Shift 2+4+ + =6 + (10, "m") : (RIGHT, MOUSE_UP, ALT), # right_up Alt 2+ +8+ =10 + (14, "m") : (RIGHT, MOUSE_UP, SHIFT_ALT), # right_up Shift Alt 2+4+8+ =14 + (18, "m") : (RIGHT, MOUSE_UP, CONTROL), # right_up Control 2+ + +16=18 + (22, "m") : (RIGHT, MOUSE_UP, SHIFT_CONTROL), # right_up Shift Control 2+4+ +16=22 + (26, "m") : (RIGHT, MOUSE_UP, ALT_CONTROL), # right_up Alt Control 2+ +8+16=26 + (30, "m") : (RIGHT, MOUSE_UP, SHIFT_ALT_CONTROL), # right_up Shift Alt Control 2+4+8+16=30 + + ( 0, "M") : (LEFT, MOUSE_DOWN, NO_MODIFIER), # left_down 0+ + + =0 + ( 4, "M") : (LEFT, MOUSE_DOWN, SHIFT), # left_down Shift 0+4+ + =4 + ( 8, "M") : (LEFT, MOUSE_DOWN, ALT), # left_down Alt 0+ +8+ =8 + (12, "M") : (LEFT, MOUSE_DOWN, SHIFT_ALT), # left_down Shift Alt 0+4+8+ =12 + (16, "M") : (LEFT, MOUSE_DOWN, CONTROL), # left_down Control 0+ + +16=16 + (20, "M") : (LEFT, MOUSE_DOWN, SHIFT_CONTROL), # left_down Shift Control 0+4+ +16=20 + (24, "M") : (LEFT, MOUSE_DOWN, ALT_CONTROL), # left_down Alt Control 0+ +8+16=24 + (28, "M") : (LEFT, MOUSE_DOWN, SHIFT_ALT_CONTROL), # left_down Shift Alt Control 0+4+8+16=28 + + ( 1, "M") : (MIDDLE, MOUSE_DOWN, NO_MODIFIER), # middle_down 1+ + + =1 + ( 5, "M") : (MIDDLE, MOUSE_DOWN, SHIFT), # middle_down Shift 1+4+ + =5 + ( 9, "M") : (MIDDLE, MOUSE_DOWN, ALT), # middle_down Alt 1+ +8+ =9 + (13, "M") : (MIDDLE, MOUSE_DOWN, SHIFT_ALT), # middle_down Shift Alt 1+4+8+ =13 + (17, "M") : (MIDDLE, MOUSE_DOWN, CONTROL), # middle_down Control 1+ + +16=17 + (21, "M") : (MIDDLE, MOUSE_DOWN, SHIFT_CONTROL), # middle_down Shift Control 1+4+ +16=21 + (25, "M") : (MIDDLE, MOUSE_DOWN, ALT_CONTROL), # middle_down Alt Control 1+ +8+16=25 + (29, "M") : (MIDDLE, MOUSE_DOWN, SHIFT_ALT_CONTROL), # middle_down Shift Alt Control 1+4+8+16=29 + + ( 2, "M") : (RIGHT, MOUSE_DOWN, NO_MODIFIER), # right_down 2+ + + =2 + ( 6, "M") : (RIGHT, MOUSE_DOWN, SHIFT), # right_down Shift 2+4+ + =6 + (10, "M") : (RIGHT, MOUSE_DOWN, ALT), # right_down Alt 2+ +8+ =10 + (14, "M") : (RIGHT, MOUSE_DOWN, SHIFT_ALT), # right_down Shift Alt 2+4+8+ =14 + (18, "M") : (RIGHT, MOUSE_DOWN, CONTROL), # right_down Control 2+ + +16=18 + (22, "M") : (RIGHT, MOUSE_DOWN, SHIFT_CONTROL), # right_down Shift Control 2+4+ +16=22 + (26, "M") : (RIGHT, MOUSE_DOWN, ALT_CONTROL), # right_down Alt Control 2+ +8+16=26 + (30, "M") : (RIGHT, MOUSE_DOWN, SHIFT_ALT_CONTROL), # right_down Shift Alt Control 2+4+8+16=30 + + (32, "M") : (LEFT, MOUSE_MOVE, NO_MODIFIER), # left_drag 32+ + + =32 + (36, "M") : (LEFT, MOUSE_MOVE, SHIFT), # left_drag Shift 32+4+ + =36 + (40, "M") : (LEFT, MOUSE_MOVE, ALT), # left_drag Alt 32+ +8+ =40 + (44, "M") : (LEFT, MOUSE_MOVE, SHIFT_ALT), # left_drag Shift Alt 32+4+8+ =44 + (48, "M") : (LEFT, MOUSE_MOVE, CONTROL), # left_drag Control 32+ + +16=48 + (52, "M") : (LEFT, MOUSE_MOVE, SHIFT_CONTROL), # left_drag Shift Control 32+4+ +16=52 + (56, "M") : (LEFT, MOUSE_MOVE, ALT_CONTROL), # left_drag Alt Control 32+ +8+16=56 + (60, "M") : (LEFT, MOUSE_MOVE, SHIFT_ALT_CONTROL), # left_drag Shift Alt Control 32+4+8+16=60 + + (33, "M") : (MIDDLE, MOUSE_MOVE, NO_MODIFIER), # middle_drag 33+ + + =33 + (37, "M") : (MIDDLE, MOUSE_MOVE, SHIFT), # middle_drag Shift 33+4+ + =37 + (41, "M") : (MIDDLE, MOUSE_MOVE, ALT), # middle_drag Alt 33+ +8+ =41 + (45, "M") : (MIDDLE, MOUSE_MOVE, SHIFT_ALT), # middle_drag Shift Alt 33+4+8+ =45 + (49, "M") : (MIDDLE, MOUSE_MOVE, CONTROL), # middle_drag Control 33+ + +16=49 + (53, "M") : (MIDDLE, MOUSE_MOVE, SHIFT_CONTROL), # middle_drag Shift Control 33+4+ +16=53 + (57, "M") : (MIDDLE, MOUSE_MOVE, ALT_CONTROL), # middle_drag Alt Control 33+ +8+16=57 + (61, "M") : (MIDDLE, MOUSE_MOVE, SHIFT_ALT_CONTROL), # middle_drag Shift Alt Control 33+4+8+16=61 + + (34, "M") : (RIGHT, MOUSE_MOVE, NO_MODIFIER), # right_drag 34+ + + =34 + (38, "M") : (RIGHT, MOUSE_MOVE, SHIFT), # right_drag Shift 34+4+ + =38 + (42, "M") : (RIGHT, MOUSE_MOVE, ALT), # right_drag Alt 34+ +8+ =42 + (46, "M") : (RIGHT, MOUSE_MOVE, SHIFT_ALT), # right_drag Shift Alt 34+4+8+ =46 + (50, "M") : (RIGHT, MOUSE_MOVE, CONTROL), # right_drag Control 34+ + +16=50 + (54, "M") : (RIGHT, MOUSE_MOVE, SHIFT_CONTROL), # right_drag Shift Control 34+4+ +16=54 + (58, "M") : (RIGHT, MOUSE_MOVE, ALT_CONTROL), # right_drag Alt Control 34+ +8+16=58 + (62, "M") : (RIGHT, MOUSE_MOVE, SHIFT_ALT_CONTROL), # right_drag Shift Alt Control 34+4+8+16=62 + + (35, "M") : (NO_BUTTON, MOUSE_MOVE, NO_MODIFIER), # none_drag 35+ + + =35 + (39, "M") : (NO_BUTTON, MOUSE_MOVE, SHIFT), # none_drag Shift 35+4+ + =39 + (43, "M") : (NO_BUTTON, MOUSE_MOVE, ALT), # none_drag Alt 35+ +8+ =43 + (47, "M") : (NO_BUTTON, MOUSE_MOVE, SHIFT_ALT), # none_drag Shift Alt 35+4+8+ =47 + (51, "M") : (NO_BUTTON, MOUSE_MOVE, CONTROL), # none_drag Control 35+ + +16=51 + (55, "M") : (NO_BUTTON, MOUSE_MOVE, SHIFT_CONTROL), # none_drag Shift Control 35+4+ +16=55 + (59, "M") : (NO_BUTTON, MOUSE_MOVE, ALT_CONTROL), # none_drag Alt Control 35+ +8+16=59 + (63, "M") : (NO_BUTTON, MOUSE_MOVE, SHIFT_ALT_CONTROL), # none_drag Shift Alt Control 35+4+8+16=63 + + (64, "M") : (NO_BUTTON, SCROLL_UP, NO_MODIFIER), # scroll_up 64+ + + =64 + (68, "M") : (NO_BUTTON, SCROLL_UP, SHIFT), # scroll_up Shift 64+4+ + =68 + (72, "M") : (NO_BUTTON, SCROLL_UP, ALT), # scroll_up Alt 64+ +8+ =72 + (76, "M") : (NO_BUTTON, SCROLL_UP, SHIFT_ALT), # scroll_up Shift Alt 64+4+8+ =76 + (80, "M") : (NO_BUTTON, SCROLL_UP, CONTROL), # scroll_up Control 64+ + +16=80 + (84, "M") : (NO_BUTTON, SCROLL_UP, SHIFT_CONTROL), # scroll_up Shift Control 64+4+ +16=84 + (88, "M") : (NO_BUTTON, SCROLL_UP, ALT_CONTROL), # scroll_up Alt Control 64+ +8+16=88 + (92, "M") : (NO_BUTTON, SCROLL_UP, SHIFT_ALT_CONTROL), # scroll_up Shift Alt Control 64+4+8+16=92 + + (65, "M") : (NO_BUTTON, SCROLL_DOWN, NO_MODIFIER), # scroll_down 64+ + + =65 + (69, "M") : (NO_BUTTON, SCROLL_DOWN, SHIFT), # scroll_down Shift 64+4+ + =69 + (73, "M") : (NO_BUTTON, SCROLL_DOWN, ALT), # scroll_down Alt 64+ +8+ =73 + (77, "M") : (NO_BUTTON, SCROLL_DOWN, SHIFT_ALT), # scroll_down Shift Alt 64+4+8+ =77 + (81, "M") : (NO_BUTTON, SCROLL_DOWN, CONTROL), # scroll_down Control 64+ + +16=81 + (85, "M") : (NO_BUTTON, SCROLL_DOWN, SHIFT_CONTROL), # scroll_down Shift Control 64+4+ +16=85 + (89, "M") : (NO_BUTTON, SCROLL_DOWN, ALT_CONTROL), # scroll_down Alt Control 64+ +8+16=89 + (93, "M") : (NO_BUTTON, SCROLL_DOWN, SHIFT_ALT_CONTROL), # scroll_down Shift Alt Control 64+4+8+16=93 } typical_mouse_events = { diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/vi.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/vi.py index 436a553c1f..5cc74b4fb2 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/vi.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/vi.py @@ -962,6 +962,7 @@ def load_vi_bindings() -> KeyBindingsBase: ) @handle(">", ">", filter=vi_navigation_mode) + @handle("c-t", filter=vi_insert_mode) def _indent(event: E) -> None: """ Indent lines. @@ -971,6 +972,7 @@ def load_vi_bindings() -> KeyBindingsBase: indent(buffer, current_row, current_row + event.arg) @handle("<", "<", filter=vi_navigation_mode) + @handle("c-d", filter=vi_insert_mode) def _unindent(event: E) -> None: """ Unindent lines. diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/key_processor.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/key_processor.py index edf27573ee..4c4f0d155d 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/key_processor.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/key_processor.py @@ -10,7 +10,7 @@ from __future__ import annotations import weakref from asyncio import Task, sleep from collections import deque -from typing import TYPE_CHECKING, Any, Deque, Generator +from typing import TYPE_CHECKING, Any, Generator from prompt_toolkit.application.current import get_app from prompt_toolkit.enums import EditingMode @@ -103,7 +103,7 @@ class KeyProcessor: self._previous_handler: Binding | None = None # The queue of keys not yet send to our _process generator/state machine. - self.input_queue: Deque[KeyPress] = deque() + self.input_queue: deque[KeyPress] = deque() # The key buffer that is matched in the generator state machine. # (This is at at most the amount of keys that make up for one key binding.) diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/containers.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/containers.py index bcbf35d056..5de87b08a7 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/containers.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/containers.py @@ -172,6 +172,7 @@ def _window_too_small() -> Window: class VerticalAlign(Enum): "Alignment for `HSplit`." + TOP = "TOP" CENTER = "CENTER" BOTTOM = "BOTTOM" @@ -180,6 +181,7 @@ class VerticalAlign(Enum): class HorizontalAlign(Enum): "Alignment for `VSplit`." + LEFT = "LEFT" CENTER = "CENTER" RIGHT = "RIGHT" diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py index cb036cc842..c13960bc43 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py @@ -449,7 +449,7 @@ class FormattedTextControl(UIControl): # Handler found. Call it. # (Handler can return NotImplemented, so return # that result.) - handler = item[2] # type: ignore + handler = item[2] return handler(mouse_event) else: break @@ -477,9 +477,7 @@ class DummyControl(UIControl): def get_line(i: int) -> StyleAndTextTuples: return [] - return UIContent( - get_line=get_line, line_count=100**100 - ) # Something very big. + return UIContent(get_line=get_line, line_count=100**100) # Something very big. def is_focusable(self) -> bool: return False diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/layout.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/layout.py index 093e69ed18..a5e7a80e75 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/layout.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/layout.py @@ -133,8 +133,7 @@ class Layout: # This is a `Window`: focus that. if value not in self.find_all_windows(): raise ValueError( - "Invalid value. Window does not appear in the layout: %r" - % (value,) + f"Invalid value. Window does not appear in the layout: {value!r}" ) self.current_window = value diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/menus.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/menus.py index 7879e3abc6..1a21237a84 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/menus.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/menus.py @@ -2,7 +2,7 @@ from __future__ import annotations import math from itertools import zip_longest -from typing import TYPE_CHECKING, Callable, Iterable, Sequence, Tuple, TypeVar, cast +from typing import TYPE_CHECKING, Callable, Iterable, Sequence, TypeVar, cast from weakref import WeakKeyDictionary from prompt_toolkit.application.current import get_app @@ -332,7 +332,7 @@ class MultiColumnCompletionMenuControl(UIControl): # the count, because a completer can add new completions to the # `CompletionState` while loading.) self._column_width_for_completion_state: WeakKeyDictionary[ - CompletionState, Tuple[int, int] + CompletionState, tuple[int, int] ] = WeakKeyDictionary() # Info of last rendering. diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/mouse_handlers.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/mouse_handlers.py index 2faf99e980..56a4eddd9d 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/mouse_handlers.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/mouse_handlers.py @@ -1,7 +1,7 @@ from __future__ import annotations from collections import defaultdict -from typing import TYPE_CHECKING, Callable, DefaultDict +from typing import TYPE_CHECKING, Callable from prompt_toolkit.mouse_events import MouseEvent @@ -34,8 +34,8 @@ class MouseHandlers: # over the mouse handlers of the visible region in the scrollable pane. # Map y (row) to x (column) to handlers. - self.mouse_handlers: DefaultDict[ - int, DefaultDict[int, MouseHandler] + self.mouse_handlers: defaultdict[ + int, defaultdict[int, MouseHandler] ] = defaultdict(lambda: defaultdict(lambda: dummy_callback)) def set_mouse_handler_for_range( diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/screen.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/screen.py index 17330283d5..49aebbd626 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/screen.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/screen.py @@ -1,7 +1,7 @@ from __future__ import annotations from collections import defaultdict -from typing import TYPE_CHECKING, Callable, DefaultDict +from typing import TYPE_CHECKING, Callable from prompt_toolkit.cache import FastDictCache from prompt_toolkit.data_structures import Point @@ -163,12 +163,12 @@ class Screen: else: default_char2 = default_char - self.data_buffer: DefaultDict[int, DefaultDict[int, Char]] = defaultdict( + self.data_buffer: defaultdict[int, defaultdict[int, Char]] = defaultdict( lambda: defaultdict(lambda: default_char2) ) #: Escape sequences to be injected. - self.zero_width_escapes: DefaultDict[int, DefaultDict[int, str]] = defaultdict( + self.zero_width_escapes: defaultdict[int, defaultdict[int, str]] = defaultdict( lambda: defaultdict(lambda: "") ) diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/pygments.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/pygments.py index 72630cecac..16ed29a287 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/pygments.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/pygments.py @@ -114,7 +114,7 @@ class RegexSync(SyntaxSync): # For HTML, start at any open/close tag definition. "HTML": r"<[/a-zA-Z]", # For javascript, start at a function. - "JavaScript": r"\bfunction\b" + "JavaScript": r"\bfunction\b", # TODO: Add definitions for other languages. # By default, we start at every possible line. } diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/win32.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/win32.py index c93ec7de3c..edeca0968d 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/win32.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/win32.py @@ -6,14 +6,6 @@ assert sys.platform == "win32" import os from ctypes import ArgumentError, byref, c_char, c_long, c_uint, c_ulong, 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: - from ctypes import windll - from ctypes.wintypes import DWORD, HANDLE from typing import Callable, TextIO, TypeVar @@ -29,9 +21,16 @@ from prompt_toolkit.win32_types import ( STD_OUTPUT_HANDLE, ) +from ..utils import SPHINX_AUTODOC_RUNNING from .base import Output from .color_depth import ColorDepth +# 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: + from ctypes import windll + + __all__ = [ "Win32Output", ] diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/renderer.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/renderer.py index 99018f1685..7a3b88a608 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/renderer.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/renderer.py @@ -7,7 +7,7 @@ from __future__ import annotations from asyncio import FIRST_COMPLETED, Future, ensure_future, sleep, wait from collections import deque from enum import Enum -from typing import TYPE_CHECKING, Any, Callable, Deque, Dict, Hashable +from typing import TYPE_CHECKING, Any, Callable, Dict, Hashable from prompt_toolkit.application.current import get_app from prompt_toolkit.cursor_shapes import CursorShape @@ -319,6 +319,7 @@ class _StyleStringHasStyleCache(Dict[str, bool]): class CPR_Support(Enum): "Enum: whether or not CPR is supported." + SUPPORTED = "SUPPORTED" NOT_SUPPORTED = "NOT_SUPPORTED" UNKNOWN = "UNKNOWN" @@ -357,7 +358,7 @@ class Renderer: self._cursor_key_mode_reset = False # Future set when we are waiting for a CPR flag. - self._waiting_for_cpr_futures: Deque[Future[None]] = deque() + self._waiting_for_cpr_futures: deque[Future[None]] = deque() self.cpr_support = CPR_Support.UNKNOWN if not output.responds_to_cpr: diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py index ed56adc94e..7274b5f03e 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py @@ -45,6 +45,7 @@ from prompt_toolkit.cursor_shapes import ( ) from prompt_toolkit.document import Document from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER, EditingMode +from prompt_toolkit.eventloop import InputHook from prompt_toolkit.filters import ( Condition, FilterOrBool, @@ -892,6 +893,7 @@ class PromptSession(Generic[_T]): set_exception_handler: bool = True, handle_sigint: bool = True, in_thread: bool = False, + inputhook: InputHook | None = None, ) -> _T: """ Display the prompt. @@ -1025,6 +1027,7 @@ class PromptSession(Generic[_T]): set_exception_handler=set_exception_handler, in_thread=in_thread, handle_sigint=handle_sigint, + inputhook=inputhook, ) @contextmanager @@ -1393,11 +1396,14 @@ def prompt( enable_open_in_editor: FilterOrBool | None = None, tempfile_suffix: str | Callable[[], str] | None = None, tempfile: str | Callable[[], str] | None = None, - in_thread: bool = False, # Following arguments are specific to the current `prompt()` call. default: str = "", accept_default: bool = False, pre_run: Callable[[], None] | None = None, + set_exception_handler: bool = True, + handle_sigint: bool = True, + in_thread: bool = False, + inputhook: InputHook | None = None, ) -> str: """ The global `prompt` function. This will create a new `PromptSession` @@ -1448,7 +1454,10 @@ def prompt( default=default, accept_default=accept_default, pre_run=pre_run, + set_exception_handler=set_exception_handler, + handle_sigint=handle_sigint, in_thread=in_thread, + inputhook=inputhook, ) diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/utils.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/utils.py index 8cd9fae100..1a99a2868a 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/utils.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/utils.py @@ -8,7 +8,6 @@ from collections import deque from typing import ( Callable, ContextManager, - Deque, Dict, Generator, Generic, @@ -136,7 +135,7 @@ class _CharSizesCache(Dict[str, int]): def __init__(self) -> None: super().__init__() # Keep track of the "long" strings in this cache. - self._long_strings: Deque[str] = deque() + self._long_strings: deque[str] = deque() def __missing__(self, string: str) -> int: # Note: We use the `max(0, ...` because some non printable control diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py index cddb91596d..f36a545755 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py @@ -58,9 +58,8 @@ from prompt_toolkit.layout.controls import ( FormattedTextControl, GetLinePrefixCallable, ) -from prompt_toolkit.layout.dimension import AnyDimension +from prompt_toolkit.layout.dimension import AnyDimension, to_dimension from prompt_toolkit.layout.dimension import Dimension as D -from prompt_toolkit.layout.dimension import to_dimension from prompt_toolkit.layout.margins import ( ConditionalMargin, NumberedMargin, @@ -100,6 +99,7 @@ E = KeyPressEvent class Border: "Box drawing characters. (Thin)" + HORIZONTAL = "\u2500" VERTICAL = "\u2502" TOP_LEFT = "\u250c" |