diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-06-25 17:16:00 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-06-25 17:25:06 +0300 |
commit | da76f0a36e74126cec432deca81e964d16c2520e (patch) | |
tree | 18e1d8ce9f53a73a6a74945844a8d6a17d3077f2 /contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py | |
parent | d9e4fe8aeca226856d2780ca903622285610658e (diff) | |
download | ydb-da76f0a36e74126cec432deca81e964d16c2520e.tar.gz |
Intermediate changes
Diffstat (limited to 'contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py')
-rw-r--r-- | contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py | 47 |
1 files changed, 30 insertions, 17 deletions
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 709b7a9499..e2330e9e1f 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py @@ -59,7 +59,7 @@ from prompt_toolkit.layout.controls import ( FormattedTextControl, GetLinePrefixCallable, ) -from prompt_toolkit.layout.dimension import AnyDimension, to_dimension +from prompt_toolkit.layout.dimension import AnyDimension from prompt_toolkit.layout.dimension import Dimension as D from prompt_toolkit.layout.margins import ( ConditionalMargin, @@ -636,31 +636,44 @@ class Box: modal: bool = False, key_bindings: KeyBindings | None = None, ) -> None: - if padding is None: - padding = D(preferred=0) - - def get(value: AnyDimension) -> D: - if value is None: - value = padding - return to_dimension(value) - - self.padding_left = get(padding_left) - self.padding_right = get(padding_right) - self.padding_top = get(padding_top) - self.padding_bottom = get(padding_bottom) + self.padding = padding + self.padding_left = padding_left + self.padding_right = padding_right + self.padding_top = padding_top + self.padding_bottom = padding_bottom self.body = body + def left() -> AnyDimension: + if self.padding_left is None: + return self.padding + return self.padding_left + + def right() -> AnyDimension: + if self.padding_right is None: + return self.padding + return self.padding_right + + def top() -> AnyDimension: + if self.padding_top is None: + return self.padding + return self.padding_top + + def bottom() -> AnyDimension: + if self.padding_bottom is None: + return self.padding + return self.padding_bottom + self.container = HSplit( [ - Window(height=self.padding_top, char=char), + Window(height=top, char=char), VSplit( [ - Window(width=self.padding_left, char=char), + Window(width=left, char=char), body, - Window(width=self.padding_right, char=char), + Window(width=right, char=char), ] ), - Window(height=self.padding_bottom, char=char), + Window(height=bottom, char=char), ], width=width, height=height, |