diff options
author | Nikita Slyusarev <nslus@yandex-team.com> | 2022-02-10 16:46:52 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:52 +0300 |
commit | cd77cecfc03a3eaf87816af28a33067c4f0cdb59 (patch) | |
tree | 1308e0bae862d52e0020d881fe758080437fe389 /contrib/python/prompt-toolkit/py2/prompt_toolkit/application.py | |
parent | cdae02d225fb5b3afbb28990e79a7ac6c9125327 (diff) | |
download | ydb-cd77cecfc03a3eaf87816af28a33067c4f0cdb59.tar.gz |
Restoring authorship annotation for Nikita Slyusarev <nslus@yandex-team.com>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/prompt-toolkit/py2/prompt_toolkit/application.py')
-rw-r--r-- | contrib/python/prompt-toolkit/py2/prompt_toolkit/application.py | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/application.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/application.py index 272d8bbcbb0..7a7afa3074f 100644 --- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/application.py +++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/application.py @@ -3,18 +3,18 @@ from __future__ import unicode_literals from .buffer import Buffer, AcceptAction from .buffer_mapping import BufferMapping from .clipboard import Clipboard, InMemoryClipboard -from .enums import DEFAULT_BUFFER, EditingMode +from .enums import DEFAULT_BUFFER, EditingMode 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.bindings.vi import load_vi_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 from .styles import DEFAULT_STYLE, Style -import six +import six __all__ = ( 'AbortAction', @@ -57,7 +57,7 @@ class Application(object): :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 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. @@ -68,10 +68,10 @@ class Application(object): boolean). When True, enable mouse support. :param paste_mode: :class:`~prompt_toolkit.filters.CLIFilter` or boolean. :param ignore_case: :class:`~prompt_toolkit.filters.CLIFilter` or boolean. - :param editing_mode: :class:`~prompt_toolkit.enums.EditingMode`. + :param editing_mode: :class:`~prompt_toolkit.enums.EditingMode`. - Callbacks (all of these should accept a - :class:`~prompt_toolkit.interface.CommandLineInterface` object as input.) + Callbacks (all of these should accept a + :class:`~prompt_toolkit.interface.CommandLineInterface` object as input.) :param on_input_timeout: Called when there is no input for x seconds. (Fired when any eventloop.onInputTimeout is fired.) @@ -81,8 +81,8 @@ class Application(object): :param on_buffer_changed: Called when the content of a buffer has been changed. :param on_initialize: Called after the :class:`~prompt_toolkit.interface.CommandLineInterface` initializes. - :param on_render: Called right after rendering. - :param on_invalidate: Called when the UI has been invalidated. + :param on_render: Called right after rendering. + :param on_invalidate: Called when the UI has been invalidated. """ def __init__(self, layout=None, buffer=None, buffers=None, initial_focussed_buffer=DEFAULT_BUFFER, @@ -92,13 +92,13 @@ class Application(object): use_alternate_screen=False, mouse_support=False, get_title=None, - paste_mode=False, ignore_case=False, editing_mode=EditingMode.EMACS, - erase_when_done=False, + paste_mode=False, ignore_case=False, editing_mode=EditingMode.EMACS, + erase_when_done=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, - on_render=None, on_invalidate=None): + on_reset=None, on_initialize=None, on_buffer_changed=None, + on_render=None, on_invalidate=None): paste_mode = to_cli_filter(paste_mode) ignore_case = to_cli_filter(ignore_case) @@ -116,28 +116,28 @@ class Application(object): assert get_title is None or callable(get_title) assert isinstance(paste_mode, CLIFilter) assert isinstance(ignore_case, CLIFilter) - assert isinstance(editing_mode, six.string_types) - assert on_input_timeout is None or callable(on_input_timeout) + assert isinstance(editing_mode, six.string_types) + assert on_input_timeout is None or callable(on_input_timeout) assert style is None or isinstance(style, Style) - assert isinstance(erase_when_done, bool) - - assert on_start is None or callable(on_start) - assert on_stop is None or callable(on_stop) - assert on_reset is None or callable(on_reset) - assert on_buffer_changed is None or callable(on_buffer_changed) - assert on_initialize is None or callable(on_initialize) - assert on_render is None or callable(on_render) - assert on_invalidate is None or callable(on_invalidate) - + assert isinstance(erase_when_done, bool) + + assert on_start is None or callable(on_start) + assert on_stop is None or callable(on_stop) + assert on_reset is None or callable(on_reset) + assert on_buffer_changed is None or callable(on_buffer_changed) + assert on_initialize is None or callable(on_initialize) + assert on_render is None or callable(on_render) + assert on_invalidate is None or callable(on_invalidate) + self.layout = layout or Window(BufferControl()) # Make sure that the 'buffers' dictionary is a BufferMapping. - # NOTE: If no buffer is given, we create a default Buffer, with IGNORE as - # default accept_action. This is what makes sense for most users - # creating full screen applications. Doing nothing is the obvious - # default. Those creating a REPL would use the shortcuts module that - # passes in RETURN_DOCUMENT. - self.buffer = buffer or Buffer(accept_action=AcceptAction.IGNORE) + # NOTE: If no buffer is given, we create a default Buffer, with IGNORE as + # default accept_action. This is what makes sense for most users + # creating full screen applications. Doing nothing is the obvious + # default. Those creating a REPL would use the shortcuts module that + # passes in RETURN_DOCUMENT. + self.buffer = buffer or Buffer(accept_action=AcceptAction.IGNORE) if not buffers or not isinstance(buffers, BufferMapping): self.buffers = BufferMapping(buffers, initial=initial_focussed_buffer) else: @@ -166,21 +166,21 @@ class Application(object): self.paste_mode = paste_mode self.ignore_case = ignore_case - self.editing_mode = editing_mode - self.erase_when_done = erase_when_done + self.editing_mode = editing_mode + self.erase_when_done = erase_when_done self.reverse_vi_search_direction = reverse_vi_search_direction - def dummy_handler(cli): - " Dummy event handler. " - - self.on_input_timeout = on_input_timeout or dummy_handler - self.on_start = on_start or dummy_handler - self.on_stop = on_stop or dummy_handler - self.on_reset = on_reset or dummy_handler - self.on_initialize = on_initialize or dummy_handler - 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 + def dummy_handler(cli): + " Dummy event handler. " + + self.on_input_timeout = on_input_timeout or dummy_handler + self.on_start = on_start or dummy_handler + self.on_stop = on_stop or dummy_handler + self.on_reset = on_reset or dummy_handler + self.on_initialize = on_initialize or dummy_handler + 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 |