aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/prompt-toolkit/py2/prompt_toolkit
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:30 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:30 +0300
commit2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch)
tree012bb94d777798f1f56ac1cec429509766d05181 /contrib/python/prompt-toolkit/py2/prompt_toolkit
parent6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff)
downloadydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/prompt-toolkit/py2/prompt_toolkit')
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/__init__.py2
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/application.py42
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/buffer.py98
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/clipboard/base.py10
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/clipboard/in_memory.py48
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/document.py28
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/eventloop/asyncio_posix.py4
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/eventloop/win32.py6
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/interface.py76
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/basic.py82
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/emacs.py96
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/named_commands.py370
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/vi.py426
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/defaults.py238
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/input_processor.py68
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/manager.py58
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/registry.py372
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/layout/containers.py4
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/layout/lexers.py22
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/layout/margins.py8
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/renderer.py26
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/selection.py14
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/shortcuts.py28
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/styles/from_dict.py8
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/styles/from_pygments.py12
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/vt100_input.py22
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/vt100_output.py22
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/win32_input.py8
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/win32_output.py64
29 files changed, 1131 insertions, 1131 deletions
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/__init__.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/__init__.py
index 6478ba4f9a..310f653209 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/__init__.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/__init__.py
@@ -19,4 +19,4 @@ from .shortcuts import prompt, prompt_async
# Don't forget to update in `docs/conf.py`!
-__version__ = '1.0.18'
+__version__ = '1.0.18'
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/application.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/application.py
index 272d8bbcbb..61ff79de4c 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/application.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/application.py
@@ -8,8 +8,8 @@ from .filters import CLIFilter, to_cli_filter
from .key_binding.bindings.basic import load_basic_bindings
from .key_binding.bindings.emacs import load_emacs_bindings
from .key_binding.bindings.vi import load_vi_bindings
-from .key_binding.registry import BaseRegistry
-from .key_binding.defaults import load_key_bindings
+from .key_binding.registry import BaseRegistry
+from .key_binding.defaults import load_key_bindings
from .layout import Window
from .layout.containers import Container
from .layout.controls import BufferControl
@@ -50,17 +50,17 @@ class Application(object):
:param buffer: A :class:`~prompt_toolkit.buffer.Buffer` instance for the default buffer.
:param initial_focussed_buffer: Name of the buffer that is focussed during start-up.
:param key_bindings_registry:
- :class:`~prompt_toolkit.key_binding.registry.BaseRegistry` instance for
- the key bindings.
+ :class:`~prompt_toolkit.key_binding.registry.BaseRegistry` instance for
+ the key bindings.
:param clipboard: :class:`~prompt_toolkit.clipboard.base.Clipboard` to use.
:param on_abort: What to do when Control-C is pressed.
:param on_exit: What to do when Control-D is pressed.
:param use_alternate_screen: When True, run the application on the alternate screen buffer.
:param get_title: Callable that returns the current title to be displayed in the terminal.
:param erase_when_done: (bool) Clear the application output when it finishes.
- :param reverse_vi_search_direction: Normally, in Vi mode, a '/' searches
- forward and a '?' searches backward. In readline mode, this is usually
- reversed.
+ :param reverse_vi_search_direction: Normally, in Vi mode, a '/' searches
+ forward and a '?' searches backward. In readline mode, this is usually
+ reversed.
Filters:
@@ -94,7 +94,7 @@ class Application(object):
paste_mode=False, ignore_case=False, editing_mode=EditingMode.EMACS,
erase_when_done=False,
- reverse_vi_search_direction=False,
+ reverse_vi_search_direction=False,
on_input_timeout=None, on_start=None, on_stop=None,
on_reset=None, on_initialize=None, on_buffer_changed=None,
@@ -103,12 +103,12 @@ class Application(object):
paste_mode = to_cli_filter(paste_mode)
ignore_case = to_cli_filter(ignore_case)
mouse_support = to_cli_filter(mouse_support)
- reverse_vi_search_direction = to_cli_filter(reverse_vi_search_direction)
+ reverse_vi_search_direction = to_cli_filter(reverse_vi_search_direction)
assert layout is None or isinstance(layout, Container)
assert buffer is None or isinstance(buffer, Buffer)
assert buffers is None or isinstance(buffers, (dict, BufferMapping))
- assert key_bindings_registry is None or isinstance(key_bindings_registry, BaseRegistry)
+ assert key_bindings_registry is None or isinstance(key_bindings_registry, BaseRegistry)
assert clipboard is None or isinstance(clipboard, Clipboard)
assert on_abort in AbortAction._all
assert on_exit in AbortAction._all
@@ -151,7 +151,7 @@ class Application(object):
self.style = style or DEFAULT_STYLE
if key_bindings_registry is None:
- key_bindings_registry = load_key_bindings()
+ key_bindings_registry = load_key_bindings()
if get_title is None:
get_title = lambda: None
@@ -168,7 +168,7 @@ class Application(object):
self.ignore_case = ignore_case
self.editing_mode = editing_mode
self.erase_when_done = erase_when_done
- self.reverse_vi_search_direction = reverse_vi_search_direction
+ self.reverse_vi_search_direction = reverse_vi_search_direction
def dummy_handler(cli):
" Dummy event handler. "
@@ -181,12 +181,12 @@ class Application(object):
self.on_buffer_changed = on_buffer_changed or dummy_handler
self.on_render = on_render or dummy_handler
self.on_invalidate = on_invalidate or dummy_handler
-
- # List of 'extra' functions to execute before a CommandLineInterface.run.
- # Note: It's important to keep this here, and not in the
- # CommandLineInterface itself. shortcuts.run_application creates
- # a new Application instance everytime. (Which is correct, it
- # could be that we want to detach from one IO backend and attach
- # the UI on a different backend.) But important is to keep as
- # much state as possible between runs.
- self.pre_run_callables = []
+
+ # List of 'extra' functions to execute before a CommandLineInterface.run.
+ # Note: It's important to keep this here, and not in the
+ # CommandLineInterface itself. shortcuts.run_application creates
+ # a new Application instance everytime. (Which is correct, it
+ # could be that we want to detach from one IO backend and attach
+ # the UI on a different backend.) But important is to keep as
+ # much state as possible between runs.
+ self.pre_run_callables = []
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/buffer.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/buffer.py
index f5df289827..4047fd8c5c 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/buffer.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/buffer.py
@@ -12,7 +12,7 @@ from .enums import IncrementalSearchDirection
from .filters import to_simple_filter
from .history import History, InMemoryHistory
from .search_state import SearchState
-from .selection import SelectionType, SelectionState, PasteMode
+from .selection import SelectionType, SelectionState, PasteMode
from .utils import Event
from .cache import FastDictCache
from .validation import ValidationError
@@ -21,7 +21,7 @@ from six.moves import range
import os
import re
-import shlex
+import shlex
import six
import subprocess
import tempfile
@@ -87,27 +87,27 @@ class AcceptAction(object):
def _return_document_handler(cli, buffer):
- # Set return value.
+ # Set return value.
cli.set_return_value(buffer.document)
- # Make sure that if we run this UI again, that we reset this buffer, next
- # time.
- def reset_this_buffer():
- buffer.reset()
- cli.pre_run_callables.append(reset_this_buffer)
-
+ # Make sure that if we run this UI again, that we reset this buffer, next
+ # time.
+ def reset_this_buffer():
+ buffer.reset()
+ cli.pre_run_callables.append(reset_this_buffer)
+
AcceptAction.RETURN_DOCUMENT = AcceptAction(_return_document_handler)
AcceptAction.IGNORE = AcceptAction(handler=None)
-class ValidationState(object):
- " The validation state of a buffer. This is set after the validation. "
- VALID = 'VALID'
- INVALID = 'INVALID'
- UNKNOWN = 'UNKNOWN'
-
-
+class ValidationState(object):
+ " The validation state of a buffer. This is set after the validation. "
+ VALID = 'VALID'
+ INVALID = 'INVALID'
+ UNKNOWN = 'UNKNOWN'
+
+
class CompletionState(object):
"""
Immutable class that contains a completion state.
@@ -285,7 +285,7 @@ class Buffer(object):
# `ValidationError` instance. (Will be set when the input is wrong.)
self.validation_error = None
- self.validation_state = ValidationState.UNKNOWN
+ self.validation_state = ValidationState.UNKNOWN
# State of the selection.
self.selection_state = None
@@ -304,10 +304,10 @@ class Buffer(object):
# State of Emacs yank-nth-arg completion.
self.yank_nth_arg_state = None # for yank-nth-arg.
- # Remember the document that we had *right before* the last paste
- # operation. This is used for rotating through the kill ring.
- self.document_before_paste = None
-
+ # Remember the document that we had *right before* the last paste
+ # operation. This is used for rotating through the kill ring.
+ self.document_before_paste = None
+
# Current suggestion.
self.suggestion = None
@@ -413,10 +413,10 @@ class Buffer(object):
def _text_changed(self):
# Remove any validation errors and complete state.
self.validation_error = None
- self.validation_state = ValidationState.UNKNOWN
+ self.validation_state = ValidationState.UNKNOWN
self.complete_state = None
self.yank_nth_arg_state = None
- self.document_before_paste = None
+ self.document_before_paste = None
self.selection_state = None
self.suggestion = None
self.preferred_column = None
@@ -427,10 +427,10 @@ class Buffer(object):
def _cursor_position_changed(self):
# Remove any validation errors and complete state.
self.validation_error = None
- self.validation_state = ValidationState.UNKNOWN
+ self.validation_state = ValidationState.UNKNOWN
self.complete_state = None
self.yank_nth_arg_state = None
- self.document_before_paste = None
+ self.document_before_paste = None
# Unset preferred_column. (Will be set after the cursor movement, if
# required.)
@@ -849,7 +849,7 @@ class Buffer(object):
""" Set `history_search_text`. """
if self.enable_history_search():
if self.history_search_text is None:
- self.history_search_text = self.document.text_before_cursor
+ self.history_search_text = self.document.text_before_cursor
else:
self.history_search_text = None
@@ -986,20 +986,20 @@ class Buffer(object):
"""
return self.copy_selection(_cut=True)
- def paste_clipboard_data(self, data, paste_mode=PasteMode.EMACS, count=1):
+ def paste_clipboard_data(self, data, paste_mode=PasteMode.EMACS, count=1):
"""
Insert the data from the clipboard.
"""
assert isinstance(data, ClipboardData)
- assert paste_mode in (PasteMode.VI_BEFORE, PasteMode.VI_AFTER, PasteMode.EMACS)
-
- original_document = self.document
- self.document = self.document.paste_clipboard_data(data, paste_mode=paste_mode, count=count)
-
- # Remember original document. This assignment should come at the end,
- # because assigning to 'document' will erase it.
- self.document_before_paste = original_document
-
+ assert paste_mode in (PasteMode.VI_BEFORE, PasteMode.VI_AFTER, PasteMode.EMACS)
+
+ original_document = self.document
+ self.document = self.document.paste_clipboard_data(data, paste_mode=paste_mode, count=count)
+
+ # Remember original document. This assignment should come at the end,
+ # because assigning to 'document' will erase it.
+ self.document_before_paste = original_document
+
def newline(self, copy_margin=True):
"""
Insert a line ending at the current position.
@@ -1093,10 +1093,10 @@ class Buffer(object):
"""
Returns `True` if valid.
"""
- # Don't call the validator again, if it was already called for the
- # current input.
- if self.validation_state != ValidationState.UNKNOWN:
- return self.validation_state == ValidationState.VALID
+ # Don't call the validator again, if it was already called for the
+ # current input.
+ if self.validation_state != ValidationState.UNKNOWN:
+ return self.validation_state == ValidationState.VALID
# Validate first. If not valid, set validation exception.
if self.validator:
@@ -1107,12 +1107,12 @@ class Buffer(object):
cursor_position = e.cursor_position
self.cursor_position = min(max(0, cursor_position), len(self.text))
- self.validation_state = ValidationState.INVALID
+ self.validation_state = ValidationState.INVALID
self.validation_error = e
return False
- self.validation_state = ValidationState.VALID
- self.validation_error = None
+ self.validation_state = ValidationState.VALID
+ self.validation_error = None
return True
def append_to_history(self):
@@ -1297,13 +1297,13 @@ class Buffer(object):
Return True when we received a zero return code.
"""
- # If the 'VISUAL' or 'EDITOR' environment variable has been set, use that.
+ # If the 'VISUAL' or 'EDITOR' environment variable has been set, use that.
# Otherwise, fall back to the first available editor that we can find.
- visual = os.environ.get('VISUAL')
+ visual = os.environ.get('VISUAL')
editor = os.environ.get('EDITOR')
editors = [
- visual,
+ visual,
editor,
# Order of preference.
@@ -1317,9 +1317,9 @@ class Buffer(object):
for e in editors:
if e:
try:
- # Use 'shlex.split()', because $VISUAL can contain spaces
- # and quotes.
- returncode = subprocess.call(shlex.split(e) + [filename])
+ # Use 'shlex.split()', because $VISUAL can contain spaces
+ # and quotes.
+ returncode = subprocess.call(shlex.split(e) + [filename])
return returncode == 0
except OSError:
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/clipboard/base.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/clipboard/base.py
index 803c0b0e7d..985a506ad6 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/clipboard/base.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/clipboard/base.py
@@ -50,11 +50,11 @@ class Clipboard(with_metaclass(ABCMeta, object)):
assert isinstance(text, six.string_types)
self.set_data(ClipboardData(text))
- def rotate(self):
- """
- For Emacs mode, rotate the kill ring.
- """
-
+ def rotate(self):
+ """
+ For Emacs mode, rotate the kill ring.
+ """
+
@abstractmethod
def get_data(self):
"""
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/clipboard/in_memory.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/clipboard/in_memory.py
index 081666ab80..f81f4056d1 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/clipboard/in_memory.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/clipboard/in_memory.py
@@ -1,7 +1,7 @@
from .base import Clipboard, ClipboardData
-from collections import deque
-
+from collections import deque
+
__all__ = (
'InMemoryClipboard',
)
@@ -11,32 +11,32 @@ class InMemoryClipboard(Clipboard):
"""
Default clipboard implementation.
Just keep the data in memory.
-
- This implements a kill-ring, for Emacs mode.
+
+ This implements a kill-ring, for Emacs mode.
"""
- def __init__(self, data=None, max_size=60):
+ def __init__(self, data=None, max_size=60):
assert data is None or isinstance(data, ClipboardData)
- assert max_size >= 1
-
- self.max_size = max_size
- self._ring = deque()
- if data is not None:
- self.set_data(data)
+ assert max_size >= 1
+ self.max_size = max_size
+ self._ring = deque()
+ if data is not None:
+ self.set_data(data)
+
def set_data(self, data):
assert isinstance(data, ClipboardData)
- self._ring.appendleft(data)
-
- while len(self._ring) > self.max_size:
- self._ring.pop()
+ self._ring.appendleft(data)
+ while len(self._ring) > self.max_size:
+ self._ring.pop()
+
def get_data(self):
- if self._ring:
- return self._ring[0]
- else:
- return ClipboardData()
-
- def rotate(self):
- if self._ring:
- # Add the very first item at the end.
- self._ring.append(self._ring.popleft())
+ if self._ring:
+ return self._ring[0]
+ else:
+ return ClipboardData()
+
+ def rotate(self):
+ if self._ring:
+ # Add the very first item at the end.
+ self._ring.append(self._ring.popleft())
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/document.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/document.py
index 25d817ddd0..4a06348a23 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/document.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/document.py
@@ -10,7 +10,7 @@ import string
import weakref
from six.moves import range, map
-from .selection import SelectionType, SelectionState, PasteMode
+from .selection import SelectionType, SelectionState, PasteMode
from .clipboard import ClipboardData
__all__ = ('Document',)
@@ -874,31 +874,31 @@ class Document(object):
else:
return self, ClipboardData('')
- def paste_clipboard_data(self, data, paste_mode=PasteMode.EMACS, count=1):
+ def paste_clipboard_data(self, data, paste_mode=PasteMode.EMACS, count=1):
"""
Return a new :class:`.Document` instance which contains the result if
we would paste this data at the current cursor position.
- :param paste_mode: Where to paste. (Before/after/emacs.)
+ :param paste_mode: Where to paste. (Before/after/emacs.)
:param count: When >1, Paste multiple times.
"""
assert isinstance(data, ClipboardData)
- assert paste_mode in (PasteMode.VI_BEFORE, PasteMode.VI_AFTER, PasteMode.EMACS)
-
- before = (paste_mode == PasteMode.VI_BEFORE)
- after = (paste_mode == PasteMode.VI_AFTER)
+ assert paste_mode in (PasteMode.VI_BEFORE, PasteMode.VI_AFTER, PasteMode.EMACS)
+ before = (paste_mode == PasteMode.VI_BEFORE)
+ after = (paste_mode == PasteMode.VI_AFTER)
+
if data.type == SelectionType.CHARACTERS:
- if after:
+ if after:
new_text = (self.text[:self.cursor_position + 1] + data.text * count +
self.text[self.cursor_position + 1:])
- else:
- new_text = self.text_before_cursor + data.text * count + self.text_after_cursor
-
- new_cursor_position = self.cursor_position + len(data.text) * count
- if before:
- new_cursor_position -= 1
+ else:
+ new_text = self.text_before_cursor + data.text * count + self.text_after_cursor
+ new_cursor_position = self.cursor_position + len(data.text) * count
+ if before:
+ new_cursor_position -= 1
+
elif data.type == SelectionType.LINES:
l = self.cursor_position_row
if before:
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/eventloop/asyncio_posix.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/eventloop/asyncio_posix.py
index 426ed96f67..3c54992beb 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/eventloop/asyncio_posix.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/eventloop/asyncio_posix.py
@@ -22,7 +22,7 @@ class PosixAsyncioEventLoop(EventLoop):
self.loop = loop or asyncio.get_event_loop()
self.closed = False
- self._stopped_f = asyncio.Future(loop=self.loop)
+ self._stopped_f = asyncio.Future(loop=self.loop)
@asyncio.coroutine
def run_as_coroutine(self, stdin, callbacks):
@@ -41,7 +41,7 @@ class PosixAsyncioEventLoop(EventLoop):
try:
# Create a new Future every time.
- self._stopped_f = asyncio.Future(loop=self.loop)
+ self._stopped_f = asyncio.Future(loop=self.loop)
# Handle input timouts
def timeout_handler():
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/eventloop/win32.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/eventloop/win32.py
index 18e356f088..e13c4c22ee 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/eventloop/win32.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/eventloop/win32.py
@@ -36,7 +36,7 @@ class Win32EventLoop(EventLoop):
def __init__(self, inputhook=None, recognize_paste=True):
assert inputhook is None or callable(inputhook)
- self._event = HANDLE(_create_event())
+ self._event = HANDLE(_create_event())
self._console_input_reader = ConsoleInputReader(recognize_paste=recognize_paste)
self._calls_from_executor = []
@@ -74,14 +74,14 @@ class Win32EventLoop(EventLoop):
# Wait for the next event.
handle = self._ready_for_reading(remaining_timeout)
- if handle == self._console_input_reader.handle.value:
+ if handle == self._console_input_reader.handle.value:
# When stdin is ready, read input and reset timeout timer.
keys = self._console_input_reader.read()
for k in keys:
callbacks.feed_key(k)
current_timeout = INPUT_TIMEOUT_MS
- elif handle == self._event.value:
+ elif handle == self._event.value:
# When the Windows Event has been trigger, process the messages in the queue.
windll.kernel32.ResetEvent(self._event)
self._process_queued_calls_from_executor()
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/interface.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/interface.py
index e1e0e56393..bf5111542b 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/interface.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/interface.py
@@ -87,9 +87,9 @@ class CommandLineInterface(object):
#: EditingMode.VI or EditingMode.EMACS
self.editing_mode = application.editing_mode
- #: Quoted insert. This flag is set if we go into quoted insert mode.
- self.quoted_insert = False
-
+ #: Quoted insert. This flag is set if we go into quoted insert mode.
+ self.quoted_insert = False
+
#: Vi state. (For Vi key bindings.)
self.vi_state = ViState()
@@ -148,10 +148,10 @@ class CommandLineInterface(object):
def clipboard(self):
return self.application.clipboard
- @property
- def pre_run_callables(self):
- return self.application.pre_run_callables
-
+ @property
+ def pre_run_callables(self):
+ return self.application.pre_run_callables
+
def add_buffer(self, name, buffer, focus=False):
"""
Insert a new buffer.
@@ -275,10 +275,10 @@ class CommandLineInterface(object):
"""
Reset everything, for reading the next input.
- :param reset_current_buffer: XXX: not used anymore. The reason for
- having this option in the past was when this CommandLineInterface
- is run multiple times, that we could reset the buffer content from
- the previous run. This is now handled in the AcceptAction.
+ :param reset_current_buffer: XXX: not used anymore. The reason for
+ having this option in the past was when this CommandLineInterface
+ is run multiple times, that we could reset the buffer content from
+ the previous run. This is now handled in the AcceptAction.
"""
# Notice that we don't reset the buffers. (This happens just before
# returning, and when we have multiple buffers, we clearly want the
@@ -372,27 +372,27 @@ class CommandLineInterface(object):
self.renderer.request_absolute_cursor_position()
self._redraw()
- def _load_next_buffer_indexes(self):
- for buff, index in self._next_buffer_indexes.items():
- if buff in self.buffers:
- self.buffers[buff].working_index = index
-
- def _pre_run(self, pre_run=None):
- " Called during `run`. "
- if pre_run:
- pre_run()
-
- # Process registered "pre_run_callables" and clear list.
- for c in self.pre_run_callables:
- c()
- del self.pre_run_callables[:]
-
+ def _load_next_buffer_indexes(self):
+ for buff, index in self._next_buffer_indexes.items():
+ if buff in self.buffers:
+ self.buffers[buff].working_index = index
+
+ def _pre_run(self, pre_run=None):
+ " Called during `run`. "
+ if pre_run:
+ pre_run()
+
+ # Process registered "pre_run_callables" and clear list.
+ for c in self.pre_run_callables:
+ c()
+ del self.pre_run_callables[:]
+
def run(self, reset_current_buffer=False, pre_run=None):
"""
Read input from the command line.
This runs the eventloop until a return value has been set.
- :param reset_current_buffer: XXX: Not used anymore.
+ :param reset_current_buffer: XXX: Not used anymore.
:param pre_run: Callable that is called right after the reset has taken
place. This allows custom initialisation.
"""
@@ -402,10 +402,10 @@ class CommandLineInterface(object):
self._is_running = True
self.on_start.fire()
- self.reset()
+ self.reset()
# Call pre_run.
- self._pre_run(pre_run)
+ self._pre_run(pre_run)
# Run eventloop in raw mode.
with self.input.raw_mode():
@@ -454,10 +454,10 @@ class CommandLineInterface(object):
self._is_running = True
self.on_start.fire()
- self.reset()
+ self.reset()
# Call pre_run.
- self._pre_run(pre_run)
+ self._pre_run(pre_run)
with self.input.raw_mode():
self.renderer.request_absolute_cursor_position()
@@ -611,7 +611,7 @@ class CommandLineInterface(object):
if self.eventloop:
self.eventloop.stop()
- def run_in_terminal(self, func, render_cli_done=False, cooked_mode=True):
+ def run_in_terminal(self, func, render_cli_done=False, cooked_mode=True):
"""
Run function on the terminal above the prompt.
@@ -624,8 +624,8 @@ class CommandLineInterface(object):
:param render_cli_done: When True, render the interface in the
'Done' state first, then execute the function. If False,
erase the interface first.
- :param cooked_mode: When True (the default), switch the input to
- cooked mode while executing the function.
+ :param cooked_mode: When True (the default), switch the input to
+ cooked mode while executing the function.
:returns: the result of `func`.
"""
@@ -639,10 +639,10 @@ class CommandLineInterface(object):
self._return_value = None
# Run system command.
- if cooked_mode:
- with self.input.cooked_mode():
- result = func()
- else:
+ if cooked_mode:
+ with self.input.cooked_mode():
+ result = func()
+ else:
result = func()
# Redraw interface again.
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/basic.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/basic.py
index 401135dec0..6b36bc30f5 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/basic.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/basic.py
@@ -2,7 +2,7 @@
from __future__ import unicode_literals
from prompt_toolkit.enums import DEFAULT_BUFFER
-from prompt_toolkit.filters import HasSelection, Condition, EmacsInsertMode, ViInsertMode
+from prompt_toolkit.filters import HasSelection, Condition, EmacsInsertMode, ViInsertMode
from prompt_toolkit.keys import Keys
from prompt_toolkit.layout.screen import Point
from prompt_toolkit.mouse_events import MouseEventType, MouseEvent
@@ -10,7 +10,7 @@ from prompt_toolkit.renderer import HeightIsUnknownError
from prompt_toolkit.utils import suspend_to_background_supported, is_windows
from .named_commands import get_by_name
-from ..registry import Registry
+from ..registry import Registry
__all__ = (
@@ -26,10 +26,10 @@ def if_no_repeat(event):
return not event.is_repeat
-def load_basic_bindings():
- registry = Registry()
+def load_basic_bindings():
+ registry = Registry()
insert_mode = ViInsertMode() | EmacsInsertMode()
- handle = registry.add_binding
+ handle = registry.add_binding
has_selection = HasSelection()
@handle(Keys.ControlA)
@@ -141,8 +141,8 @@ def load_basic_bindings():
get_by_name('self-insert'))
handle(Keys.ControlT, filter=insert_mode)(get_by_name('transpose-chars'))
handle(Keys.ControlW, filter=insert_mode)(get_by_name('unix-word-rubout'))
- handle(Keys.ControlI, filter=insert_mode)(get_by_name('menu-complete'))
- handle(Keys.BackTab, filter=insert_mode)(get_by_name('menu-complete-backward'))
+ handle(Keys.ControlI, filter=insert_mode)(get_by_name('menu-complete'))
+ handle(Keys.BackTab, filter=insert_mode)(get_by_name('menu-complete-backward'))
handle(Keys.PageUp, filter= ~has_selection)(get_by_name('previous-history'))
handle(Keys.PageDown, filter= ~has_selection)(get_by_name('next-history'))
@@ -181,7 +181,7 @@ def load_basic_bindings():
data = event.current_buffer.cut_selection()
event.cli.clipboard.set_data(data)
- # Global bindings.
+ # Global bindings.
@handle(Keys.ControlZ)
def _(event):
@@ -196,7 +196,7 @@ def load_basic_bindings():
"""
event.current_buffer.insert_text(event.data)
- @handle(Keys.CPRResponse, save_before=lambda e: False)
+ @handle(Keys.CPRResponse, save_before=lambda e: False)
def _(event):
"""
Handle incoming Cursor-Position-Request response.
@@ -208,7 +208,7 @@ def load_basic_bindings():
# Report absolute cursor position to the renderer.
event.cli.renderer.report_absolute_cursor_row(row)
- @handle(Keys.BracketedPaste)
+ @handle(Keys.BracketedPaste)
def _(event):
" Pasting from clipboard. "
data = event.data
@@ -221,24 +221,24 @@ def load_basic_bindings():
event.current_buffer.insert_text(data)
- @handle(Keys.Any, filter=Condition(lambda cli: cli.quoted_insert), eager=True)
- def _(event):
- """
- Handle quoted insert.
- """
- event.current_buffer.insert_text(event.data, overwrite=False)
- event.cli.quoted_insert = False
-
- return registry
-
-
-def load_mouse_bindings():
+ @handle(Keys.Any, filter=Condition(lambda cli: cli.quoted_insert), eager=True)
+ def _(event):
+ """
+ Handle quoted insert.
+ """
+ event.current_buffer.insert_text(event.data, overwrite=False)
+ event.cli.quoted_insert = False
+
+ return registry
+
+
+def load_mouse_bindings():
"""
Key bindings, required for mouse support.
(Mouse events enter through the key binding system.)
"""
- registry = Registry()
-
+ registry = Registry()
+
@registry.add_binding(Keys.Vt100MouseEvent)
def _(event):
"""
@@ -335,15 +335,15 @@ def load_mouse_bindings():
handler(event.cli, MouseEvent(position=Point(x=x, y=y),
event_type=event_type))
- return registry
-
+ return registry
-def load_abort_and_exit_bindings():
+
+def load_abort_and_exit_bindings():
"""
Basic bindings for abort (Ctrl-C) and exit (Ctrl-D).
"""
- registry = Registry()
- handle = registry.add_binding
+ registry = Registry()
+ handle = registry.add_binding
@handle(Keys.ControlC)
def _(event):
@@ -359,34 +359,34 @@ def load_abort_and_exit_bindings():
handle(Keys.ControlD, filter=ctrl_d_condition)(get_by_name('end-of-file'))
- return registry
-
+ return registry
-def load_basic_system_bindings():
+
+def load_basic_system_bindings():
"""
Basic system bindings (For both Emacs and Vi mode.)
"""
- registry = Registry()
+ registry = Registry()
suspend_supported = Condition(
lambda cli: suspend_to_background_supported())
- @registry.add_binding(Keys.ControlZ, filter=suspend_supported)
+ @registry.add_binding(Keys.ControlZ, filter=suspend_supported)
def _(event):
"""
Suspend process to background.
"""
event.cli.suspend_to_background()
- return registry
+ return registry
-
-def load_auto_suggestion_bindings():
+
+def load_auto_suggestion_bindings():
"""
Key bindings for accepting auto suggestion text.
"""
- registry = Registry()
- handle = registry.add_binding
+ registry = Registry()
+ handle = registry.add_binding
suggestion_available = Condition(
lambda cli:
@@ -403,5 +403,5 @@ def load_auto_suggestion_bindings():
if suggestion:
b.insert_text(suggestion.text)
-
- return registry
+
+ return registry
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/emacs.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/emacs.py
index bccdb04ff3..0f4ea37b01 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/emacs.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/emacs.py
@@ -3,12 +3,12 @@ from __future__ import unicode_literals
from prompt_toolkit.buffer import SelectionType, indent, unindent
from prompt_toolkit.keys import Keys
from prompt_toolkit.enums import IncrementalSearchDirection, SEARCH_BUFFER, SYSTEM_BUFFER
-from prompt_toolkit.filters import Condition, EmacsMode, HasSelection, EmacsInsertMode, HasFocus, HasArg
+from prompt_toolkit.filters import Condition, EmacsMode, HasSelection, EmacsInsertMode, HasFocus, HasArg
from prompt_toolkit.completion import CompleteEvent
from .scroll import scroll_page_up, scroll_page_down
from .named_commands import get_by_name
-from ..registry import Registry, ConditionalRegistry
+from ..registry import Registry, ConditionalRegistry
__all__ = (
'load_emacs_bindings',
@@ -18,14 +18,14 @@ __all__ = (
)
-def load_emacs_bindings():
+def load_emacs_bindings():
"""
Some e-macs extensions.
"""
# Overview of Readline emacs commands:
# http://www.catonmat.net/download/readline-emacs-editing-mode-cheat-sheet.pdf
- registry = ConditionalRegistry(Registry(), EmacsMode())
- handle = registry.add_binding
+ registry = ConditionalRegistry(Registry(), EmacsMode())
+ handle = registry.add_binding
insert_mode = EmacsInsertMode()
has_selection = HasSelection()
@@ -57,9 +57,9 @@ def load_emacs_bindings():
handle(Keys.Escape, 'f')(get_by_name('forward-word'))
handle(Keys.Escape, 'l', filter=insert_mode)(get_by_name('downcase-word'))
handle(Keys.Escape, 'u', filter=insert_mode)(get_by_name('uppercase-word'))
- handle(Keys.Escape, 'y', filter=insert_mode)(get_by_name('yank-pop'))
- handle(Keys.Escape, Keys.ControlH, filter=insert_mode)(get_by_name('backward-kill-word'))
- handle(Keys.Escape, Keys.Backspace, filter=insert_mode)(get_by_name('backward-kill-word'))
+ handle(Keys.Escape, 'y', filter=insert_mode)(get_by_name('yank-pop'))
+ handle(Keys.Escape, Keys.ControlH, filter=insert_mode)(get_by_name('backward-kill-word'))
+ handle(Keys.Escape, Keys.Backspace, filter=insert_mode)(get_by_name('backward-kill-word'))
handle(Keys.Escape, '\\', filter=insert_mode)(get_by_name('delete-horizontal-space'))
handle(Keys.ControlUnderscore, save_before=(lambda e: False), filter=insert_mode)(
@@ -75,18 +75,18 @@ def load_emacs_bindings():
handle(Keys.Escape, '.', filter=insert_mode)(get_by_name('yank-last-arg'))
handle(Keys.Escape, '_', filter=insert_mode)(get_by_name('yank-last-arg'))
handle(Keys.Escape, Keys.ControlY, filter=insert_mode)(get_by_name('yank-nth-arg'))
- handle(Keys.Escape, '#', filter=insert_mode)(get_by_name('insert-comment'))
- handle(Keys.ControlO)(get_by_name('operate-and-get-next'))
-
- # ControlQ does a quoted insert. Not that for vt100 terminals, you have to
- # disable flow control by running ``stty -ixon``, otherwise Ctrl-Q and
- # Ctrl-S are captured by the terminal.
- handle(Keys.ControlQ, filter= ~has_selection)(get_by_name('quoted-insert'))
-
- handle(Keys.ControlX, '(')(get_by_name('start-kbd-macro'))
- handle(Keys.ControlX, ')')(get_by_name('end-kbd-macro'))
- handle(Keys.ControlX, 'e')(get_by_name('call-last-kbd-macro'))
-
+ handle(Keys.Escape, '#', filter=insert_mode)(get_by_name('insert-comment'))
+ handle(Keys.ControlO)(get_by_name('operate-and-get-next'))
+
+ # ControlQ does a quoted insert. Not that for vt100 terminals, you have to
+ # disable flow control by running ``stty -ixon``, otherwise Ctrl-Q and
+ # Ctrl-S are captured by the terminal.
+ handle(Keys.ControlQ, filter= ~has_selection)(get_by_name('quoted-insert'))
+
+ handle(Keys.ControlX, '(')(get_by_name('start-kbd-macro'))
+ handle(Keys.ControlX, ')')(get_by_name('end-kbd-macro'))
+ handle(Keys.ControlX, 'e')(get_by_name('call-last-kbd-macro'))
+
@handle(Keys.ControlN)
def _(event):
" Next line. "
@@ -144,13 +144,13 @@ def load_emacs_bindings():
@handle(Keys.ControlSquareClose, Keys.Any)
def _(event):
" When Ctl-] + a character is pressed. go to that character. "
- # Also named 'character-search'
+ # Also named 'character-search'
character_search(event.current_buffer, event.data, event.arg)
@handle(Keys.Escape, Keys.ControlSquareClose, Keys.Any)
def _(event):
" Like Ctl-], but backwards. "
- # Also named 'character-search-backward'
+ # Also named 'character-search-backward'
character_search(event.current_buffer, event.data, -event.arg)
@handle(Keys.Escape, 'a')
@@ -296,26 +296,26 @@ def load_emacs_bindings():
unindent(buffer, from_, to + 1, count=event.arg)
- return registry
+ return registry
-
-def load_emacs_open_in_editor_bindings():
+
+def load_emacs_open_in_editor_bindings():
"""
Pressing C-X C-E will open the buffer in an external editor.
"""
- registry = Registry()
-
- registry.add_binding(Keys.ControlX, Keys.ControlE,
- filter=EmacsMode() & ~HasSelection())(
- get_by_name('edit-and-execute-command'))
+ registry = Registry()
- return registry
+ registry.add_binding(Keys.ControlX, Keys.ControlE,
+ filter=EmacsMode() & ~HasSelection())(
+ get_by_name('edit-and-execute-command'))
+ return registry
-def load_emacs_system_bindings():
- registry = ConditionalRegistry(Registry(), EmacsMode())
- handle = registry.add_binding
-
+
+def load_emacs_system_bindings():
+ registry = ConditionalRegistry(Registry(), EmacsMode())
+ handle = registry.add_binding
+
has_focus = HasFocus(SYSTEM_BUFFER)
@handle(Keys.Escape, '!', filter= ~has_focus)
@@ -347,13 +347,13 @@ def load_emacs_system_bindings():
# Focus previous buffer again.
event.cli.pop_focus()
- return registry
-
+ return registry
-def load_emacs_search_bindings(get_search_state=None):
- registry = ConditionalRegistry(Registry(), EmacsMode())
- handle = registry.add_binding
+def load_emacs_search_bindings(get_search_state=None):
+ registry = ConditionalRegistry(Registry(), EmacsMode())
+ handle = registry.add_binding
+
has_focus = HasFocus(SEARCH_BUFFER)
assert get_search_state is None or callable(get_search_state)
@@ -375,7 +375,7 @@ def load_emacs_search_bindings(get_search_state=None):
event.cli.pop_focus()
@handle(Keys.ControlJ, filter=has_focus)
- @handle(Keys.Escape, filter=has_focus, eager=True)
+ @handle(Keys.Escape, filter=has_focus, eager=True)
def _(event):
"""
When enter pressed in isearch, quit isearch mode. (Multiline
@@ -433,20 +433,20 @@ def load_emacs_search_bindings(get_search_state=None):
def _(event):
incremental_search(event.cli, IncrementalSearchDirection.FORWARD, count=event.arg)
- return registry
+ return registry
-
-def load_extra_emacs_page_navigation_bindings():
+
+def load_extra_emacs_page_navigation_bindings():
"""
Key bindings, for scrolling up and down through pages.
This are separate bindings, because GNU readline doesn't have them.
"""
- registry = ConditionalRegistry(Registry(), EmacsMode())
- handle = registry.add_binding
+ registry = ConditionalRegistry(Registry(), EmacsMode())
+ handle = registry.add_binding
handle(Keys.ControlV)(scroll_page_down)
handle(Keys.PageDown)(scroll_page_down)
handle(Keys.Escape, 'v')(scroll_page_up)
handle(Keys.PageUp)(scroll_page_up)
-
- return registry
+
+ return registry
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/named_commands.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/named_commands.py
index f80c439fc6..d045b1268f 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/named_commands.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/named_commands.py
@@ -5,15 +5,15 @@ See: http://www.delorie.com/gnu/docs/readline/rlman_13.html
"""
from __future__ import unicode_literals
from prompt_toolkit.enums import IncrementalSearchDirection, SEARCH_BUFFER
-from prompt_toolkit.selection import PasteMode
+from prompt_toolkit.selection import PasteMode
from six.moves import range
import six
-from .completion import generate_completions, display_completions_like_readline
-from prompt_toolkit.document import Document
-from prompt_toolkit.enums import EditingMode
-from prompt_toolkit.key_binding.input_processor import KeyPress
-from prompt_toolkit.keys import Keys
+from .completion import generate_completions, display_completions_like_readline
+from prompt_toolkit.document import Document
+from prompt_toolkit.enums import EditingMode
+from prompt_toolkit.key_binding.input_processor import KeyPress
+from prompt_toolkit.keys import Keys
__all__ = (
'get_by_name',
@@ -134,13 +134,13 @@ def accept_line(event):
@register('previous-history')
def previous_history(event):
- " Move `back` through the history list, fetching the previous command. "
+ " Move `back` through the history list, fetching the previous command. "
event.current_buffer.history_backward(count=event.arg)
@register('next-history')
def next_history(event):
- " Move `forward` through the history list, fetching the next command. "
+ " Move `forward` through the history list, fetching the next command. "
event.current_buffer.history_forward(count=event.arg)
@@ -163,13 +163,13 @@ def end_of_history(event):
@register('reverse-search-history')
def reverse_search_history(event):
"""
- Search backward starting at the current line and moving `up` through
+ Search backward starting at the current line and moving `up` through
the history as necessary. This is an incremental search.
"""
event.cli.current_search_state.direction = IncrementalSearchDirection.BACKWARD
event.cli.push_focus(SEARCH_BUFFER)
-
+
#
# Commands for changing text
#
@@ -267,16 +267,16 @@ def capitalize_word(event):
words = buff.document.text_after_cursor[:pos]
buff.insert_text(words.title(), overwrite=True)
-
-@register('quoted-insert')
-def quoted_insert(event):
- """
- Add the next character typed to the line verbatim. This is how to insert
- key sequences like C-q, for example.
- """
- event.cli.quoted_insert = True
-
-
+
+@register('quoted-insert')
+def quoted_insert(event):
+ """
+ Add the next character typed to the line verbatim. This is how to insert
+ key sequences like C-q, for example.
+ """
+ event.cli.quoted_insert = True
+
+
#
# Killing and yanking.
#
@@ -316,13 +316,13 @@ def kill_word(event):
@register('unix-word-rubout')
-def unix_word_rubout(event, WORD=True):
+def unix_word_rubout(event, WORD=True):
"""
- Kill the word behind point, using whitespace as a word boundary.
- Usually bound to ControlW.
+ Kill the word behind point, using whitespace as a word boundary.
+ Usually bound to ControlW.
"""
buff = event.current_buffer
- pos = buff.document.find_start_of_previous_word(count=event.arg, WORD=WORD)
+ pos = buff.document.find_start_of_previous_word(count=event.arg, WORD=WORD)
if pos is None:
# Nothing found? delete until the start of the document. (The
@@ -344,15 +344,15 @@ def unix_word_rubout(event, WORD=True):
event.cli.output.bell()
-@register('backward-kill-word')
-def backward_kill_word(event):
- """
- Kills the word before point, using "not a letter nor a digit" as a word boundary.
- Usually bound to M-Del or M-Backspace.
- """
- unix_word_rubout(event, WORD=False)
-
-
+@register('backward-kill-word')
+def backward_kill_word(event):
+ """
+ Kills the word before point, using "not a letter nor a digit" as a word boundary.
+ Usually bound to M-Del or M-Backspace.
+ """
+ unix_word_rubout(event, WORD=False)
+
+
@register('delete-horizontal-space')
def delete_horizontal_space(event):
" Delete all spaces and tabs around point. "
@@ -387,7 +387,7 @@ def yank(event):
Paste before cursor.
"""
event.current_buffer.paste_clipboard_data(
- event.cli.clipboard.get_data(), count=event.arg, paste_mode=PasteMode.EMACS)
+ event.cli.clipboard.get_data(), count=event.arg, paste_mode=PasteMode.EMACS)
@register('yank-nth-arg')
def yank_nth_arg(event):
@@ -408,86 +408,86 @@ def yank_last_arg(event):
n = (event.arg if event.arg_present else None)
event.current_buffer.yank_last_arg(n)
-@register('yank-pop')
-def yank_pop(event):
- """
- Rotate the kill ring, and yank the new top. Only works following yank or
- yank-pop.
- """
- buff = event.current_buffer
- doc_before_paste = buff.document_before_paste
- clipboard = event.cli.clipboard
-
- if doc_before_paste is not None:
- buff.document = doc_before_paste
- clipboard.rotate()
- buff.paste_clipboard_data(
- clipboard.get_data(), paste_mode=PasteMode.EMACS)
-
+@register('yank-pop')
+def yank_pop(event):
+ """
+ Rotate the kill ring, and yank the new top. Only works following yank or
+ yank-pop.
+ """
+ buff = event.current_buffer
+ doc_before_paste = buff.document_before_paste
+ clipboard = event.cli.clipboard
+
+ if doc_before_paste is not None:
+ buff.document = doc_before_paste
+ clipboard.rotate()
+ buff.paste_clipboard_data(
+ clipboard.get_data(), paste_mode=PasteMode.EMACS)
+
#
# Completion.
#
@register('complete')
def complete(event):
- " Attempt to perform completion. "
- display_completions_like_readline(event)
-
-
-@register('menu-complete')
-def menu_complete(event):
- """
- Generate completions, or go to the next completion. (This is the default
- way of completing input in prompt_toolkit.)
- """
+ " Attempt to perform completion. "
+ display_completions_like_readline(event)
+
+
+@register('menu-complete')
+def menu_complete(event):
+ """
+ Generate completions, or go to the next completion. (This is the default
+ way of completing input in prompt_toolkit.)
+ """
generate_completions(event)
-@register('menu-complete-backward')
-def menu_complete_backward(event):
- " Move backward through the list of possible completions. "
- event.current_buffer.complete_previous()
-
-#
-# Keyboard macros.
-#
-
-@register('start-kbd-macro')
-def start_kbd_macro(event):
- """
- Begin saving the characters typed into the current keyboard macro.
- """
- event.cli.input_processor.start_macro()
-
-
-@register('end-kbd-macro')
-def start_kbd_macro(event):
- """
- Stop saving the characters typed into the current keyboard macro and save
- the definition.
- """
- event.cli.input_processor.end_macro()
-
-
-@register('call-last-kbd-macro')
-def start_kbd_macro(event):
- """
- Re-execute the last keyboard macro defined, by making the characters in the
- macro appear as if typed at the keyboard.
- """
- event.cli.input_processor.call_macro()
-
-
-@register('print-last-kbd-macro')
-def print_last_kbd_macro(event):
- " Print the last keboard macro. "
- # TODO: Make the format suitable for the inputrc file.
- def print_macro():
- for k in event.cli.input_processor.macro:
- print(k)
- event.cli.run_in_terminal(print_macro)
-
+@register('menu-complete-backward')
+def menu_complete_backward(event):
+ " Move backward through the list of possible completions. "
+ event.current_buffer.complete_previous()
+
#
+# Keyboard macros.
+#
+
+@register('start-kbd-macro')
+def start_kbd_macro(event):
+ """
+ Begin saving the characters typed into the current keyboard macro.
+ """
+ event.cli.input_processor.start_macro()
+
+
+@register('end-kbd-macro')
+def start_kbd_macro(event):
+ """
+ Stop saving the characters typed into the current keyboard macro and save
+ the definition.
+ """
+ event.cli.input_processor.end_macro()
+
+
+@register('call-last-kbd-macro')
+def start_kbd_macro(event):
+ """
+ Re-execute the last keyboard macro defined, by making the characters in the
+ macro appear as if typed at the keyboard.
+ """
+ event.cli.input_processor.call_macro()
+
+
+@register('print-last-kbd-macro')
+def print_last_kbd_macro(event):
+ " Print the last keboard macro. "
+ # TODO: Make the format suitable for the inputrc file.
+ def print_macro():
+ for k in event.cli.input_processor.macro:
+ print(k)
+ event.cli.run_in_terminal(print_macro)
+
+#
# Miscellaneous Commands.
#
@@ -495,84 +495,84 @@ def print_last_kbd_macro(event):
def undo(event):
" Incremental undo. "
event.current_buffer.undo()
-
-
-@register('insert-comment')
-def insert_comment(event):
- """
- Without numeric argument, comment all lines.
- With numeric argument, uncomment all lines.
- In any case accept the input.
- """
- buff = event.current_buffer
-
- # Transform all lines.
- if event.arg != 1:
- def change(line):
- return line[1:] if line.startswith('#') else line
- else:
- def change(line):
- return '#' + line
-
- buff.document = Document(
- text='\n'.join(map(change, buff.text.splitlines())),
- cursor_position=0)
-
- # Accept input.
- buff.accept_action.validate_and_handle(event.cli, buff)
-
-
-@register('vi-editing-mode')
-def vi_editing_mode(event):
- " Switch to Vi editing mode. "
- event.cli.editing_mode = EditingMode.VI
-
-
-@register('emacs-editing-mode')
-def emacs_editing_mode(event):
- " Switch to Emacs editing mode. "
- event.cli.editing_mode = EditingMode.EMACS
-
-
-@register('prefix-meta')
-def prefix_meta(event):
- """
- Metafy the next character typed. This is for keyboards without a meta key.
-
- Sometimes people also want to bind other keys to Meta, e.g. 'jj'::
-
- registry.add_key_binding('j', 'j', filter=ViInsertMode())(prefix_meta)
- """
- event.cli.input_processor.feed(KeyPress(Keys.Escape))
-
-
-@register('operate-and-get-next')
-def operate_and_get_next(event):
- """
- Accept the current line for execution and fetch the next line relative to
- the current line from the history for editing.
- """
- buff = event.current_buffer
- new_index = buff.working_index + 1
-
- # Accept the current input. (This will also redraw the interface in the
- # 'done' state.)
- buff.accept_action.validate_and_handle(event.cli, buff)
-
- # Set the new index at the start of the next run.
- def set_working_index():
- if new_index < len(buff._working_lines):
- buff.working_index = new_index
-
- event.cli.pre_run_callables.append(set_working_index)
-
-
-@register('edit-and-execute-command')
-def edit_and_execute(event):
- """
- Invoke an editor on the current command line, and accept the result.
- """
- buff = event.current_buffer
-
- buff.open_in_editor(event.cli)
- buff.accept_action.validate_and_handle(event.cli, buff)
+
+
+@register('insert-comment')
+def insert_comment(event):
+ """
+ Without numeric argument, comment all lines.
+ With numeric argument, uncomment all lines.
+ In any case accept the input.
+ """
+ buff = event.current_buffer
+
+ # Transform all lines.
+ if event.arg != 1:
+ def change(line):
+ return line[1:] if line.startswith('#') else line
+ else:
+ def change(line):
+ return '#' + line
+
+ buff.document = Document(
+ text='\n'.join(map(change, buff.text.splitlines())),
+ cursor_position=0)
+
+ # Accept input.
+ buff.accept_action.validate_and_handle(event.cli, buff)
+
+
+@register('vi-editing-mode')
+def vi_editing_mode(event):
+ " Switch to Vi editing mode. "
+ event.cli.editing_mode = EditingMode.VI
+
+
+@register('emacs-editing-mode')
+def emacs_editing_mode(event):
+ " Switch to Emacs editing mode. "
+ event.cli.editing_mode = EditingMode.EMACS
+
+
+@register('prefix-meta')
+def prefix_meta(event):
+ """
+ Metafy the next character typed. This is for keyboards without a meta key.
+
+ Sometimes people also want to bind other keys to Meta, e.g. 'jj'::
+
+ registry.add_key_binding('j', 'j', filter=ViInsertMode())(prefix_meta)
+ """
+ event.cli.input_processor.feed(KeyPress(Keys.Escape))
+
+
+@register('operate-and-get-next')
+def operate_and_get_next(event):
+ """
+ Accept the current line for execution and fetch the next line relative to
+ the current line from the history for editing.
+ """
+ buff = event.current_buffer
+ new_index = buff.working_index + 1
+
+ # Accept the current input. (This will also redraw the interface in the
+ # 'done' state.)
+ buff.accept_action.validate_and_handle(event.cli, buff)
+
+ # Set the new index at the start of the next run.
+ def set_working_index():
+ if new_index < len(buff._working_lines):
+ buff.working_index = new_index
+
+ event.cli.pre_run_callables.append(set_working_index)
+
+
+@register('edit-and-execute-command')
+def edit_and_execute(event):
+ """
+ Invoke an editor on the current command line, and accept the result.
+ """
+ buff = event.current_buffer
+
+ buff.open_in_editor(event.cli)
+ buff.accept_action.validate_and_handle(event.cli, buff)
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/vi.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/vi.py
index 72568ee273..25133196af 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/vi.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/bindings/vi.py
@@ -3,17 +3,17 @@ from __future__ import unicode_literals
from prompt_toolkit.buffer import ClipboardData, indent, unindent, reshape_text
from prompt_toolkit.document import Document
from prompt_toolkit.enums import IncrementalSearchDirection, SEARCH_BUFFER, SYSTEM_BUFFER
-from prompt_toolkit.filters import Filter, Condition, HasArg, Always, IsReadOnly
+from prompt_toolkit.filters import Filter, Condition, HasArg, Always, IsReadOnly
from prompt_toolkit.filters.cli import ViNavigationMode, ViInsertMode, ViInsertMultipleMode, ViReplaceMode, ViSelectionMode, ViWaitingForTextObjectMode, ViDigraphMode, ViMode
from prompt_toolkit.key_binding.digraphs import DIGRAPHS
from prompt_toolkit.key_binding.vi_state import CharacterFind, InputMode
from prompt_toolkit.keys import Keys
from prompt_toolkit.layout.utils import find_window_for_buffer_name
-from prompt_toolkit.selection import SelectionType, SelectionState, PasteMode
+from prompt_toolkit.selection import SelectionType, SelectionState, PasteMode
from .scroll import scroll_forward, scroll_backward, scroll_half_page_up, scroll_half_page_down, scroll_one_line_up, scroll_one_line_down, scroll_page_up, scroll_page_down
-from .named_commands import get_by_name
-from ..registry import Registry, ConditionalRegistry, BaseRegistry
+from .named_commands import get_by_name
+from ..registry import Registry, ConditionalRegistry, BaseRegistry
import prompt_toolkit.filters as filters
from six.moves import range
@@ -137,168 +137,168 @@ class TextObject(object):
return new_document, clipboard_data
-def create_text_object_decorator(registry):
- """
- Create a decorator that can be used to register Vi text object implementations.
- """
- assert isinstance(registry, BaseRegistry)
-
- operator_given = ViWaitingForTextObjectMode()
- navigation_mode = ViNavigationMode()
- selection_mode = ViSelectionMode()
-
- def text_object_decorator(*keys, **kw):
- """
- Register a text object function.
-
- Usage::
-
- @text_object('w', filter=..., no_move_handler=False)
- def handler(event):
- # Return a text object for this key.
- return TextObject(...)
-
- :param no_move_handler: Disable the move handler in navigation mode.
- (It's still active in selection mode.)
- """
- filter = kw.pop('filter', Always())
- no_move_handler = kw.pop('no_move_handler', False)
- no_selection_handler = kw.pop('no_selection_handler', False)
- eager = kw.pop('eager', False)
- assert not kw
-
- def decorator(text_object_func):
- assert callable(text_object_func)
-
- @registry.add_binding(*keys, filter=operator_given & filter, eager=eager)
- def _(event):
- # Arguments are multiplied.
- vi_state = event.cli.vi_state
- event._arg = (vi_state.operator_arg or 1) * (event.arg or 1)
-
- # Call the text object handler.
- text_obj = text_object_func(event)
- if text_obj is not None:
- assert isinstance(text_obj, TextObject)
-
- # Call the operator function with the text object.
- vi_state.operator_func(event, text_obj)
-
- # Clear operator.
- event.cli.vi_state.operator_func = None
- event.cli.vi_state.operator_arg = None
-
- # Register a move operation. (Doesn't need an operator.)
- if not no_move_handler:
- @registry.add_binding(*keys, filter=~operator_given & filter & navigation_mode, eager=eager)
- def _(event):
- " Move handler for navigation mode. "
- text_object = text_object_func(event)
- event.current_buffer.cursor_position += text_object.start
-
- # Register a move selection operation.
- if not no_selection_handler:
- @registry.add_binding(*keys, filter=~operator_given & filter & selection_mode, eager=eager)
- def _(event):
- " Move handler for selection mode. "
- text_object = text_object_func(event)
- buff = event.current_buffer
-
- # When the text object has both a start and end position, like 'i(' or 'iw',
- # Turn this into a selection, otherwise the cursor.
- if text_object.end:
- # Take selection positions from text object.
- start, end = text_object.operator_range(buff.document)
- start += buff.cursor_position
- end += buff.cursor_position
-
- buff.selection_state.original_cursor_position = start
- buff.cursor_position = end
-
- # Take selection type from text object.
- if text_object.type == TextObjectType.LINEWISE:
- buff.selection_state.type = SelectionType.LINES
- else:
- buff.selection_state.type = SelectionType.CHARACTERS
- else:
- event.current_buffer.cursor_position += text_object.start
-
- # Make it possible to chain @text_object decorators.
- return text_object_func
-
- return decorator
- return text_object_decorator
-
-
-def create_operator_decorator(registry):
- """
- Create a decorator that can be used for registering Vi operators.
- """
- assert isinstance(registry, BaseRegistry)
-
- operator_given = ViWaitingForTextObjectMode()
- navigation_mode = ViNavigationMode()
- selection_mode = ViSelectionMode()
-
- def operator_decorator(*keys, **kw):
- """
- Register a Vi operator.
-
- Usage::
-
- @operator('d', filter=...)
- def handler(cli, text_object):
- # Do something with the text object here.
- """
- filter = kw.pop('filter', Always())
- eager = kw.pop('eager', False)
- assert not kw
-
- def decorator(operator_func):
- @registry.add_binding(*keys, filter=~operator_given & filter & navigation_mode, eager=eager)
- def _(event):
- """
- Handle operator in navigation mode.
- """
- # When this key binding is matched, only set the operator
- # function in the ViState. We should execute it after a text
- # object has been received.
- event.cli.vi_state.operator_func = operator_func
- event.cli.vi_state.operator_arg = event.arg
-
- @registry.add_binding(*keys, filter=~operator_given & filter & selection_mode, eager=eager)
- def _(event):
- """
- Handle operator in selection mode.
- """
- buff = event.current_buffer
- selection_state = buff.selection_state
-
- # Create text object from selection.
- if selection_state.type == SelectionType.LINES:
- text_obj_type = TextObjectType.LINEWISE
- elif selection_state.type == SelectionType.BLOCK:
- text_obj_type = TextObjectType.BLOCK
- else:
- text_obj_type = TextObjectType.INCLUSIVE
-
- text_object = TextObject(
- selection_state.original_cursor_position - buff.cursor_position,
- type=text_obj_type)
-
- # Execute operator.
- operator_func(event, text_object)
-
- # Quit selection mode.
- buff.selection_state = None
-
- return operator_func
- return decorator
- return operator_decorator
-
-
-def load_vi_bindings(get_search_state=None):
+def create_text_object_decorator(registry):
"""
+ Create a decorator that can be used to register Vi text object implementations.
+ """
+ assert isinstance(registry, BaseRegistry)
+
+ operator_given = ViWaitingForTextObjectMode()
+ navigation_mode = ViNavigationMode()
+ selection_mode = ViSelectionMode()
+
+ def text_object_decorator(*keys, **kw):
+ """
+ Register a text object function.
+
+ Usage::
+
+ @text_object('w', filter=..., no_move_handler=False)
+ def handler(event):
+ # Return a text object for this key.
+ return TextObject(...)
+
+ :param no_move_handler: Disable the move handler in navigation mode.
+ (It's still active in selection mode.)
+ """
+ filter = kw.pop('filter', Always())
+ no_move_handler = kw.pop('no_move_handler', False)
+ no_selection_handler = kw.pop('no_selection_handler', False)
+ eager = kw.pop('eager', False)
+ assert not kw
+
+ def decorator(text_object_func):
+ assert callable(text_object_func)
+
+ @registry.add_binding(*keys, filter=operator_given & filter, eager=eager)
+ def _(event):
+ # Arguments are multiplied.
+ vi_state = event.cli.vi_state
+ event._arg = (vi_state.operator_arg or 1) * (event.arg or 1)
+
+ # Call the text object handler.
+ text_obj = text_object_func(event)
+ if text_obj is not None:
+ assert isinstance(text_obj, TextObject)
+
+ # Call the operator function with the text object.
+ vi_state.operator_func(event, text_obj)
+
+ # Clear operator.
+ event.cli.vi_state.operator_func = None
+ event.cli.vi_state.operator_arg = None
+
+ # Register a move operation. (Doesn't need an operator.)
+ if not no_move_handler:
+ @registry.add_binding(*keys, filter=~operator_given & filter & navigation_mode, eager=eager)
+ def _(event):
+ " Move handler for navigation mode. "
+ text_object = text_object_func(event)
+ event.current_buffer.cursor_position += text_object.start
+
+ # Register a move selection operation.
+ if not no_selection_handler:
+ @registry.add_binding(*keys, filter=~operator_given & filter & selection_mode, eager=eager)
+ def _(event):
+ " Move handler for selection mode. "
+ text_object = text_object_func(event)
+ buff = event.current_buffer
+
+ # When the text object has both a start and end position, like 'i(' or 'iw',
+ # Turn this into a selection, otherwise the cursor.
+ if text_object.end:
+ # Take selection positions from text object.
+ start, end = text_object.operator_range(buff.document)
+ start += buff.cursor_position
+ end += buff.cursor_position
+
+ buff.selection_state.original_cursor_position = start
+ buff.cursor_position = end
+
+ # Take selection type from text object.
+ if text_object.type == TextObjectType.LINEWISE:
+ buff.selection_state.type = SelectionType.LINES
+ else:
+ buff.selection_state.type = SelectionType.CHARACTERS
+ else:
+ event.current_buffer.cursor_position += text_object.start
+
+ # Make it possible to chain @text_object decorators.
+ return text_object_func
+
+ return decorator
+ return text_object_decorator
+
+
+def create_operator_decorator(registry):
+ """
+ Create a decorator that can be used for registering Vi operators.
+ """
+ assert isinstance(registry, BaseRegistry)
+
+ operator_given = ViWaitingForTextObjectMode()
+ navigation_mode = ViNavigationMode()
+ selection_mode = ViSelectionMode()
+
+ def operator_decorator(*keys, **kw):
+ """
+ Register a Vi operator.
+
+ Usage::
+
+ @operator('d', filter=...)
+ def handler(cli, text_object):
+ # Do something with the text object here.
+ """
+ filter = kw.pop('filter', Always())
+ eager = kw.pop('eager', False)
+ assert not kw
+
+ def decorator(operator_func):
+ @registry.add_binding(*keys, filter=~operator_given & filter & navigation_mode, eager=eager)
+ def _(event):
+ """
+ Handle operator in navigation mode.
+ """
+ # When this key binding is matched, only set the operator
+ # function in the ViState. We should execute it after a text
+ # object has been received.
+ event.cli.vi_state.operator_func = operator_func
+ event.cli.vi_state.operator_arg = event.arg
+
+ @registry.add_binding(*keys, filter=~operator_given & filter & selection_mode, eager=eager)
+ def _(event):
+ """
+ Handle operator in selection mode.
+ """
+ buff = event.current_buffer
+ selection_state = buff.selection_state
+
+ # Create text object from selection.
+ if selection_state.type == SelectionType.LINES:
+ text_obj_type = TextObjectType.LINEWISE
+ elif selection_state.type == SelectionType.BLOCK:
+ text_obj_type = TextObjectType.BLOCK
+ else:
+ text_obj_type = TextObjectType.INCLUSIVE
+
+ text_object = TextObject(
+ selection_state.original_cursor_position - buff.cursor_position,
+ type=text_obj_type)
+
+ # Execute operator.
+ operator_func(event, text_object)
+
+ # Quit selection mode.
+ buff.selection_state = None
+
+ return operator_func
+ return decorator
+ return operator_decorator
+
+
+def load_vi_bindings(get_search_state=None):
+ """
Vi extensions.
# Overview of Readline Vi commands:
@@ -316,8 +316,8 @@ def load_vi_bindings(get_search_state=None):
# handled correctly. There is no need to add "~IsReadOnly" to all key
# bindings that do text manipulation.
- registry = ConditionalRegistry(Registry(), ViMode())
- handle = registry.add_binding
+ registry = ConditionalRegistry(Registry(), ViMode())
+ handle = registry.add_binding
# Default get_search_state.
if get_search_state is None:
@@ -348,9 +348,9 @@ def load_vi_bindings(get_search_state=None):
(('~', ), Condition(lambda cli: cli.vi_state.tilde_operator), lambda string: string.swapcase()),
]
- # Insert a character literally (quoted insert).
- handle(Keys.ControlV, filter=insert_mode)(get_by_name('quoted-insert'))
-
+ # Insert a character literally (quoted insert).
+ handle(Keys.ControlV, filter=insert_mode)(get_by_name('quoted-insert'))
+
@handle(Keys.Escape)
def _(event):
"""
@@ -635,8 +635,8 @@ def load_vi_bindings(get_search_state=None):
"""
event.current_buffer.paste_clipboard_data(
event.cli.clipboard.get_data(),
- count=event.arg,
- paste_mode=PasteMode.VI_AFTER)
+ count=event.arg,
+ paste_mode=PasteMode.VI_AFTER)
@handle('P', filter=navigation_mode)
def _(event):
@@ -645,8 +645,8 @@ def load_vi_bindings(get_search_state=None):
"""
event.current_buffer.paste_clipboard_data(
event.cli.clipboard.get_data(),
- count=event.arg,
- paste_mode=PasteMode.VI_BEFORE)
+ count=event.arg,
+ paste_mode=PasteMode.VI_BEFORE)
@handle('"', Keys.Any, 'p', filter=navigation_mode)
def _(event):
@@ -655,8 +655,8 @@ def load_vi_bindings(get_search_state=None):
if c in vi_register_names:
data = event.cli.vi_state.named_registers.get(c)
if data:
- event.current_buffer.paste_clipboard_data(
- data, count=event.arg, paste_mode=PasteMode.VI_AFTER)
+ event.current_buffer.paste_clipboard_data(
+ data, count=event.arg, paste_mode=PasteMode.VI_AFTER)
@handle('"', Keys.Any, 'P', filter=navigation_mode)
def _(event):
@@ -666,7 +666,7 @@ def load_vi_bindings(get_search_state=None):
data = event.cli.vi_state.named_registers.get(c)
if data:
event.current_buffer.paste_clipboard_data(
- data, count=event.arg, paste_mode=PasteMode.VI_BEFORE)
+ data, count=event.arg, paste_mode=PasteMode.VI_BEFORE)
@handle('r', Keys.Any, filter=navigation_mode)
def _(event):
@@ -723,7 +723,7 @@ def load_vi_bindings(get_search_state=None):
else:
event.current_buffer.exit_selection()
- @handle('v', filter=navigation_mode)
+ @handle('v', filter=navigation_mode)
def _(event):
" Enter character selection mode. "
event.current_buffer.start_selection(selection_type=SelectionType.CHARACTERS)
@@ -910,8 +910,8 @@ def load_vi_bindings(get_search_state=None):
# XXX: should become text_object.
pass
- operator = create_operator_decorator(registry)
- text_object = create_text_object_decorator(registry)
+ operator = create_operator_decorator(registry)
+ text_object = create_text_object_decorator(registry)
@text_object(Keys.Any, filter=operator_given)
def _(event):
@@ -1705,25 +1705,25 @@ def load_vi_bindings(get_search_state=None):
event.cli.vi_state.waiting_for_digraph = False
event.cli.vi_state.digraph_symbol1 = None
- return registry
-
+ return registry
-def load_vi_open_in_editor_bindings():
+
+def load_vi_open_in_editor_bindings():
"""
Pressing 'v' in navigation mode will open the buffer in an external editor.
"""
- registry = Registry()
+ registry = Registry()
navigation_mode = ViNavigationMode()
- registry.add_binding('v', filter=navigation_mode)(
- get_by_name('edit-and-execute-command'))
- return registry
+ registry.add_binding('v', filter=navigation_mode)(
+ get_by_name('edit-and-execute-command'))
+ return registry
-def load_vi_system_bindings():
- registry = ConditionalRegistry(Registry(), ViMode())
- handle = registry.add_binding
-
+def load_vi_system_bindings():
+ registry = ConditionalRegistry(Registry(), ViMode())
+ handle = registry.add_binding
+
has_focus = filters.HasFocus(SYSTEM_BUFFER)
navigation_mode = ViNavigationMode()
@@ -1759,28 +1759,28 @@ def load_vi_system_bindings():
# Focus previous buffer again.
event.cli.pop_focus()
- return registry
-
+ return registry
-def load_vi_search_bindings(get_search_state=None,
- search_buffer_name=SEARCH_BUFFER):
+
+def load_vi_search_bindings(get_search_state=None,
+ search_buffer_name=SEARCH_BUFFER):
assert get_search_state is None or callable(get_search_state)
if not get_search_state:
def get_search_state(cli): return cli.search_state
- registry = ConditionalRegistry(Registry(), ViMode())
- handle = registry.add_binding
-
+ registry = ConditionalRegistry(Registry(), ViMode())
+ handle = registry.add_binding
+
has_focus = filters.HasFocus(search_buffer_name)
navigation_mode = ViNavigationMode()
selection_mode = ViSelectionMode()
- reverse_vi_search_direction = Condition(
- lambda cli: cli.application.reverse_vi_search_direction(cli))
-
- @handle('/', filter=(navigation_mode|selection_mode)&~reverse_vi_search_direction)
- @handle('?', filter=(navigation_mode|selection_mode)&reverse_vi_search_direction)
+ reverse_vi_search_direction = Condition(
+ lambda cli: cli.application.reverse_vi_search_direction(cli))
+
+ @handle('/', filter=(navigation_mode|selection_mode)&~reverse_vi_search_direction)
+ @handle('?', filter=(navigation_mode|selection_mode)&reverse_vi_search_direction)
@handle(Keys.ControlS, filter=~has_focus)
def _(event):
"""
@@ -1793,8 +1793,8 @@ def load_vi_search_bindings(get_search_state=None,
# Focus search buffer.
event.cli.push_focus(search_buffer_name)
- @handle('?', filter=(navigation_mode|selection_mode)&~reverse_vi_search_direction)
- @handle('/', filter=(navigation_mode|selection_mode)&reverse_vi_search_direction)
+ @handle('?', filter=(navigation_mode|selection_mode)&~reverse_vi_search_direction)
+ @handle('/', filter=(navigation_mode|selection_mode)&reverse_vi_search_direction)
@handle(Keys.ControlR, filter=~has_focus)
def _(event):
"""
@@ -1808,7 +1808,7 @@ def load_vi_search_bindings(get_search_state=None,
event.cli.vi_state.input_mode = InputMode.INSERT
@handle(Keys.ControlJ, filter=has_focus)
- @handle(Keys.Escape, filter=has_focus)
+ @handle(Keys.Escape, filter=has_focus)
def _(event):
"""
Apply the search. (At the / or ? prompt.)
@@ -1870,16 +1870,16 @@ def load_vi_search_bindings(get_search_state=None,
event.cli.pop_focus()
event.cli.buffers[search_buffer_name].reset()
- return registry
-
+ return registry
-def load_extra_vi_page_navigation_bindings():
+
+def load_extra_vi_page_navigation_bindings():
"""
Key bindings, for scrolling up and down through pages.
This are separate bindings, because GNU readline doesn't have them.
"""
- registry = ConditionalRegistry(Registry(), ViMode())
- handle = registry.add_binding
+ registry = ConditionalRegistry(Registry(), ViMode())
+ handle = registry.add_binding
handle(Keys.ControlF)(scroll_forward)
handle(Keys.ControlB)(scroll_backward)
@@ -1890,9 +1890,9 @@ def load_extra_vi_page_navigation_bindings():
handle(Keys.PageDown)(scroll_page_down)
handle(Keys.PageUp)(scroll_page_up)
- return registry
-
+ return registry
+
class ViStateFilter(Filter):
" Deprecated! "
def __init__(self, get_vi_state, mode):
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/defaults.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/defaults.py
index fb2c1070f7..a7396b82cc 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/defaults.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/defaults.py
@@ -1,119 +1,119 @@
-"""
-Default key bindings.::
-
- registry = load_key_bindings()
- app = Application(key_bindings_registry=registry)
-"""
-from __future__ import unicode_literals
-from prompt_toolkit.key_binding.registry import ConditionalRegistry, MergedRegistry
-from prompt_toolkit.key_binding.bindings.basic import load_basic_bindings, load_abort_and_exit_bindings, load_basic_system_bindings, load_auto_suggestion_bindings, load_mouse_bindings
-from prompt_toolkit.key_binding.bindings.emacs import load_emacs_bindings, load_emacs_system_bindings, load_emacs_search_bindings, load_emacs_open_in_editor_bindings, load_extra_emacs_page_navigation_bindings
-from prompt_toolkit.key_binding.bindings.vi import load_vi_bindings, load_vi_system_bindings, load_vi_search_bindings, load_vi_open_in_editor_bindings, load_extra_vi_page_navigation_bindings
-from prompt_toolkit.filters import to_cli_filter
-
-__all__ = (
- 'load_key_bindings',
- 'load_key_bindings_for_prompt',
-)
-
-
-def load_key_bindings(
- get_search_state=None,
- enable_abort_and_exit_bindings=False,
- enable_system_bindings=False,
- enable_search=False,
- enable_open_in_editor=False,
- enable_extra_page_navigation=False,
- enable_auto_suggest_bindings=False):
- """
- Create a Registry object that contains the default key bindings.
-
- :param enable_abort_and_exit_bindings: Filter to enable Ctrl-C and Ctrl-D.
- :param enable_system_bindings: Filter to enable the system bindings (meta-!
- prompt and Control-Z suspension.)
- :param enable_search: Filter to enable the search bindings.
- :param enable_open_in_editor: Filter to enable open-in-editor.
- :param enable_open_in_editor: Filter to enable open-in-editor.
- :param enable_extra_page_navigation: Filter for enabling extra page
- navigation. (Bindings for up/down scrolling through long pages, like in
- Emacs or Vi.)
- :param enable_auto_suggest_bindings: Filter to enable fish-style suggestions.
- """
-
- assert get_search_state is None or callable(get_search_state)
-
- # Accept both Filters and booleans as input.
- enable_abort_and_exit_bindings = to_cli_filter(enable_abort_and_exit_bindings)
- enable_system_bindings = to_cli_filter(enable_system_bindings)
- enable_search = to_cli_filter(enable_search)
- enable_open_in_editor = to_cli_filter(enable_open_in_editor)
- enable_extra_page_navigation = to_cli_filter(enable_extra_page_navigation)
- enable_auto_suggest_bindings = to_cli_filter(enable_auto_suggest_bindings)
-
- registry = MergedRegistry([
- # Load basic bindings.
- load_basic_bindings(),
- load_mouse_bindings(),
-
- ConditionalRegistry(load_abort_and_exit_bindings(),
- enable_abort_and_exit_bindings),
-
- ConditionalRegistry(load_basic_system_bindings(),
- enable_system_bindings),
-
- # Load emacs bindings.
- load_emacs_bindings(),
-
- ConditionalRegistry(load_emacs_open_in_editor_bindings(),
- enable_open_in_editor),
-
- ConditionalRegistry(load_emacs_search_bindings(get_search_state=get_search_state),
- enable_search),
-
- ConditionalRegistry(load_emacs_system_bindings(),
- enable_system_bindings),
-
- ConditionalRegistry(load_extra_emacs_page_navigation_bindings(),
- enable_extra_page_navigation),
-
- # Load Vi bindings.
- load_vi_bindings(get_search_state=get_search_state),
-
- ConditionalRegistry(load_vi_open_in_editor_bindings(),
- enable_open_in_editor),
-
- ConditionalRegistry(load_vi_search_bindings(get_search_state=get_search_state),
- enable_search),
-
- ConditionalRegistry(load_vi_system_bindings(),
- enable_system_bindings),
-
- ConditionalRegistry(load_extra_vi_page_navigation_bindings(),
- enable_extra_page_navigation),
-
- # Suggestion bindings.
- # (This has to come at the end, because the Vi bindings also have an
- # implementation for the "right arrow", but we really want the
- # suggestion binding when a suggestion is available.)
- ConditionalRegistry(load_auto_suggestion_bindings(),
- enable_auto_suggest_bindings),
- ])
-
- return registry
-
-
-def load_key_bindings_for_prompt(**kw):
- """
- Create a ``Registry`` object with the defaults key bindings for an input
- prompt.
-
- This activates the key bindings for abort/exit (Ctrl-C/Ctrl-D),
- incremental search and auto suggestions.
-
- (Not for full screen applications.)
- """
- kw.setdefault('enable_abort_and_exit_bindings', True)
- kw.setdefault('enable_search', True)
- kw.setdefault('enable_auto_suggest_bindings', True)
-
- return load_key_bindings(**kw)
+"""
+Default key bindings.::
+
+ registry = load_key_bindings()
+ app = Application(key_bindings_registry=registry)
+"""
+from __future__ import unicode_literals
+from prompt_toolkit.key_binding.registry import ConditionalRegistry, MergedRegistry
+from prompt_toolkit.key_binding.bindings.basic import load_basic_bindings, load_abort_and_exit_bindings, load_basic_system_bindings, load_auto_suggestion_bindings, load_mouse_bindings
+from prompt_toolkit.key_binding.bindings.emacs import load_emacs_bindings, load_emacs_system_bindings, load_emacs_search_bindings, load_emacs_open_in_editor_bindings, load_extra_emacs_page_navigation_bindings
+from prompt_toolkit.key_binding.bindings.vi import load_vi_bindings, load_vi_system_bindings, load_vi_search_bindings, load_vi_open_in_editor_bindings, load_extra_vi_page_navigation_bindings
+from prompt_toolkit.filters import to_cli_filter
+
+__all__ = (
+ 'load_key_bindings',
+ 'load_key_bindings_for_prompt',
+)
+
+
+def load_key_bindings(
+ get_search_state=None,
+ enable_abort_and_exit_bindings=False,
+ enable_system_bindings=False,
+ enable_search=False,
+ enable_open_in_editor=False,
+ enable_extra_page_navigation=False,
+ enable_auto_suggest_bindings=False):
+ """
+ Create a Registry object that contains the default key bindings.
+
+ :param enable_abort_and_exit_bindings: Filter to enable Ctrl-C and Ctrl-D.
+ :param enable_system_bindings: Filter to enable the system bindings (meta-!
+ prompt and Control-Z suspension.)
+ :param enable_search: Filter to enable the search bindings.
+ :param enable_open_in_editor: Filter to enable open-in-editor.
+ :param enable_open_in_editor: Filter to enable open-in-editor.
+ :param enable_extra_page_navigation: Filter for enabling extra page
+ navigation. (Bindings for up/down scrolling through long pages, like in
+ Emacs or Vi.)
+ :param enable_auto_suggest_bindings: Filter to enable fish-style suggestions.
+ """
+
+ assert get_search_state is None or callable(get_search_state)
+
+ # Accept both Filters and booleans as input.
+ enable_abort_and_exit_bindings = to_cli_filter(enable_abort_and_exit_bindings)
+ enable_system_bindings = to_cli_filter(enable_system_bindings)
+ enable_search = to_cli_filter(enable_search)
+ enable_open_in_editor = to_cli_filter(enable_open_in_editor)
+ enable_extra_page_navigation = to_cli_filter(enable_extra_page_navigation)
+ enable_auto_suggest_bindings = to_cli_filter(enable_auto_suggest_bindings)
+
+ registry = MergedRegistry([
+ # Load basic bindings.
+ load_basic_bindings(),
+ load_mouse_bindings(),
+
+ ConditionalRegistry(load_abort_and_exit_bindings(),
+ enable_abort_and_exit_bindings),
+
+ ConditionalRegistry(load_basic_system_bindings(),
+ enable_system_bindings),
+
+ # Load emacs bindings.
+ load_emacs_bindings(),
+
+ ConditionalRegistry(load_emacs_open_in_editor_bindings(),
+ enable_open_in_editor),
+
+ ConditionalRegistry(load_emacs_search_bindings(get_search_state=get_search_state),
+ enable_search),
+
+ ConditionalRegistry(load_emacs_system_bindings(),
+ enable_system_bindings),
+
+ ConditionalRegistry(load_extra_emacs_page_navigation_bindings(),
+ enable_extra_page_navigation),
+
+ # Load Vi bindings.
+ load_vi_bindings(get_search_state=get_search_state),
+
+ ConditionalRegistry(load_vi_open_in_editor_bindings(),
+ enable_open_in_editor),
+
+ ConditionalRegistry(load_vi_search_bindings(get_search_state=get_search_state),
+ enable_search),
+
+ ConditionalRegistry(load_vi_system_bindings(),
+ enable_system_bindings),
+
+ ConditionalRegistry(load_extra_vi_page_navigation_bindings(),
+ enable_extra_page_navigation),
+
+ # Suggestion bindings.
+ # (This has to come at the end, because the Vi bindings also have an
+ # implementation for the "right arrow", but we really want the
+ # suggestion binding when a suggestion is available.)
+ ConditionalRegistry(load_auto_suggestion_bindings(),
+ enable_auto_suggest_bindings),
+ ])
+
+ return registry
+
+
+def load_key_bindings_for_prompt(**kw):
+ """
+ Create a ``Registry`` object with the defaults key bindings for an input
+ prompt.
+
+ This activates the key bindings for abort/exit (Ctrl-C/Ctrl-D),
+ incremental search and auto suggestions.
+
+ (Not for full screen applications.)
+ """
+ kw.setdefault('enable_abort_and_exit_bindings', True)
+ kw.setdefault('enable_search', True)
+ kw.setdefault('enable_auto_suggest_bindings', True)
+
+ return load_key_bindings(**kw)
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/input_processor.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/input_processor.py
index 51a3110827..7c1da5de90 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/input_processor.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/input_processor.py
@@ -12,7 +12,7 @@ from prompt_toolkit.filters.cli import ViNavigationMode
from prompt_toolkit.keys import Keys, Key
from prompt_toolkit.utils import Event
-from .registry import BaseRegistry
+from .registry import BaseRegistry
from collections import deque
from six.moves import range
@@ -67,11 +67,11 @@ class InputProcessor(object):
# Now the ControlX-ControlC callback will be called if this sequence is
# registered in the registry.
- :param registry: `BaseRegistry` instance.
+ :param registry: `BaseRegistry` instance.
:param cli_ref: weakref to `CommandLineInterface`.
"""
def __init__(self, registry, cli_ref):
- assert isinstance(registry, BaseRegistry)
+ assert isinstance(registry, BaseRegistry)
self._registry = registry
self._cli_ref = cli_ref
@@ -86,14 +86,14 @@ class InputProcessor(object):
# (This is at at most the amount of keys that make up for one key binding.)
self.key_buffer = []
- # Simple macro recording. (Like readline does.)
- self.record_macro = False
- self.macro = []
-
+ # Simple macro recording. (Like readline does.)
+ self.record_macro = False
+ self.macro = []
+
self.reset()
def reset(self):
- self._previous_key_sequence = []
+ self._previous_key_sequence = []
self._previous_handler = None
self._process_coroutine = self._process()
@@ -103,19 +103,19 @@ class InputProcessor(object):
#: https://www.gnu.org/software/bash/manual/html_node/Readline-Arguments.html
self.arg = None
- def start_macro(self):
- " Start recording macro. "
- self.record_macro = True
- self.macro = []
-
- def end_macro(self):
- " End recording macro. "
- self.record_macro = False
-
- def call_macro(self):
- for k in self.macro:
- self.feed(k)
-
+ def start_macro(self):
+ " Start recording macro. "
+ self.record_macro = True
+ self.macro = []
+
+ def end_macro(self):
+ " End recording macro. "
+ self.record_macro = False
+
+ def call_macro(self):
+ for k in self.macro:
+ self.feed(k)
+
def _get_matches(self, key_presses):
"""
For a list of :class:`KeyPress` instances. Give the matching handlers
@@ -163,17 +163,17 @@ class InputProcessor(object):
is_prefix_of_longer_match = self._is_prefix_of_longer_match(buffer)
matches = self._get_matches(buffer)
- # When eager matches were found, give priority to them and also
- # ignore all the longer matches.
- eager_matches = [m for m in matches if m.eager(self._cli_ref())]
-
- if eager_matches:
- matches = eager_matches
+ # When eager matches were found, give priority to them and also
+ # ignore all the longer matches.
+ eager_matches = [m for m in matches if m.eager(self._cli_ref())]
+
+ if eager_matches:
+ matches = eager_matches
is_prefix_of_longer_match = False
# Exact matches found, call handler.
if not is_prefix_of_longer_match and matches:
- self._call_handler(matches[-1], key_sequence=buffer[:])
+ self._call_handler(matches[-1], key_sequence=buffer[:])
del buffer[:] # Keep reference.
# No match found.
@@ -227,7 +227,7 @@ class InputProcessor(object):
cli.invalidate()
def _call_handler(self, handler, key_sequence=None):
- was_recording = self.record_macro
+ was_recording = self.record_macro
arg = self.arg
self.arg = None
@@ -255,11 +255,11 @@ class InputProcessor(object):
self._previous_key_sequence = key_sequence
self._previous_handler = handler
- # Record the key sequence in our macro. (Only if we're in macro mode
- # before and after executing the key.)
- if self.record_macro and was_recording:
- self.macro.extend(key_sequence)
-
+ # Record the key sequence in our macro. (Only if we're in macro mode
+ # before and after executing the key.)
+ if self.record_macro and was_recording:
+ self.macro.extend(key_sequence)
+
def _fix_vi_cursor_position(self, event):
"""
After every command, make sure that if we are in Vi navigation mode, we
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/manager.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/manager.py
index 83612c2a5c..7bad16a6c5 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/manager.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/manager.py
@@ -1,7 +1,7 @@
"""
-DEPRECATED:
-Use `prompt_toolkit.key_binding.defaults.load_key_bindings` instead.
-
+DEPRECATED:
+Use `prompt_toolkit.key_binding.defaults.load_key_bindings` instead.
+
:class:`KeyBindingManager` is a utility (or shortcut) for loading all the key
bindings in a key binding registry, with a logic set of filters to quickly to
quickly change from Vi to Emacs key bindings at runtime.
@@ -11,12 +11,12 @@ You don't have to use this, but it's practical.
Usage::
manager = KeyBindingManager()
- app = Application(key_bindings_registry=manager.registry)
+ app = Application(key_bindings_registry=manager.registry)
"""
from __future__ import unicode_literals
-from .defaults import load_key_bindings
+from .defaults import load_key_bindings
from prompt_toolkit.filters import to_cli_filter
-from prompt_toolkit.key_binding.registry import Registry, ConditionalRegistry, MergedRegistry
+from prompt_toolkit.key_binding.registry import Registry, ConditionalRegistry, MergedRegistry
__all__ = (
'KeyBindingManager',
@@ -40,37 +40,37 @@ class KeyBindingManager(object):
:param enable_vi_mode: Deprecated!
"""
- def __init__(self,
- registry=None, # XXX: not used anymore.
+ def __init__(self,
+ registry=None, # XXX: not used anymore.
enable_vi_mode=None, # (`enable_vi_mode` is deprecated.)
- enable_all=True, #
+ enable_all=True, #
get_search_state=None,
enable_abort_and_exit_bindings=False,
- enable_system_bindings=False,
- enable_search=False,
- enable_open_in_editor=False,
- enable_extra_page_navigation=False,
- enable_auto_suggest_bindings=False):
+ enable_system_bindings=False,
+ enable_search=False,
+ enable_open_in_editor=False,
+ enable_extra_page_navigation=False,
+ enable_auto_suggest_bindings=False):
assert registry is None or isinstance(registry, Registry)
assert get_search_state is None or callable(get_search_state)
enable_all = to_cli_filter(enable_all)
- defaults = load_key_bindings(
- get_search_state=get_search_state,
- enable_abort_and_exit_bindings=enable_abort_and_exit_bindings,
- enable_system_bindings=enable_system_bindings,
- enable_search=enable_search,
- enable_open_in_editor=enable_open_in_editor,
- enable_extra_page_navigation=enable_extra_page_navigation,
- enable_auto_suggest_bindings=enable_auto_suggest_bindings)
-
- # Note, we wrap this whole thing again in a MergedRegistry, because we
- # don't want the `enable_all` settings to apply on items that were
- # added to the registry as a whole.
- self.registry = MergedRegistry([
- ConditionalRegistry(defaults, enable_all)
- ])
+ defaults = load_key_bindings(
+ get_search_state=get_search_state,
+ enable_abort_and_exit_bindings=enable_abort_and_exit_bindings,
+ enable_system_bindings=enable_system_bindings,
+ enable_search=enable_search,
+ enable_open_in_editor=enable_open_in_editor,
+ enable_extra_page_navigation=enable_extra_page_navigation,
+ enable_auto_suggest_bindings=enable_auto_suggest_bindings)
+
+ # Note, we wrap this whole thing again in a MergedRegistry, because we
+ # don't want the `enable_all` settings to apply on items that were
+ # added to the registry as a whole.
+ self.registry = MergedRegistry([
+ ConditionalRegistry(defaults, enable_all)
+ ])
@classmethod
def for_prompt(cls, **kw):
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/registry.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/registry.py
index 24d0e729a1..5d6bc3493c 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/registry.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/key_binding/registry.py
@@ -1,42 +1,42 @@
-"""
-Key bindings registry.
-
-A `Registry` 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::
-
- r = Registry()
-
- @r.add_binding(Keys.ControlX, Keys.ControlC, filter=INSERT)
- def handler(event):
- # Handle ControlX-ControlC key sequence.
- pass
-
-
-It is also possible to combine multiple registries. We do this in the default
-key bindings. There are some registries that contain Emacs bindings, while
-others contain the Vi bindings. They are merged together using a
-`MergedRegistry`.
-
-We also have a `ConditionalRegistry` object that can enable/disable a group of
-key bindings at once.
-"""
+"""
+Key bindings registry.
+
+A `Registry` 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::
+
+ r = Registry()
+
+ @r.add_binding(Keys.ControlX, Keys.ControlC, filter=INSERT)
+ def handler(event):
+ # Handle ControlX-ControlC key sequence.
+ pass
+
+
+It is also possible to combine multiple registries. We do this in the default
+key bindings. There are some registries that contain Emacs bindings, while
+others contain the Vi bindings. They are merged together using a
+`MergedRegistry`.
+
+We also have a `ConditionalRegistry` object that can enable/disable a group of
+key bindings at once.
+"""
from __future__ import unicode_literals
-from abc import ABCMeta, abstractmethod
-
+from abc import ABCMeta, abstractmethod
+
from prompt_toolkit.cache import SimpleCache
from prompt_toolkit.filters import CLIFilter, to_cli_filter, Never
from prompt_toolkit.keys import Key, Keys
-from six import text_type, with_metaclass
+from six import text_type, with_metaclass
__all__ = (
- 'BaseRegistry',
+ 'BaseRegistry',
'Registry',
- 'ConditionalRegistry',
- 'MergedRegistry',
+ 'ConditionalRegistry',
+ 'MergedRegistry',
)
@@ -65,36 +65,36 @@ class _Binding(object):
self.__class__.__name__, self.keys, self.handler)
-class BaseRegistry(with_metaclass(ABCMeta, object)):
+class BaseRegistry(with_metaclass(ABCMeta, object)):
"""
- Interface for a Registry.
- """
- _version = 0 # For cache invalidation.
-
- @abstractmethod
- def get_bindings_for_keys(self, keys):
- pass
-
- @abstractmethod
- def get_bindings_starting_with_keys(self, keys):
- pass
-
- # `add_binding` and `remove_binding` don't have to be part of this
- # interface.
-
-
-class Registry(BaseRegistry):
- """
- Key binding registry.
+ Interface for a Registry.
+ """
+ _version = 0 # For cache invalidation.
+
+ @abstractmethod
+ def get_bindings_for_keys(self, keys):
+ pass
+
+ @abstractmethod
+ def get_bindings_starting_with_keys(self, keys):
+ pass
+
+ # `add_binding` and `remove_binding` don't have to be part of this
+ # interface.
+
+
+class Registry(BaseRegistry):
"""
+ Key binding registry.
+ """
def __init__(self):
self.key_bindings = []
self._get_bindings_for_keys_cache = SimpleCache(maxsize=10000)
self._get_bindings_starting_with_keys_cache = SimpleCache(maxsize=1000)
- self._version = 0 # For cache invalidation.
+ self._version = 0 # For cache invalidation.
def _clear_cache(self):
- self._version += 1
+ self._version += 1
self._get_bindings_for_keys_cache.clear()
self._get_bindings_starting_with_keys_cache.clear()
@@ -215,136 +215,136 @@ class Registry(BaseRegistry):
return result
return self._get_bindings_starting_with_keys_cache.get(keys, get)
-
-
-class _AddRemoveMixin(BaseRegistry):
- """
- Common part for ConditionalRegistry and MergedRegistry.
- """
- def __init__(self):
- # `Registry` to be synchronized with all the others.
- self._registry2 = Registry()
- self._last_version = None
-
- # The 'extra' registry. Mostly for backwards compatibility.
- self._extra_registry = Registry()
-
- def _update_cache(self):
- raise NotImplementedError
-
- # For backwards, compatibility, we allow adding bindings to both
- # ConditionalRegistry and MergedRegistry. This is however not the
- # recommended way. Better is to create a new registry and merge them
- # together using MergedRegistry.
-
- def add_binding(self, *k, **kw):
- return self._extra_registry.add_binding(*k, **kw)
-
- def remove_binding(self, *k, **kw):
- return self._extra_registry.remove_binding(*k, **kw)
-
- # Proxy methods to self._registry2.
-
- @property
- def key_bindings(self):
- self._update_cache()
- return self._registry2.key_bindings
-
- @property
- def _version(self):
- self._update_cache()
- return self._last_version
-
- def get_bindings_for_keys(self, *a, **kw):
- self._update_cache()
- return self._registry2.get_bindings_for_keys(*a, **kw)
-
- def get_bindings_starting_with_keys(self, *a, **kw):
- self._update_cache()
- return self._registry2.get_bindings_starting_with_keys(*a, **kw)
-
-
-class ConditionalRegistry(_AddRemoveMixin):
- """
- Wraps around a `Registry`. Disable/enable all the key bindings according to
- the given (additional) filter.::
-
- @Condition
- def setting_is_true(cli):
- return True # or False
-
- registy = ConditionalRegistry(registry, setting_is_true)
-
- When new key bindings are added to this object. They are also
- enable/disabled according to the given `filter`.
-
- :param registries: List of `Registry` objects.
- :param filter: `CLIFilter` object.
- """
- def __init__(self, registry=None, filter=True):
- registry = registry or Registry()
- assert isinstance(registry, BaseRegistry)
-
- _AddRemoveMixin.__init__(self)
-
- self.registry = registry
- self.filter = to_cli_filter(filter)
-
- def _update_cache(self):
- " If the original registry was changed. Update our copy version. "
- expected_version = (self.registry._version, self._extra_registry._version)
-
- if self._last_version != expected_version:
- registry2 = Registry()
-
- # Copy all bindings from `self.registry`, adding our condition.
- for reg in (self.registry, self._extra_registry):
- for b in reg.key_bindings:
- registry2.key_bindings.append(
- _Binding(
- keys=b.keys,
- handler=b.handler,
- filter=self.filter & b.filter,
- eager=b.eager,
- save_before=b.save_before))
-
- self._registry2 = registry2
- self._last_version = expected_version
-
-
-class MergedRegistry(_AddRemoveMixin):
- """
- Merge multiple registries of key bindings into one.
-
- This class acts as a proxy to multiple `Registry` objects, but behaves as
- if this is just one bigger `Registry`.
-
- :param registries: List of `Registry` objects.
- """
- def __init__(self, registries):
- assert all(isinstance(r, BaseRegistry) for r in registries)
-
- _AddRemoveMixin.__init__(self)
-
- self.registries = registries
-
- def _update_cache(self):
- """
- If one of the original registries was changed. Update our merged
- version.
- """
- expected_version = (
- tuple(r._version for r in self.registries) +
- (self._extra_registry._version, ))
-
- if self._last_version != expected_version:
- registry2 = Registry()
-
- for reg in self.registries:
- registry2.key_bindings.extend(reg.key_bindings)
-
- # Copy all bindings from `self._extra_registry`.
- registry2.key_bindings.extend(self._extra_registry.key_bindings)
-
- self._registry2 = registry2
- self._last_version = expected_version
+
+
+class _AddRemoveMixin(BaseRegistry):
+ """
+ Common part for ConditionalRegistry and MergedRegistry.
+ """
+ def __init__(self):
+ # `Registry` to be synchronized with all the others.
+ self._registry2 = Registry()
+ self._last_version = None
+
+ # The 'extra' registry. Mostly for backwards compatibility.
+ self._extra_registry = Registry()
+
+ def _update_cache(self):
+ raise NotImplementedError
+
+ # For backwards, compatibility, we allow adding bindings to both
+ # ConditionalRegistry and MergedRegistry. This is however not the
+ # recommended way. Better is to create a new registry and merge them
+ # together using MergedRegistry.
+
+ def add_binding(self, *k, **kw):
+ return self._extra_registry.add_binding(*k, **kw)
+
+ def remove_binding(self, *k, **kw):
+ return self._extra_registry.remove_binding(*k, **kw)
+
+ # Proxy methods to self._registry2.
+
+ @property
+ def key_bindings(self):
+ self._update_cache()
+ return self._registry2.key_bindings
+
+ @property
+ def _version(self):
+ self._update_cache()
+ return self._last_version
+
+ def get_bindings_for_keys(self, *a, **kw):
+ self._update_cache()
+ return self._registry2.get_bindings_for_keys(*a, **kw)
+
+ def get_bindings_starting_with_keys(self, *a, **kw):
+ self._update_cache()
+ return self._registry2.get_bindings_starting_with_keys(*a, **kw)
+
+
+class ConditionalRegistry(_AddRemoveMixin):
+ """
+ Wraps around a `Registry`. Disable/enable all the key bindings according to
+ the given (additional) filter.::
+
+ @Condition
+ def setting_is_true(cli):
+ return True # or False
+
+ registy = ConditionalRegistry(registry, setting_is_true)
+
+ When new key bindings are added to this object. They are also
+ enable/disabled according to the given `filter`.
+
+ :param registries: List of `Registry` objects.
+ :param filter: `CLIFilter` object.
+ """
+ def __init__(self, registry=None, filter=True):
+ registry = registry or Registry()
+ assert isinstance(registry, BaseRegistry)
+
+ _AddRemoveMixin.__init__(self)
+
+ self.registry = registry
+ self.filter = to_cli_filter(filter)
+
+ def _update_cache(self):
+ " If the original registry was changed. Update our copy version. "
+ expected_version = (self.registry._version, self._extra_registry._version)
+
+ if self._last_version != expected_version:
+ registry2 = Registry()
+
+ # Copy all bindings from `self.registry`, adding our condition.
+ for reg in (self.registry, self._extra_registry):
+ for b in reg.key_bindings:
+ registry2.key_bindings.append(
+ _Binding(
+ keys=b.keys,
+ handler=b.handler,
+ filter=self.filter & b.filter,
+ eager=b.eager,
+ save_before=b.save_before))
+
+ self._registry2 = registry2
+ self._last_version = expected_version
+
+
+class MergedRegistry(_AddRemoveMixin):
+ """
+ Merge multiple registries of key bindings into one.
+
+ This class acts as a proxy to multiple `Registry` objects, but behaves as
+ if this is just one bigger `Registry`.
+
+ :param registries: List of `Registry` objects.
+ """
+ def __init__(self, registries):
+ assert all(isinstance(r, BaseRegistry) for r in registries)
+
+ _AddRemoveMixin.__init__(self)
+
+ self.registries = registries
+
+ def _update_cache(self):
+ """
+ If one of the original registries was changed. Update our merged
+ version.
+ """
+ expected_version = (
+ tuple(r._version for r in self.registries) +
+ (self._extra_registry._version, ))
+
+ if self._last_version != expected_version:
+ registry2 = Registry()
+
+ for reg in self.registries:
+ registry2.key_bindings.extend(reg.key_bindings)
+
+ # Copy all bindings from `self._extra_registry`.
+ registry2.key_bindings.extend(self._extra_registry.key_bindings)
+
+ self._registry2 = registry2
+ self._last_version = expected_version
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/layout/containers.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/layout/containers.py
index 0bdafe18e0..f91a15a1e1 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/layout/containers.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/layout/containers.py
@@ -1046,8 +1046,8 @@ class Window(Container):
def _get_digraph_char(self, cli):
" Return `False`, or the Digraph symbol to be used. "
- if cli.quoted_insert:
- return '^'
+ if cli.quoted_insert:
+ return '^'
if cli.vi_state.waiting_for_digraph:
if cli.vi_state.digraph_symbol1:
return cli.vi_state.digraph_symbol1
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/layout/lexers.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/layout/lexers.py
index a928fd8226..7c3cc3c8f7 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/layout/lexers.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/layout/lexers.py
@@ -150,17 +150,17 @@ class PygmentsLexer(Lexer):
"""
Lexer that calls a pygments lexer.
- Example::
-
- from pygments.lexers import HtmlLexer
- lexer = PygmentsLexer(HtmlLexer)
-
- Note: Don't forget to also load a Pygments compatible style. E.g.::
-
- from prompt_toolkit.styles.from_pygments import style_from_pygments
- from pygments.styles import get_style_by_name
- style = style_from_pygments(get_style_by_name('monokai'))
-
+ Example::
+
+ from pygments.lexers import HtmlLexer
+ lexer = PygmentsLexer(HtmlLexer)
+
+ Note: Don't forget to also load a Pygments compatible style. E.g.::
+
+ from prompt_toolkit.styles.from_pygments import style_from_pygments
+ from pygments.styles import get_style_by_name
+ style = style_from_pygments(get_style_by_name('monokai'))
+
:param pygments_lexer_cls: A `Lexer` from Pygments.
:param sync_from_start: Start lexing at the start of the document. This
will always give the best results, but it will be slow for bigger
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/layout/margins.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/layout/margins.py
index 2934dfc9a7..412c602207 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/layout/margins.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/layout/margins.py
@@ -231,10 +231,10 @@ class PromptMargin(Margin):
# Next lines. (Show line numbering when numbering is enabled.)
if self.get_continuation_tokens:
- # Note: we turn this into a list, to make sure that we fail early
- # in case `get_continuation_tokens` returns something else,
- # like `None`.
- tokens2 = list(self.get_continuation_tokens(cli, width))
+ # Note: we turn this into a list, to make sure that we fail early
+ # in case `get_continuation_tokens` returns something else,
+ # like `None`.
+ tokens2 = list(self.get_continuation_tokens(cli, width))
else:
tokens2 = []
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/renderer.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/renderer.py
index 7a8fde55b3..5104b22f2b 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/renderer.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/renderer.py
@@ -21,8 +21,8 @@ __all__ = (
def _output_screen_diff(output, screen, current_pos, previous_screen=None, last_token=None,
- is_done=False, use_alternate_screen=False, attrs_for_token=None, size=None,
- previous_width=0): # XXX: drop is_done
+ is_done=False, use_alternate_screen=False, attrs_for_token=None, size=None,
+ previous_width=0): # XXX: drop is_done
"""
Render the diff between this screen and the previous screen.
@@ -109,17 +109,17 @@ def _output_screen_diff(output, screen, current_pos, previous_screen=None, last_
write(char.char)
last_token[0] = char.token
- # Render for the first time: reset styling.
+ # Render for the first time: reset styling.
if not previous_screen:
reset_attributes()
- # Disable autowrap. (When entering a the alternate screen, or anytime when
- # we have a prompt. - In the case of a REPL, like IPython, people can have
- # background threads, and it's hard for debugging if their output is not
- # wrapped.)
- if not previous_screen or not use_alternate_screen:
- output.disable_autowrap()
-
+ # Disable autowrap. (When entering a the alternate screen, or anytime when
+ # we have a prompt. - In the case of a REPL, like IPython, people can have
+ # background threads, and it's hard for debugging if their output is not
+ # wrapped.)
+ if not previous_screen or not use_alternate_screen:
+ output.disable_autowrap()
+
# When the previous screen has a different size, redraw everything anyway.
# Also when we are done. (We meight take up less rows, so clearing is important.)
if is_done or not previous_screen or previous_width != width: # XXX: also consider height??
@@ -194,7 +194,7 @@ def _output_screen_diff(output, screen, current_pos, previous_screen=None, last_
else:
current_pos = move_cursor(screen.cursor_position)
- if is_done or not use_alternate_screen:
+ if is_done or not use_alternate_screen:
output.enable_autowrap()
# Always reset the color attributes. This is important because a background
@@ -444,7 +444,7 @@ class Renderer(object):
self._cursor_pos, self._last_token = _output_screen_diff(
output, screen, self._cursor_pos,
self._last_screen, self._last_token, is_done,
- use_alternate_screen=self.use_alternate_screen,
+ use_alternate_screen=self.use_alternate_screen,
attrs_for_token=self._attrs_for_token,
size=size,
previous_width=(self._last_size.columns if self._last_size else 0))
@@ -480,7 +480,7 @@ class Renderer(object):
output.cursor_up(self._cursor_pos.y)
output.erase_down()
output.reset_attributes()
- output.enable_autowrap()
+ output.enable_autowrap()
output.flush()
# Erase title.
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/selection.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/selection.py
index 6582921222..10cf160e28 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/selection.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/selection.py
@@ -5,7 +5,7 @@ from __future__ import unicode_literals
__all__ = (
'SelectionType',
- 'PasteMode',
+ 'PasteMode',
'SelectionState',
)
@@ -24,12 +24,12 @@ class SelectionType(object):
BLOCK = 'BLOCK'
-class PasteMode(object):
- EMACS = 'EMACS' # Yank like emacs.
- VI_AFTER = 'VI_AFTER' # When pressing 'p' in Vi.
- VI_BEFORE = 'VI_BEFORE' # When pressing 'P' in Vi.
-
-
+class PasteMode(object):
+ EMACS = 'EMACS' # Yank like emacs.
+ VI_AFTER = 'VI_AFTER' # When pressing 'p' in Vi.
+ VI_BEFORE = 'VI_BEFORE' # When pressing 'P' in Vi.
+
+
class SelectionState(object):
"""
State of the current selection.
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/shortcuts.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/shortcuts.py
index 9893624c6e..566fc23319 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/shortcuts.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/shortcuts.py
@@ -27,7 +27,7 @@ from .enums import DEFAULT_BUFFER, SEARCH_BUFFER, EditingMode
from .filters import IsDone, HasFocus, RendererHeightIsKnown, to_simple_filter, to_cli_filter, Condition
from .history import InMemoryHistory
from .interface import CommandLineInterface, Application, AbortAction
-from .key_binding.defaults import load_key_bindings_for_prompt
+from .key_binding.defaults import load_key_bindings_for_prompt
from .key_binding.registry import Registry
from .keys import Keys
from .layout import Window, HSplit, FloatContainer, Float
@@ -77,10 +77,10 @@ __all__ = (
'prompt',
'prompt_async',
'create_confirm_application',
- 'run_application',
+ 'run_application',
'confirm',
'print_tokens',
- 'clear',
+ 'clear',
)
@@ -449,9 +449,9 @@ def create_prompt_application(
be edited by the user.)
"""
if key_bindings_registry is None:
- key_bindings_registry = load_key_bindings_for_prompt(
+ key_bindings_registry = load_key_bindings_for_prompt(
enable_system_bindings=enable_system_bindings,
- enable_open_in_editor=enable_open_in_editor)
+ enable_open_in_editor=enable_open_in_editor)
# Ensure backwards-compatibility, when `vi_mode` is passed.
if vi_mode:
@@ -506,7 +506,7 @@ def create_prompt_application(
mouse_support=mouse_support,
editing_mode=editing_mode,
erase_when_done=erase_when_done,
- reverse_vi_search_direction=True,
+ reverse_vi_search_direction=True,
on_abort=on_abort,
on_exit=on_exit)
@@ -594,7 +594,7 @@ def run_application(
cli.on_stop += stop_refresh_loop
# Replace stdout.
- patch_context = cli.patch_stdout_context(raw=True) if patch_stdout else DummyContext()
+ patch_context = cli.patch_stdout_context(raw=True) if patch_stdout else DummyContext()
# Read input and return it.
if return_asyncio_coroutine:
@@ -610,7 +610,7 @@ def run_application(
@asyncio.coroutine
def run():
with patch_context:
- result = yield from cli.run_async()
+ result = yield from cli.run_async()
if isinstance(result, Document): # Backwards-compatibility.
return result.text
@@ -622,7 +622,7 @@ def run_application(
else:
try:
with patch_context:
- result = cli.run()
+ result = cli.run()
if isinstance(result, Document): # Backwards-compatibility.
return result.text
@@ -671,7 +671,7 @@ def confirm(message='Confirm (y or n) '):
return run_application(app)
-def print_tokens(tokens, style=None, true_color=False, file=None):
+def print_tokens(tokens, style=None, true_color=False, file=None):
"""
Print a list of (Token, text) tuples in the given style to the output.
E.g.::
@@ -689,13 +689,13 @@ def print_tokens(tokens, style=None, true_color=False, file=None):
:param tokens: List of ``(Token, text)`` tuples.
:param style: :class:`.Style` instance for the color scheme.
:param true_color: When True, use 24bit colors instead of 256 colors.
- :param file: The output file. This can be `sys.stdout` or `sys.stderr`.
+ :param file: The output file. This can be `sys.stdout` or `sys.stderr`.
"""
- if style is None:
- style = DEFAULT_STYLE
+ if style is None:
+ style = DEFAULT_STYLE
assert isinstance(style, Style)
- output = create_output(true_color=true_color, stdout=file)
+ output = create_output(true_color=true_color, stdout=file)
renderer_print_tokens(output, tokens, style)
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/styles/from_dict.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/styles/from_dict.py
index b50325710f..e17cac4564 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/styles/from_dict.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/styles/from_dict.py
@@ -6,10 +6,10 @@ This is very similar to the Pygments style dictionary, with some additions:
- Support for ANSI color names. (These will map directly to the 16 terminal
colors.)
"""
-try:
- from collections.abc import Mapping
-except ImportError:
- from collections import Mapping
+try:
+ from collections.abc import Mapping
+except ImportError:
+ from collections import Mapping
from .base import Style, DEFAULT_ATTRS, ANSI_COLOR_NAMES
from .defaults import DEFAULT_STYLE_EXTENSIONS
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/styles/from_pygments.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/styles/from_pygments.py
index 0af8c53cf2..ad4861346c 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/styles/from_pygments.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/styles/from_pygments.py
@@ -33,12 +33,12 @@ def style_from_pygments(style_cls=pygments_DefaultStyle,
Shortcut to create a :class:`.Style` instance from a Pygments style class
and a style dictionary.
- Example::
-
- from prompt_toolkit.styles.from_pygments import style_from_pygments
- from pygments.styles import get_style_by_name
- style = style_from_pygments(get_style_by_name('monokai'))
-
+ Example::
+
+ from prompt_toolkit.styles.from_pygments import style_from_pygments
+ from pygments.styles import get_style_by_name
+ style = style_from_pygments(get_style_by_name('monokai'))
+
:param style_cls: Pygments style class to start from.
:param style_dict: Dictionary for this style. `{Token: style}`.
:param include_defaults: (`bool`) Include prompt_toolkit extensions.
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/vt100_input.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/vt100_input.py
index 74841312fa..5f7ad8b298 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/vt100_input.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/vt100_input.py
@@ -170,9 +170,9 @@ ANSI_SEQUENCES = {
'\x1b[5C': Keys.ControlRight,
'\x1b[5D': Keys.ControlLeft,
- '\x1bOc': Keys.ControlRight, # rxvt
- '\x1bOd': Keys.ControlLeft, # rxvt
-
+ '\x1bOc': Keys.ControlRight, # rxvt
+ '\x1bOd': Keys.ControlLeft, # rxvt
+
'\x1b[200~': Keys.BracketedPaste, # Start of bracketed paste.
# Meta + arrow keys. Several terminals handle this differently.
@@ -459,14 +459,14 @@ class raw_mode(object):
else:
newattr[tty.LFLAG] = self._patch_lflag(newattr[tty.LFLAG])
newattr[tty.IFLAG] = self._patch_iflag(newattr[tty.IFLAG])
-
- # VMIN defines the number of characters read at a time in
- # non-canonical mode. It seems to default to 1 on Linux, but on
- # Solaris and derived operating systems it defaults to 4. (This is
- # because the VMIN slot is the same as the VEOF slot, which
- # defaults to ASCII EOT = Ctrl-D = 4.)
- newattr[tty.CC][termios.VMIN] = 1
-
+
+ # VMIN defines the number of characters read at a time in
+ # non-canonical mode. It seems to default to 1 on Linux, but on
+ # Solaris and derived operating systems it defaults to 4. (This is
+ # because the VMIN slot is the same as the VEOF slot, which
+ # defaults to ASCII EOT = Ctrl-D = 4.)
+ newattr[tty.CC][termios.VMIN] = 1
+
termios.tcsetattr(self.fileno, termios.TCSANOW, newattr)
# Put the terminal in cursor mode. (Instead of application mode.)
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/vt100_output.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/vt100_output.py
index b800aaacec..04a6a12804 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/vt100_output.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/vt100_output.py
@@ -28,48 +28,48 @@ FG_ANSI_COLORS = {
'ansidefault': 39,
# Low intensity.
- 'ansiblack': 30,
+ 'ansiblack': 30,
'ansidarkred': 31,
'ansidarkgreen': 32,
'ansibrown': 33,
'ansidarkblue': 34,
'ansipurple': 35,
'ansiteal': 36,
- 'ansilightgray': 37,
+ 'ansilightgray': 37,
# High intensity.
- 'ansidarkgray': 90,
+ 'ansidarkgray': 90,
'ansired': 91,
'ansigreen': 92,
'ansiyellow': 93,
'ansiblue': 94,
'ansifuchsia': 95,
'ansiturquoise': 96,
- 'ansiwhite': 97,
+ 'ansiwhite': 97,
}
BG_ANSI_COLORS = {
'ansidefault': 49,
# Low intensity.
- 'ansiblack': 40,
+ 'ansiblack': 40,
'ansidarkred': 41,
'ansidarkgreen': 42,
'ansibrown': 43,
'ansidarkblue': 44,
'ansipurple': 45,
'ansiteal': 46,
- 'ansilightgray': 47,
+ 'ansilightgray': 47,
# High intensity.
- 'ansidarkgray': 100,
+ 'ansidarkgray': 100,
'ansired': 101,
'ansigreen': 102,
'ansiyellow': 103,
'ansiblue': 104,
'ansifuchsia': 105,
'ansiturquoise': 106,
- 'ansiwhite': 107,
+ 'ansiwhite': 107,
}
@@ -424,9 +424,9 @@ class Vt100_Output(Output):
assert stdout.isatty()
def get_size():
rows, columns = _get_size(stdout.fileno())
- # If terminal (incorrectly) reports its size as 0, pick a reasonable default.
- # See https://github.com/ipython/ipython/issues/10071
- return Size(rows=(rows or 24), columns=(columns or 80))
+ # If terminal (incorrectly) reports its size as 0, pick a reasonable default.
+ # See https://github.com/ipython/ipython/issues/10071
+ return Size(rows=(rows or 24), columns=(columns or 80))
return cls(stdout, get_size, true_color=true_color,
ansi_colors_only=ansi_colors_only, term=term)
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/win32_input.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/win32_input.py
index 410e5fa517..2a66351221 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/win32_input.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/win32_input.py
@@ -1,6 +1,6 @@
from __future__ import unicode_literals
from ctypes import windll, pointer
-from ctypes.wintypes import DWORD, HANDLE
+from ctypes.wintypes import DWORD, HANDLE
from six.moves import range
from prompt_toolkit.key_binding.input_processor import KeyPress
@@ -111,10 +111,10 @@ class ConsoleInputReader(object):
# When stdin is a tty, use that handle, otherwise, create a handle from
# CONIN$.
if sys.stdin.isatty():
- self.handle = HANDLE(windll.kernel32.GetStdHandle(STD_INPUT_HANDLE))
+ self.handle = HANDLE(windll.kernel32.GetStdHandle(STD_INPUT_HANDLE))
else:
self._fdcon = os.open('CONIN$', os.O_RDWR | os.O_BINARY)
- self.handle = HANDLE(msvcrt.get_osfhandle(self._fdcon))
+ self.handle = HANDLE(msvcrt.get_osfhandle(self._fdcon))
def close(self):
" Close fdcon. "
@@ -321,7 +321,7 @@ class raw_mode(object):
`raw_input` method of `.vt100_input`.
"""
def __init__(self, fileno=None):
- self.handle = HANDLE(windll.kernel32.GetStdHandle(STD_INPUT_HANDLE))
+ self.handle = HANDLE(windll.kernel32.GetStdHandle(STD_INPUT_HANDLE))
def __enter__(self):
# Remember original mode.
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/win32_output.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/win32_output.py
index d4dddbab42..19788652d2 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/win32_output.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/terminal/win32_output.py
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
from ctypes import windll, byref, ArgumentError, c_char, c_long, c_ulong, c_uint, pointer
-from ctypes.wintypes import DWORD, HANDLE
+from ctypes.wintypes import DWORD, HANDLE
from prompt_toolkit.renderer import Output
from prompt_toolkit.styles import ANSI_COLOR_NAMES
@@ -70,7 +70,7 @@ class Win32Output(Output):
self._buffer = []
self.stdout = stdout
- self.hconsole = HANDLE(windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE))
+ self.hconsole = HANDLE(windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE))
self._in_alternate_screen = False
@@ -141,31 +141,31 @@ class Win32Output(Output):
"""
Return Screen buffer info.
"""
- # NOTE: We don't call the `GetConsoleScreenBufferInfo` API through
- # `self._winapi`. Doing so causes Python to crash on certain 64bit
- # Python versions. (Reproduced with 64bit Python 2.7.6, on Windows
- # 10). It is not clear why. Possibly, it has to do with passing
- # these objects as an argument, or through *args.
-
- # The Python documentation contains the following - possibly related - warning:
- # ctypes does not support passing unions or structures with
- # bit-fields to functions by value. While this may work on 32-bit
- # x86, it's not guaranteed by the library to work in the general
- # case. Unions and structures with bit-fields should always be
- # passed to functions by pointer.
-
- # Also see:
- # - https://github.com/ipython/ipython/issues/10070
- # - https://github.com/jonathanslenders/python-prompt-toolkit/issues/406
- # - https://github.com/jonathanslenders/python-prompt-toolkit/issues/86
-
- self.flush()
+ # NOTE: We don't call the `GetConsoleScreenBufferInfo` API through
+ # `self._winapi`. Doing so causes Python to crash on certain 64bit
+ # Python versions. (Reproduced with 64bit Python 2.7.6, on Windows
+ # 10). It is not clear why. Possibly, it has to do with passing
+ # these objects as an argument, or through *args.
+
+ # The Python documentation contains the following - possibly related - warning:
+ # ctypes does not support passing unions or structures with
+ # bit-fields to functions by value. While this may work on 32-bit
+ # x86, it's not guaranteed by the library to work in the general
+ # case. Unions and structures with bit-fields should always be
+ # passed to functions by pointer.
+
+ # Also see:
+ # - https://github.com/ipython/ipython/issues/10070
+ # - https://github.com/jonathanslenders/python-prompt-toolkit/issues/406
+ # - https://github.com/jonathanslenders/python-prompt-toolkit/issues/86
+
+ self.flush()
sbinfo = CONSOLE_SCREEN_BUFFER_INFO()
- success = windll.kernel32.GetConsoleScreenBufferInfo(self.hconsole, byref(sbinfo))
-
- # success = self._winapi(windll.kernel32.GetConsoleScreenBufferInfo,
- # self.hconsole, byref(sbinfo))
-
+ success = windll.kernel32.GetConsoleScreenBufferInfo(self.hconsole, byref(sbinfo))
+
+ # success = self._winapi(windll.kernel32.GetConsoleScreenBufferInfo,
+ # self.hconsole, byref(sbinfo))
+
if success:
return sbinfo
else:
@@ -346,8 +346,8 @@ class Win32Output(Output):
GENERIC_WRITE = 0x40000000
# Create a new console buffer and activate that one.
- handle = HANDLE(self._winapi(windll.kernel32.CreateConsoleScreenBuffer, GENERIC_READ|GENERIC_WRITE,
- DWORD(0), None, DWORD(1), None))
+ handle = HANDLE(self._winapi(windll.kernel32.CreateConsoleScreenBuffer, GENERIC_READ|GENERIC_WRITE,
+ DWORD(0), None, DWORD(1), None))
self._winapi(windll.kernel32.SetConsoleActiveScreenBuffer, handle)
self.hconsole = handle
@@ -358,7 +358,7 @@ class Win32Output(Output):
Make stdout again the active buffer.
"""
if self._in_alternate_screen:
- stdout = HANDLE(self._winapi(windll.kernel32.GetStdHandle, STD_OUTPUT_HANDLE))
+ stdout = HANDLE(self._winapi(windll.kernel32.GetStdHandle, STD_OUTPUT_HANDLE))
self._winapi(windll.kernel32.SetConsoleActiveScreenBuffer, stdout)
self._winapi(windll.kernel32.CloseHandle, self.hconsole)
self.hconsole = stdout
@@ -366,7 +366,7 @@ class Win32Output(Output):
def enable_mouse_support(self):
ENABLE_MOUSE_INPUT = 0x10
- handle = HANDLE(windll.kernel32.GetStdHandle(STD_INPUT_HANDLE))
+ handle = HANDLE(windll.kernel32.GetStdHandle(STD_INPUT_HANDLE))
original_mode = DWORD()
self._winapi(windll.kernel32.GetConsoleMode, handle, pointer(original_mode))
@@ -374,7 +374,7 @@ class Win32Output(Output):
def disable_mouse_support(self):
ENABLE_MOUSE_INPUT = 0x10
- handle = HANDLE(windll.kernel32.GetStdHandle(STD_INPUT_HANDLE))
+ handle = HANDLE(windll.kernel32.GetStdHandle(STD_INPUT_HANDLE))
original_mode = DWORD()
self._winapi(windll.kernel32.GetConsoleMode, handle, pointer(original_mode))
@@ -396,7 +396,7 @@ class Win32Output(Output):
to a bug in the Windows Console. Sending a repaint request solves it.
"""
# Get console handle
- handle = HANDLE(windll.kernel32.GetConsoleWindow())
+ handle = HANDLE(windll.kernel32.GetConsoleWindow())
RDW_INVALIDATE = 0x0001
windll.user32.RedrawWindow(handle, None, None, c_uint(RDW_INVALIDATE))