Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/textual/_styles_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def __init__(self) -> None:
self._cache: dict[int, Strip] = {}
self._dirty_lines: set[int] = set()
self._width = 1
self._simple_strip: Strip | None = None
"""A simple strip consisting of left border + background + right border, which may be reused in a render."""

def __rich_repr__(self) -> rich.repr.Result:
if self._dirty_lines:
Expand Down Expand Up @@ -106,6 +108,7 @@ def render_widget(self, widget: Widget, crop: Region) -> list[Strip]:
"""
border_title = widget._border_title
border_subtitle = widget._border_subtitle
self._simple_strip = None

base_background, background = widget.background_colors
styles = widget.styles
Expand Down Expand Up @@ -348,6 +351,7 @@ def post(segments: Iterable[Segment]) -> Iterable[Segment]:
segments = _apply_opacity(segments, base_background, opacity)
return segments

cache_simple_strip: bool = False
line: Iterable[Segment]
# Draw top or bottom borders (A)
if (border_top and y == 0) or (border_bottom and y == height - 1):
Expand Down Expand Up @@ -411,11 +415,13 @@ def post(segments: Iterable[Segment]) -> Iterable[Segment]:
label_segments,
label_alignment, # type: ignore
)

# Draw padding (B)
elif (pad_top and y < gutter.top) or (
pad_bottom and y >= height - gutter.bottom
):
if self._simple_strip is not None:
return self._simple_strip
cache_simple_strip = True
background_rich_style = inner.rich_style
left_style = Style(
foreground=base_background + border_left_color.multiply_alpha(opacity)
Expand Down Expand Up @@ -498,6 +504,7 @@ def post(segments: Iterable[Segment]) -> Iterable[Segment]:
line = [left, *line]
else:
line = [*line, right]

strip = Strip(post(line), width)
if cache_simple_strip:
self._simple_strip = strip
return strip
2 changes: 2 additions & 0 deletions src/textual/widgets/_collapsible.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
class CollapsibleTitle(Static, can_focus=True):
"""Title and symbol for the Collapsible."""

BINDING_GROUP_TITLE = "Collapsible"

ALLOW_SELECT = False
DEFAULT_CSS = """
CollapsibleTitle {
Expand Down
6 changes: 5 additions & 1 deletion src/textual/widgets/_help_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ def update_help(self, focused_widget: Widget | None) -> None:
return
self.set_class(focused_widget is not None, "-show-help")
if focused_widget is not None:
help = focused_widget.HELP or ""
help: str = ""
for node in focused_widget.ancestors_with_self:
if isinstance(node, Widget) and node.HELP:
help = node.HELP
break
if not help:
self.remove_class("-show-help")
try:
Expand Down
1 change: 1 addition & 0 deletions src/textual/widgets/_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def is_empty(self) -> bool:
class Input(ScrollView):
"""A text input widget."""

BINDING_GROUP_TITLE = "Input"
BINDINGS: ClassVar[list[BindingType]] = [
Binding("left", "cursor_left", "Move cursor left", show=False),
Binding(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading