aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2025-02-04 23:55:58 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2025-02-05 00:13:10 +0300
commite0149bcce6c022b2baaf22dc46dfad00080d041d (patch)
tree8d8629279ddbec4d3cbd1756cd1348c7c1d53706 /contrib/python/prompt-toolkit/py3/prompt_toolkit/layout
parent850bc4677d9c730e49444ba0fba91309d9cadd0b (diff)
downloadydb-e0149bcce6c022b2baaf22dc46dfad00080d041d.tar.gz
Intermediate changes
commit_hash:fe9cb645107d4e98cea6850ff89242dd287facbb
Diffstat (limited to 'contrib/python/prompt-toolkit/py3/prompt_toolkit/layout')
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py17
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/processors.py12
2 files changed, 23 insertions, 6 deletions
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 222e471c57..5083c8286d 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py
@@ -667,7 +667,11 @@ class BufferControl(UIControl):
merged_processor = merge_processors(input_processors)
- def transform(lineno: int, fragments: StyleAndTextTuples) -> _ProcessedLine:
+ def transform(
+ lineno: int,
+ fragments: StyleAndTextTuples,
+ get_line: Callable[[int], StyleAndTextTuples],
+ ) -> _ProcessedLine:
"Transform the fragments for a given line number."
# Get cursor position at this line.
@@ -679,7 +683,14 @@ class BufferControl(UIControl):
transformation = merged_processor.apply_transformation(
TransformationInput(
- self, document, lineno, source_to_display, fragments, width, height
+ self,
+ document,
+ lineno,
+ source_to_display,
+ fragments,
+ width,
+ height,
+ get_line,
)
)
@@ -697,7 +708,7 @@ class BufferControl(UIControl):
try:
return cache[i]
except KeyError:
- processed_line = transform(i, get_line(i))
+ processed_line = transform(i, get_line(i), get_line)
cache[i] = processed_line
return processed_line
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/processors.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/processors.py
index b10ecf7184..666e79c66d 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/processors.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/processors.py
@@ -86,6 +86,9 @@ class TransformationInput:
previous processors into account.)
:param fragments: List of fragments that we can transform. (Received from the
previous processor.)
+ :param get_line: Optional ; a callable that returns the fragments of another
+ line in the current buffer; This can be used to create processors capable
+ of affecting transforms across multiple lines.
"""
def __init__(
@@ -97,6 +100,7 @@ class TransformationInput:
fragments: StyleAndTextTuples,
width: int,
height: int,
+ get_line: Callable[[int], StyleAndTextTuples] | None = None,
) -> None:
self.buffer_control = buffer_control
self.document = document
@@ -105,6 +109,7 @@ class TransformationInput:
self.fragments = fragments
self.width = width
self.height = height
+ self.get_line = get_line
def unpack(
self,
@@ -842,9 +847,9 @@ class ReverseSearchProcessor(Processor):
def apply_transformation(self, ti: TransformationInput) -> Transformation:
from .controls import SearchBufferControl
- assert isinstance(
- ti.buffer_control, SearchBufferControl
- ), "`ReverseSearchProcessor` should be applied to a `SearchBufferControl` only."
+ assert isinstance(ti.buffer_control, SearchBufferControl), (
+ "`ReverseSearchProcessor` should be applied to a `SearchBufferControl` only."
+ )
source_to_display: SourceToDisplay | None
display_to_source: DisplayToSource | None
@@ -987,6 +992,7 @@ class _MergedProcessor(Processor):
fragments,
ti.width,
ti.height,
+ ti.get_line,
)
)
fragments = transformation.fragments