diff options
author | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-02-08 15:26:58 +0300 |
---|---|---|
committer | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-02-08 15:26:58 +0300 |
commit | 2efaaefec2cb2a55d55c01753d1eed2a3296adb5 (patch) | |
tree | 27ec5258b325565c3963b91b36d64e84084fdb04 /contrib/python/prompt-toolkit | |
parent | 23793c5d0827a08b5ff9242d2123eff92b681912 (diff) | |
download | ydb-2efaaefec2cb2a55d55c01753d1eed2a3296adb5.tar.gz |
intermediate changes
ref:0bfa27bb6c38df8c510497e54e4ebf0b4fb84503
Diffstat (limited to 'contrib/python/prompt-toolkit')
32 files changed, 544 insertions, 129 deletions
diff --git a/contrib/python/prompt-toolkit/py3/.dist-info/METADATA b/contrib/python/prompt-toolkit/py3/.dist-info/METADATA index ebe6304f08..76d0029401 100644 --- a/contrib/python/prompt-toolkit/py3/.dist-info/METADATA +++ b/contrib/python/prompt-toolkit/py3/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: prompt-toolkit -Version: 3.0.26 +Version: 3.0.27 Summary: Library for building powerful interactive command lines in Python Home-page: https://github.com/prompt-toolkit/python-prompt-toolkit Author: Jonathan Slenders diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py index 4324557a45..554ca2238c 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py @@ -18,7 +18,7 @@ from .formatted_text import ANSI, HTML from .shortcuts import PromptSession, print_formatted_text, prompt # Don't forget to update in `docs/conf.py`! -__version__ = "3.0.26" +__version__ = "3.0.27" # Version tuple. VERSION = tuple(__version__.split(".")) diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/__init__.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/__init__.py index 343261cdc3..dc61ca73c3 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/__init__.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/__init__.py @@ -2,6 +2,7 @@ from .application import Application from .current import ( AppSession, create_app_session, + create_app_session_from_tty, get_app, get_app_or_none, get_app_session, @@ -17,6 +18,7 @@ __all__ = [ "AppSession", "get_app_session", "create_app_session", + "create_app_session_from_tty", "get_app", "get_app_or_none", "set_app", diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py index aec0accae1..5426ebfdfe 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py @@ -41,6 +41,7 @@ from typing import ( from prompt_toolkit.buffer import Buffer from prompt_toolkit.cache import SimpleCache from prompt_toolkit.clipboard import Clipboard, InMemoryClipboard +from prompt_toolkit.cursor_shapes import AnyCursorShapeConfig, to_cursor_shape_config from prompt_toolkit.data_structures import Size from prompt_toolkit.enums import EditingMode from prompt_toolkit.eventloop import ( @@ -216,6 +217,7 @@ class Application(Generic[_AppResult]): max_render_postpone_time: Union[float, int, None] = 0.01, refresh_interval: Optional[float] = None, terminal_size_polling_interval: Optional[float] = 0.5, + cursor: AnyCursorShapeConfig = None, on_reset: Optional["ApplicationEventHandler[_AppResult]"] = None, on_invalidate: Optional["ApplicationEventHandler[_AppResult]"] = None, before_render: Optional["ApplicationEventHandler[_AppResult]"] = None, @@ -266,6 +268,8 @@ class Application(Generic[_AppResult]): self.refresh_interval = refresh_interval self.terminal_size_polling_interval = terminal_size_polling_interval + self.cursor = to_cursor_shape_config(cursor) + # Events. self.on_invalidate = Event(self, on_invalidate) self.on_reset = Event(self, on_reset) diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/current.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/current.py index 051916699e..14eb7922c8 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/current.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/current.py @@ -20,6 +20,7 @@ __all__ = [ "get_app_or_none", "set_app", "create_app_session", + "create_app_session_from_tty", ] @@ -168,3 +169,29 @@ def create_app_session( yield session finally: _current_app_session.reset(token) + + +@contextmanager +def create_app_session_from_tty() -> Generator[AppSession, None, None]: + """ + Create `AppSession` that always prefers the TTY input/output. + + Even if `sys.stdin` and `sys.stdout` are connected to input/output pipes, + this will still use the terminal for interaction (because `sys.stderr` is + still connected to the terminal). + + Usage:: + + from prompt_toolkit.shortcuts import prompt + + with create_app_session_from_tty(): + prompt('>') + """ + from prompt_toolkit.input.defaults import create_input + from prompt_toolkit.output.defaults import create_output + + input = create_input(always_prefer_tty=True) + output = create_output(always_prefer_tty=True) + + with create_app_session(input=input, output=output) as app_session: + yield app_session diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/compiler.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/compiler.py index 9d23490f18..a6eb77127a 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/compiler.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/compiler.py @@ -41,7 +41,7 @@ Partial matches are possible:: import re from typing import Callable, Dict, Iterable, Iterator, List from typing import Match as RegexMatch -from typing import Optional, Pattern, Tuple, cast +from typing import Optional, Pattern, Tuple from .regex_parser import ( AnyNode, diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/server.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/server.py index b69f910bcf..b6e4b14065 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/server.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/server.py @@ -2,9 +2,9 @@ Telnet server. """ import asyncio -import contextvars # Requires Python3.7! import socket -from typing import Awaitable, Callable, List, Optional, Set, TextIO, Tuple, cast +import sys +from typing import Any, Awaitable, Callable, List, Optional, Set, TextIO, Tuple, cast from prompt_toolkit.application.current import create_app_session, get_app from prompt_toolkit.application.run_in_terminal import run_in_terminal @@ -33,6 +33,11 @@ from .protocol import ( TelnetProtocolParser, ) +if sys.version_info >= (3, 7): + import contextvars # Requires Python3.7! +else: + contextvars: Any = None + __all__ = [ "TelnetServer", ] diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/cursor_shapes.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/cursor_shapes.py new file mode 100644 index 0000000000..d38b3505bd --- /dev/null +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/cursor_shapes.py @@ -0,0 +1,102 @@ +from abc import ABC, abstractmethod +from enum import Enum +from typing import TYPE_CHECKING, Any, Callable, Union + +from prompt_toolkit.enums import EditingMode +from prompt_toolkit.key_binding.vi_state import InputMode + +if TYPE_CHECKING: + from .application import Application + +__all__ = [ + "CursorShape", + "CursorShapeConfig", + "SimpleCursorShapeConfig", + "ModalCursorShapeConfig", + "DynamicCursorShapeConfig", + "to_cursor_shape_config", +] + + +class CursorShape(Enum): + # Default value that should tell the output implementation to never send + # cursor shape escape sequences. This is the default right now, because + # before this `CursorShape` functionality was introduced into + # prompt_toolkit itself, people had workarounds to send cursor shapes + # escapes into the terminal, by monkey patching some of prompt_toolkit's + # internals. We don't want the default prompt_toolkit implemetation to + # interefere with that. E.g., IPython patches the `ViState.input_mode` + # property. See: https://github.com/ipython/ipython/pull/13501/files + _NEVER_CHANGE = "_NEVER_CHANGE" + + BLOCK = "BLOCK" + BEAM = "BEAM" + UNDERLINE = "UNDERLINE" + BLINKING_BLOCK = "BLINKING_BLOCK" + BLINKING_BEAM = "BLINKING_BEAM" + BLINKING_UNDERLINE = "BLINKING_UNDERLINE" + + +class CursorShapeConfig(ABC): + @abstractmethod + def get_cursor_shape(self, application: "Application[Any]") -> CursorShape: + """ + Return the cursor shape to be used in the current state. + """ + + +AnyCursorShapeConfig = Union[CursorShape, CursorShapeConfig, None] + + +class SimpleCursorShapeConfig(CursorShapeConfig): + """ + Always show the given cursor shape. + """ + + def __init__(self, cursor_shape: CursorShape = CursorShape._NEVER_CHANGE) -> None: + self.cursor_shape = cursor_shape + + def get_cursor_shape(self, application: "Application[Any]") -> CursorShape: + return self.cursor_shape + + +class ModalCursorShapeConfig(CursorShapeConfig): + """ + Show cursor shape according to the current input mode. + """ + + def get_cursor_shape(self, application: "Application[Any]") -> CursorShape: + if application.editing_mode == EditingMode.VI: + if application.vi_state.input_mode == InputMode.INSERT: + return CursorShape.BEAM + if application.vi_state.input_mode == InputMode.REPLACE: + return CursorShape.UNDERLINE + + # Default + return CursorShape.BLOCK + + +class DynamicCursorShapeConfig(CursorShapeConfig): + def __init__( + self, get_cursor_shape_config: Callable[[], AnyCursorShapeConfig] + ) -> None: + self.get_cursor_shape_config = get_cursor_shape_config + + def get_cursor_shape(self, application: "Application[Any]") -> CursorShape: + return to_cursor_shape_config(self.get_cursor_shape_config()).get_cursor_shape( + application + ) + + +def to_cursor_shape_config(value: AnyCursorShapeConfig) -> CursorShapeConfig: + """ + Take a `CursorShape` instance or `CursorShapeConfig` and turn it into a + `CursorShapeConfig`. + """ + if value is None: + return SimpleCursorShapeConfig() + + if isinstance(value, CursorShape): + return SimpleCursorShapeConfig(value) + + return value diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/async_context_manager.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/async_context_manager.py index 173751ab06..39146165a0 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/async_context_manager.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/async_context_manager.py @@ -6,7 +6,7 @@ Types have been added to this file, just enough to make Mypy happy. # mypy: allow-untyped-defs import abc from functools import wraps -from typing import TYPE_CHECKING, AsyncContextManager, AsyncIterator, Callable, TypeVar +from typing import AsyncContextManager, AsyncIterator, Callable, TypeVar import _collections_abc diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/inputhook.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/inputhook.py index 7490d5b258..26228a2af3 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/inputhook.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/inputhook.py @@ -29,16 +29,7 @@ import selectors import threading from asyncio import AbstractEventLoop from selectors import BaseSelector, SelectorKey -from typing import ( - TYPE_CHECKING, - Any, - Callable, - List, - Mapping, - NamedTuple, - Optional, - Tuple, -) +from typing import TYPE_CHECKING, Any, Callable, List, Mapping, Optional, Tuple from prompt_toolkit.utils import is_windows @@ -52,7 +43,7 @@ __all__ = [ ] if TYPE_CHECKING: - from _typeshed import FileDescriptor, FileDescriptorLike + from _typeshed import FileDescriptorLike _EventMask = int diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/base.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/base.py index a268a82b11..fd57cca6e9 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/base.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/base.py @@ -1,5 +1,5 @@ from abc import ABCMeta, abstractmethod -from typing import Callable, Dict, Iterable, List, Tuple, Union, cast +from typing import Callable, Dict, Iterable, List, Tuple, Union __all__ = ["Filter", "Never", "Always", "Condition", "FilterOrBool"] diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/__init__.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/__init__.py index 1cb56bb653..f0c92c96f9 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/__init__.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/__init__.py @@ -27,6 +27,7 @@ from .utils import ( fragment_list_to_text, fragment_list_width, split_lines, + to_plain_text, ) __all__ = [ @@ -49,4 +50,5 @@ __all__ = [ "fragment_list_width", "fragment_list_to_text", "split_lines", + "to_plain_text", ] diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/ansi.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/ansi.py index 374cb32575..3d57063357 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/ansi.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/ansi.py @@ -55,7 +55,11 @@ class ANSI: formatted_text = self._formatted_text while True: + # NOTE: CSI is a special token within a stream of characters that + # introduces an ANSI control sequence used to set the + # style attributes of the following characters. csi = False + c = yield # Everything between \001 and \002 should become a ZeroWidthEscape. @@ -70,6 +74,7 @@ class ANSI: else: escaped_text += c + # Check for CSI if c == "\x1b": # Start of color escape sequence. square_bracket = yield @@ -84,19 +89,37 @@ class ANSI: # Got a CSI sequence. Color codes are following. current = "" params = [] + while True: char = yield + + # Construct number if char.isdigit(): current += char + + # Eval number else: + # Limit and save number value params.append(min(int(current or 0), 9999)) + + # Get delimiter token if present if char == ";": current = "" + + # Check and evaluate color codes elif char == "m": # Set attributes and token. self._select_graphic_rendition(params) style = self._create_style_string() break + + # Check and evaluate cursor forward + elif char == "C": + for i in range(params[0]): + # add <SPACE> using current style + formatted_text.append((style, " ")) + break + else: # Ignore unsupported sequence. break @@ -127,14 +150,16 @@ class ANSI: self._bgcolor = _bg_colors[attr] elif attr == 1: self._bold = True + # elif attr == 2: + # self._faint = True elif attr == 3: self._italic = True elif attr == 4: self._underline = True elif attr == 5: - self._blink = True + self._blink = True # Slow blink elif attr == 6: - self._blink = True # Fast blink. + self._blink = True # Fast blink elif attr == 7: self._reverse = True elif attr == 8: @@ -142,7 +167,7 @@ class ANSI: elif attr == 9: self._strike = True elif attr == 22: - self._bold = False + self._bold = False # Normal intensity elif attr == 23: self._italic = False elif attr == 24: @@ -151,9 +176,12 @@ class ANSI: self._blink = False elif attr == 27: self._reverse = False + elif attr == 28: + self._hidden = False elif attr == 29: self._strike = False elif not attr: + # Reset all style attributes self._color = None self._bgcolor = None self._bold = False diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/utils.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/utils.py index 7d48762db4..cda4233e06 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/utils.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/utils.py @@ -8,9 +8,15 @@ from typing import Iterable, cast from prompt_toolkit.utils import get_cwidth -from .base import OneStyleAndTextTuple, StyleAndTextTuples +from .base import ( + AnyFormattedText, + OneStyleAndTextTuple, + StyleAndTextTuples, + to_formatted_text, +) __all__ = [ + "to_plain_text", "fragment_list_len", "fragment_list_width", "fragment_list_to_text", @@ -18,6 +24,13 @@ __all__ = [ ] +def to_plain_text(value: AnyFormattedText) -> str: + """ + Turn any kind of formatted text back into plain text. + """ + return fragment_list_to_text(to_formatted_text(value)) + + def fragment_list_len(fragments: StyleAndTextTuples) -> int: """ Return the amount of characters in this text fragment list. diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/named_commands.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/named_commands.py index 48ae1aa40a..e0796ef0b8 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/named_commands.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/named_commands.py @@ -205,7 +205,7 @@ def end_of_history(event: E) -> None: """ Move to the end of the input history, i.e., the line currently being entered. """ - event.current_buffer.history_forward(count=10 ** 100) + event.current_buffer.history_forward(count=10**100) buff = event.current_buffer buff.go_to_history(len(buff._working_lines) - 1) diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/vi.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/vi.py index 89870ee531..efbb107de0 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/vi.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/vi.py @@ -3,7 +3,7 @@ import codecs import string from enum import Enum from itertools import accumulate -from typing import Callable, Iterable, List, Optional, Tuple, TypeVar, Union, cast +from typing import Callable, Iterable, List, Optional, Tuple, TypeVar, Union from prompt_toolkit.application.current import get_app from prompt_toolkit.buffer import Buffer, indent, reshape_text, unindent diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/containers.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/containers.py index 547d81d68b..2c845a76aa 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/containers.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/containers.py @@ -826,7 +826,7 @@ class FloatContainer(Container): if postpone: new_z_index = ( - number + 10 ** 8 + number + 10**8 ) # Draw as late as possible, but keep the order. screen.draw_with_z_index( z_index=new_z_index, diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py index 1e1f15f7aa..45b50e68f8 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py @@ -208,7 +208,7 @@ class UIContent: return self._line_heights_cache[key] except KeyError: if width == 0: - height = 10 ** 8 + height = 10**8 else: # Calculate line width first. line = fragment_list_to_text(self.get_line(lineno))[:slice_stop] @@ -235,7 +235,7 @@ class UIContent: prefix_width = get_cwidth(fragment_list_to_text(fragments2)) if prefix_width >= width: # Prefix doesn't fit. - height = 10 ** 8 + height = 10**8 break text_width += prefix_width @@ -244,7 +244,7 @@ class UIContent: try: quotient, remainder = divmod(text_width, width) except ZeroDivisionError: - height = 10 ** 8 + height = 10**8 else: if remainder: quotient += 1 # Like math.ceil. @@ -488,7 +488,7 @@ class DummyControl(UIControl): return [] return UIContent( - get_line=get_line, line_count=100 ** 100 + get_line=get_line, line_count=100**100 ) # Something very big. def is_focusable(self) -> bool: diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/dimension.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/dimension.py index 9b68da2f8f..04c21637cb 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/dimension.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/dimension.py @@ -58,7 +58,7 @@ class Dimension: if min is None: min = 0 # Smallest possible value. if max is None: # 0-values are allowed, so use "is None" - max = 1000 ** 10 # Something huge. + max = 1000**10 # Something huge. if preferred is None: preferred = min if weight is None: diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/menus.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/menus.py index e138fcea11..557450c000 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/menus.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/menus.py @@ -277,7 +277,7 @@ class CompletionsMenu(ConditionalContainer): scroll_offset: Union[int, Callable[[], int]] = 0, extra_filter: FilterOrBool = True, display_arrows: FilterOrBool = False, - z_index: int = 10 ** 8, + z_index: int = 10**8, ) -> None: extra_filter = to_filter(extra_filter) @@ -622,7 +622,7 @@ class MultiColumnCompletionsMenu(HSplit): suggested_max_column_width: int = 30, show_meta: FilterOrBool = True, extra_filter: FilterOrBool = True, - z_index: int = 10 ** 8, + z_index: int = 10**8, ) -> None: show_meta = to_filter(show_meta) diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/base.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/base.py index 0d6be34842..c78677bc8b 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/base.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/base.py @@ -4,6 +4,7 @@ Interface for an output. from abc import ABCMeta, abstractmethod from typing import Optional, TextIO +from prompt_toolkit.cursor_shapes import CursorShape from prompt_toolkit.data_structures import Size from prompt_toolkit.styles import Attrs @@ -140,6 +141,14 @@ class Output(metaclass=ABCMeta): def show_cursor(self) -> None: "Show cursor." + @abstractmethod + def set_cursor_shape(self, cursor_shape: CursorShape) -> None: + "Set cursor shape to block, beam or underline." + + @abstractmethod + def reset_cursor_shape(self) -> None: + "Reset cursor shape." + def ask_for_cpr(self) -> None: """ Asks for a cursor position report (CPR). @@ -289,6 +298,12 @@ class DummyOutput(Output): def show_cursor(self) -> None: pass + def set_cursor_shape(self, cursor_shape: CursorShape) -> None: + pass + + def reset_cursor_shape(self) -> None: + pass + def ask_for_cpr(self) -> None: pass diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/defaults.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/defaults.py index fc107a4d6e..bd4bf950c4 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/defaults.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/defaults.py @@ -10,6 +10,7 @@ from prompt_toolkit.utils import ( from .base import DummyOutput, Output from .color_depth import ColorDepth +from .plain_text import PlainTextOutput __all__ = [ "create_output", @@ -17,7 +18,7 @@ __all__ = [ def create_output( - stdout: Optional[TextIO] = None, always_prefer_tty: bool = True + stdout: Optional[TextIO] = None, always_prefer_tty: bool = False ) -> Output: """ Return an :class:`~prompt_toolkit.output.Output` instance for the command @@ -25,9 +26,13 @@ def create_output( :param stdout: The stdout object :param always_prefer_tty: When set, look for `sys.stderr` if `sys.stdout` - is not a TTY. (The prompt_toolkit render output is not meant to be - consumed by something other then a terminal, so this is a reasonable - default.) + is not a TTY. Useful if `sys.stdout` is redirected to a file, but we + still want user input and output on the terminal. + + By default, this is `False`. If `sys.stdout` is not a terminal (maybe + it's redirected to a file), then a `PlainTextOutput` will be returned. + That way, tools like `print_formatted_text` will write plain text into + that file. """ # Consider TERM, PROMPT_TOOLKIT_BELL, and PROMPT_TOOLKIT_COLOR_DEPTH # environment variables. Notice that PROMPT_TOOLKIT_COLOR_DEPTH value is @@ -82,6 +87,12 @@ def create_output( else: from .vt100 import Vt100_Output + # Stdout is not a TTY? Render as plain text. + # This is mostly useful if stdout is redirected to a file, and + # `print_formatted_text` is used. + if not stdout.isatty(): + return PlainTextOutput(stdout) + return Vt100_Output.from_pty( stdout, term=term_from_env, diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/flush_stdout.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/flush_stdout.py new file mode 100644 index 0000000000..4adcbd109d --- /dev/null +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/flush_stdout.py @@ -0,0 +1,84 @@ +import errno +import os +import sys +from contextlib import contextmanager +from typing import IO, Iterator, TextIO, cast + +__all__ = ["flush_stdout"] + + +def flush_stdout(stdout: TextIO, data: str, write_binary: bool) -> None: + try: + # Ensure that `stdout` is made blocking when writing into it. + # Otherwise, when uvloop is activated (which makes stdout + # non-blocking), and we write big amounts of text, then we get a + # `BlockingIOError` here. + with _blocking_io(stdout): + # (We try to encode ourself, because that way we can replace + # characters that don't exist in the character set, avoiding + # UnicodeEncodeError crashes. E.g. u'\xb7' does not appear in 'ascii'.) + # My Arch Linux installation of july 2015 reported 'ANSI_X3.4-1968' + # for sys.stdout.encoding in xterm. + out: IO[bytes] + if write_binary: + if hasattr(stdout, "buffer"): + out = stdout.buffer + else: + # IO[bytes] was given to begin with. + # (Used in the unit tests, for instance.) + out = cast(IO[bytes], stdout) + out.write(data.encode(stdout.encoding or "utf-8", "replace")) + else: + stdout.write(data) + + stdout.flush() + except IOError as e: + if e.args and e.args[0] == errno.EINTR: + # Interrupted system call. Can happen in case of a window + # resize signal. (Just ignore. The resize handler will render + # again anyway.) + pass + elif e.args and e.args[0] == 0: + # This can happen when there is a lot of output and the user + # sends a KeyboardInterrupt by pressing Control-C. E.g. in + # a Python REPL when we execute "while True: print('test')". + # (The `ptpython` REPL uses this `Output` class instead of + # `stdout` directly -- in order to be network transparent.) + # So, just ignore. + pass + else: + raise + + +@contextmanager +def _blocking_io(io: IO[str]) -> Iterator[None]: + """ + Ensure that the FD for `io` is set to blocking in here. + """ + if sys.platform == "win32": + # On Windows, the `os` module doesn't have a `get/set_blocking` + # function. + yield + return + + try: + fd = io.fileno() + blocking = os.get_blocking(fd) + except: # noqa + # Failed somewhere. + # `get_blocking` can raise `OSError`. + # The io object can raise `AttributeError` when no `fileno()` method is + # present if we're not a real file object. + blocking = True # Assume we're good, and don't do anything. + + try: + # Make blocking if we weren't blocking yet. + if not blocking: + os.set_blocking(fd, True) + + yield + + finally: + # Restore original blocking mode. + if not blocking: + os.set_blocking(fd, blocking) diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/plain_text.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/plain_text.py new file mode 100644 index 0000000000..23c1e9453f --- /dev/null +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/plain_text.py @@ -0,0 +1,145 @@ +from typing import List, TextIO + +from prompt_toolkit.cursor_shapes import CursorShape +from prompt_toolkit.data_structures import Size +from prompt_toolkit.styles import Attrs + +from .base import Output +from .color_depth import ColorDepth +from .flush_stdout import flush_stdout + +__all__ = ["PlainTextOutput"] + + +class PlainTextOutput(Output): + """ + Output that won't include any ANSI escape sequences. + + Useful when stdout is not a terminal. Maybe stdout is redirected to a file. + In this case, if `print_formatted_text` is used, for instance, we don't + want to include formatting. + + (The code is mostly identical to `Vt100_Output`, but without the + formatting.) + """ + + def __init__(self, stdout: TextIO, write_binary: bool = True) -> None: + assert all(hasattr(stdout, a) for a in ("write", "flush")) + + if write_binary: + assert hasattr(stdout, "encoding") + + self.stdout: TextIO = stdout + self.write_binary = write_binary + self._buffer: List[str] = [] + + def fileno(self) -> int: + "There is no sensible default for fileno()." + return self.stdout.fileno() + + def encoding(self) -> str: + return "utf-8" + + def write(self, data: str) -> None: + self._buffer.append(data) + + def write_raw(self, data: str) -> None: + self._buffer.append(data) + + def set_title(self, title: str) -> None: + pass + + def clear_title(self) -> None: + pass + + def flush(self) -> None: + if not self._buffer: + return + + data = "".join(self._buffer) + self._buffer = [] + flush_stdout(self.stdout, data, write_binary=self.write_binary) + + def erase_screen(self) -> None: + pass + + def enter_alternate_screen(self) -> None: + pass + + def quit_alternate_screen(self) -> None: + pass + + def enable_mouse_support(self) -> None: + pass + + def disable_mouse_support(self) -> None: + pass + + def erase_end_of_line(self) -> None: + pass + + def erase_down(self) -> None: + pass + + def reset_attributes(self) -> None: + pass + + def set_attributes(self, attrs: Attrs, color_depth: ColorDepth) -> None: + pass + + def disable_autowrap(self) -> None: + pass + + def enable_autowrap(self) -> None: + pass + + def cursor_goto(self, row: int = 0, column: int = 0) -> None: + pass + + def cursor_up(self, amount: int) -> None: + pass + + def cursor_down(self, amount: int) -> None: + self._buffer.append("\n") + + def cursor_forward(self, amount: int) -> None: + self._buffer.append(" " * amount) + + def cursor_backward(self, amount: int) -> None: + pass + + def hide_cursor(self) -> None: + pass + + def show_cursor(self) -> None: + pass + + def set_cursor_shape(self, cursor_shape: CursorShape) -> None: + pass + + def reset_cursor_shape(self) -> None: + pass + + def ask_for_cpr(self) -> None: + pass + + def bell(self) -> None: + pass + + def enable_bracketed_paste(self) -> None: + pass + + def disable_bracketed_paste(self) -> None: + pass + + def scroll_buffer_to_prompt(self) -> None: + pass + + def get_size(self) -> Size: + return Size(rows=40, columns=80) + + def get_rows_below_cursor_position(self) -> int: + return 8 + + def get_default_color_depth(self) -> ColorDepth: + return ColorDepth.DEPTH_1_BIT diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/vt100.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/vt100.py index 686303fa7b..0586267286 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/vt100.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/vt100.py @@ -6,34 +6,30 @@ A lot of thanks, regarding outputting of colors, goes to the Pygments project: everything has been highly optimized.) http://pygments.org/ """ -import array -import errno import io import os import sys -from contextlib import contextmanager from typing import ( - IO, Callable, Dict, Hashable, Iterable, - Iterator, List, Optional, Sequence, Set, TextIO, Tuple, - cast, ) +from prompt_toolkit.cursor_shapes import CursorShape from prompt_toolkit.data_structures import Size from prompt_toolkit.output import Output from prompt_toolkit.styles import ANSI_COLOR_NAMES, Attrs from prompt_toolkit.utils import is_dumb_terminal from .color_depth import ColorDepth +from .flush_stdout import flush_stdout __all__ = [ "Vt100_Output", @@ -443,6 +439,11 @@ class Vt100_Output(Output): ColorDepth.DEPTH_24_BIT: _EscapeCodeCache(ColorDepth.DEPTH_24_BIT), } + # Keep track of whether the cursor shape was ever changed. + # (We don't restore the cursor shape if it was never changed - by + # default, we don't change them.) + self._cursor_shape_changed = False + @classmethod def from_pty( cls, @@ -663,6 +664,31 @@ class Vt100_Output(Output): def show_cursor(self) -> None: self.write_raw("\x1b[?12l\x1b[?25h") # Stop blinking cursor and show. + def set_cursor_shape(self, cursor_shape: CursorShape) -> None: + if cursor_shape == CursorShape._NEVER_CHANGE: + return + + self._cursor_shape_changed = True + self.write_raw( + { + CursorShape.BLOCK: "\x1b[2 q", + CursorShape.BEAM: "\x1b[6 q", + CursorShape.UNDERLINE: "\x1b[4 q", + CursorShape.BLINKING_BLOCK: "\x1b[1 q", + CursorShape.BLINKING_BEAM: "\x1b[5 q", + CursorShape.BLINKING_UNDERLINE: "\x1b[3 q", + }.get(cursor_shape, "") + ) + + def reset_cursor_shape(self) -> None: + "Reset cursor shape." + # (Only reset cursor shape, if we ever changed it.) + if self._cursor_shape_changed: + self._cursor_shape_changed = False + + # Reset cursor shape. + self.write_raw("\x1b[0 q") + def flush(self) -> None: """ Write to output stream and flush. @@ -673,46 +699,7 @@ class Vt100_Output(Output): data = "".join(self._buffer) self._buffer = [] - try: - # Ensure that `self.stdout` is made blocking when writing into it. - # Otherwise, when uvloop is activated (which makes stdout - # non-blocking), and we write big amounts of text, then we get a - # `BlockingIOError` here. - with blocking_io(self.stdout): - # (We try to encode ourself, because that way we can replace - # characters that don't exist in the character set, avoiding - # UnicodeEncodeError crashes. E.g. u'\xb7' does not appear in 'ascii'.) - # My Arch Linux installation of july 2015 reported 'ANSI_X3.4-1968' - # for sys.stdout.encoding in xterm. - out: IO[bytes] - if self.write_binary: - if hasattr(self.stdout, "buffer"): - out = self.stdout.buffer - else: - # IO[bytes] was given to begin with. - # (Used in the unit tests, for instance.) - out = cast(IO[bytes], self.stdout) - out.write(data.encode(self.stdout.encoding or "utf-8", "replace")) - else: - self.stdout.write(data) - - self.stdout.flush() - except IOError as e: - if e.args and e.args[0] == errno.EINTR: - # Interrupted system call. Can happen in case of a window - # resize signal. (Just ignore. The resize handler will render - # again anyway.) - pass - elif e.args and e.args[0] == 0: - # This can happen when there is a lot of output and the user - # sends a KeyboardInterrupt by pressing Control-C. E.g. in - # a Python REPL when we execute "while True: print('test')". - # (The `ptpython` REPL uses this `Output` class instead of - # `stdout` directly -- in order to be network transparent.) - # So, just ignore. - pass - else: - raise + flush_stdout(self.stdout, data, write_binary=self.write_binary) def ask_for_cpr(self) -> None: """ @@ -764,37 +751,3 @@ class Vt100_Output(Output): return ColorDepth.DEPTH_4_BIT return ColorDepth.DEFAULT - - -@contextmanager -def blocking_io(io: IO[str]) -> Iterator[None]: - """ - Ensure that the FD for `io` is set to blocking in here. - """ - if sys.platform == "win32": - # On Windows, the `os` module doesn't have a `get/set_blocking` - # function. - yield - return - - try: - fd = io.fileno() - blocking = os.get_blocking(fd) - except: # noqa - # Failed somewhere. - # `get_blocking` can raise `OSError`. - # The io object can raise `AttributeError` when no `fileno()` method is - # present if we're not a real file object. - blocking = True # Assume we're good, and don't do anything. - - try: - # Make blocking if we weren't blocking yet. - if not blocking: - os.set_blocking(fd, True) - - yield - - finally: - # Restore original blocking mode. - if not blocking: - os.set_blocking(fd, blocking) diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/win32.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/win32.py index f26066cb99..abfd61774b 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/win32.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/win32.py @@ -1,14 +1,5 @@ import os -from ctypes import ( - ArgumentError, - byref, - c_char, - c_long, - c_short, - c_uint, - c_ulong, - pointer, -) +from ctypes import ArgumentError, byref, c_char, c_long, c_uint, c_ulong, pointer from ..utils import SPHINX_AUTODOC_RUNNING @@ -20,6 +11,7 @@ if not SPHINX_AUTODOC_RUNNING: from ctypes.wintypes import DWORD, HANDLE from typing import Callable, Dict, List, Optional, TextIO, Tuple, Type, TypeVar, Union +from prompt_toolkit.cursor_shapes import CursorShape from prompt_toolkit.data_structures import Size from prompt_toolkit.styles import ANSI_COLOR_NAMES, Attrs from prompt_toolkit.utils import get_cwidth @@ -498,6 +490,12 @@ class Win32Output(Output): def show_cursor(self) -> None: pass + def set_cursor_shape(self, cursor_shape: CursorShape) -> None: + pass + + def reset_cursor_shape(self) -> None: + pass + @classmethod def win32_refresh_window(cls) -> None: """ diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/renderer.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/renderer.py index 9d8255d717..d670c3c57b 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/renderer.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/renderer.py @@ -8,6 +8,7 @@ from enum import Enum from typing import TYPE_CHECKING, Any, Callable, Deque, Dict, Hashable, Optional, Tuple from prompt_toolkit.application.current import get_app +from prompt_toolkit.cursor_shapes import CursorShape from prompt_toolkit.data_structures import Point, Size from prompt_toolkit.filters import FilterOrBool, to_filter from prompt_toolkit.formatted_text import AnyFormattedText, to_formatted_text @@ -385,6 +386,7 @@ class Renderer: self._last_screen: Optional[Screen] = None self._last_size: Optional[Size] = None self._last_style: Optional[str] = None + self._last_cursor_shape: Optional[CursorShape] = None # Default MouseHandlers. (Just empty.) self.mouse_handlers = MouseHandlers() @@ -704,6 +706,16 @@ class Renderer: self._last_size = size self.mouse_handlers = mouse_handlers + # Handle cursor shapes. + new_cursor_shape = app.cursor.get_cursor_shape(app) + if ( + self._last_cursor_shape is None + or self._last_cursor_shape != new_cursor_shape + ): + output.set_cursor_shape(new_cursor_shape) + self._last_cursor_shape = new_cursor_shape + + # Flush buffered output. output.flush() # Set visible windows in layout. @@ -728,6 +740,8 @@ class Renderer: output.erase_down() output.reset_attributes() output.enable_autowrap() + output.reset_cursor_shape() + output.flush() self.reset(leave_alternate_screen=leave_alternate_screen) diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/dialogs.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/dialogs.py index d7e57028d0..a91bb3142c 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/dialogs.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/dialogs.py @@ -263,7 +263,7 @@ def progress_dialog( focusable=False, # Prefer this text area as big as possible, to avoid having a window # that keeps resizing when we add text to it. - height=D(preferred=10 ** 10), + height=D(preferred=10**10), ) dialog = Dialog( diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/base.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/base.py index 0f08dbfd01..c22507e25c 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/base.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/base.py @@ -51,7 +51,6 @@ from prompt_toolkit.layout.controls import UIContent, UIControl from prompt_toolkit.layout.dimension import AnyDimension, D from prompt_toolkit.output import ColorDepth, Output from prompt_toolkit.styles import BaseStyle -from prompt_toolkit.utils import in_main_thread from .formatters import Formatter, create_default_formatters diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py index 9fff411424..a8d8a58555 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py @@ -46,6 +46,11 @@ from prompt_toolkit.auto_suggest import AutoSuggest, DynamicAutoSuggest from prompt_toolkit.buffer import Buffer from prompt_toolkit.clipboard import Clipboard, DynamicClipboard, InMemoryClipboard from prompt_toolkit.completion import Completer, DynamicCompleter, ThreadedCompleter +from prompt_toolkit.cursor_shapes import ( + AnyCursorShapeConfig, + CursorShapeConfig, + DynamicCursorShapeConfig, +) from prompt_toolkit.document import Document from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER, EditingMode from prompt_toolkit.eventloop import get_event_loop @@ -342,6 +347,7 @@ class PromptSession(Generic[_T]): "style_transformation", "swap_light_and_dark_colors", "color_depth", + "cursor", "include_default_pygments_style", "rprompt", "multiline", @@ -394,6 +400,7 @@ class PromptSession(Generic[_T]): style_transformation: Optional[StyleTransformation] = None, swap_light_and_dark_colors: FilterOrBool = False, color_depth: Optional[ColorDepth] = None, + cursor: AnyCursorShapeConfig = None, include_default_pygments_style: FilterOrBool = True, history: Optional[History] = None, clipboard: Optional[Clipboard] = None, @@ -436,6 +443,7 @@ class PromptSession(Generic[_T]): self.style_transformation = style_transformation self.swap_light_and_dark_colors = swap_light_and_dark_colors self.color_depth = color_depth + self.cursor = cursor self.include_default_pygments_style = include_default_pygments_style self.rprompt = rprompt self.multiline = multiline @@ -751,6 +759,7 @@ class PromptSession(Generic[_T]): erase_when_done=erase_when_done, reverse_vi_search_direction=True, color_depth=lambda: self.color_depth, + cursor=DynamicCursorShapeConfig(lambda: self.cursor), refresh_interval=self.refresh_interval, input=self._input, output=self._output, @@ -861,6 +870,7 @@ class PromptSession(Generic[_T]): bottom_toolbar: Optional[AnyFormattedText] = None, style: Optional[BaseStyle] = None, color_depth: Optional[ColorDepth] = None, + cursor: Optional[AnyCursorShapeConfig] = None, include_default_pygments_style: Optional[FilterOrBool] = None, style_transformation: Optional[StyleTransformation] = None, swap_light_and_dark_colors: Optional[FilterOrBool] = None, @@ -957,6 +967,8 @@ class PromptSession(Generic[_T]): self.style = style if color_depth is not None: self.color_depth = color_depth + if cursor is not None: + self.cursor = cursor if include_default_pygments_style is not None: self.include_default_pygments_style = include_default_pygments_style if style_transformation is not None: @@ -1090,6 +1102,7 @@ class PromptSession(Generic[_T]): bottom_toolbar: Optional[AnyFormattedText] = None, style: Optional[BaseStyle] = None, color_depth: Optional[ColorDepth] = None, + cursor: Optional[CursorShapeConfig] = None, include_default_pygments_style: Optional[FilterOrBool] = None, style_transformation: Optional[StyleTransformation] = None, swap_light_and_dark_colors: Optional[FilterOrBool] = None, @@ -1145,6 +1158,8 @@ class PromptSession(Generic[_T]): self.style = style if color_depth is not None: self.color_depth = color_depth + if cursor is not None: + self.cursor = cursor if include_default_pygments_style is not None: self.include_default_pygments_style = include_default_pygments_style if style_transformation is not None: @@ -1358,6 +1373,7 @@ def prompt( bottom_toolbar: Optional[AnyFormattedText] = None, style: Optional[BaseStyle] = None, color_depth: Optional[ColorDepth] = None, + cursor: AnyCursorShapeConfig = None, include_default_pygments_style: Optional[FilterOrBool] = None, style_transformation: Optional[StyleTransformation] = None, swap_light_and_dark_colors: Optional[FilterOrBool] = None, @@ -1408,6 +1424,7 @@ def prompt( bottom_toolbar=bottom_toolbar, style=style, color_depth=color_depth, + cursor=cursor, include_default_pygments_style=include_default_pygments_style, style_transformation=style_transformation, swap_light_and_dark_colors=swap_light_and_dark_colors, diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py index bb35a2c62e..728190b54c 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py @@ -343,6 +343,7 @@ class Label: width: AnyDimension = None, dont_extend_height: bool = True, dont_extend_width: bool = False, + align: Union[WindowAlign, Callable[[], WindowAlign]] = WindowAlign.LEFT, ) -> None: self.text = text @@ -368,6 +369,7 @@ class Label: style="class:label " + style, dont_extend_height=dont_extend_height, dont_extend_width=dont_extend_width, + align=align, ) def __pt_container__(self) -> Container: diff --git a/contrib/python/prompt-toolkit/py3/ya.make b/contrib/python/prompt-toolkit/py3/ya.make index 7ff953603b..d53f98a7c3 100644 --- a/contrib/python/prompt-toolkit/py3/ya.make +++ b/contrib/python/prompt-toolkit/py3/ya.make @@ -4,7 +4,7 @@ PY3_LIBRARY() OWNER(g:python-contrib) -VERSION(3.0.26) +VERSION(3.0.27) LICENSE(BSD-3-Clause) @@ -67,6 +67,7 @@ PY_SRCS( prompt_toolkit/contrib/telnet/log.py prompt_toolkit/contrib/telnet/protocol.py prompt_toolkit/contrib/telnet/server.py + prompt_toolkit/cursor_shapes.py prompt_toolkit/data_structures.py prompt_toolkit/document.py prompt_toolkit/enums.py @@ -145,6 +146,8 @@ PY_SRCS( prompt_toolkit/output/color_depth.py prompt_toolkit/output/conemu.py prompt_toolkit/output/defaults.py + prompt_toolkit/output/flush_stdout.py + prompt_toolkit/output/plain_text.py prompt_toolkit/output/vt100.py prompt_toolkit/output/win32.py prompt_toolkit/output/windows10.py |