Skip to content

Commit 555fa62

Browse files
committed
fix padding style
1 parent 617f1bd commit 555fa62

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/textual/content.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ def wrap(
220220
selection: Selection | None = None,
221221
selection_style: Style | None = None,
222222
) -> list[ContentLine]:
223-
# lines: list[Content] = []
224223
output_lines: list[ContentLine] = []
225224

226225
if selection is not None:
@@ -1065,7 +1064,9 @@ def to_strip(self, style: Style) -> Strip:
10651064
return strip
10661065

10671066
segments: list[Segment] = (
1068-
[Segment(" " * pad_left, base_rich_style)] if pad_left else []
1067+
[Segment(" " * pad_left, style.background_style.rich_style)]
1068+
if pad_left
1069+
else []
10691070
)
10701071
add_segment = segments.append
10711072
for text, text_style in content.render(style, end=""):
@@ -1075,7 +1076,9 @@ def to_strip(self, style: Style) -> Strip:
10751076
x += len(text)
10761077

10771078
if pad_right:
1078-
segments.append(_Segment(" " * pad_right, base_rich_style))
1079+
segments.append(
1080+
_Segment(" " * pad_right, style.background_style.rich_style)
1081+
)
10791082
strip = Strip(segments, content.cell_length + pad_left + pad_right)
10801083
return strip
10811084

src/textual/visual.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def visualize(widget: Widget, obj: object) -> Visual:
8888

8989
if isinstance(obj, Text) and widget.allow_select:
9090
return Content.from_rich_text(
91-
obj, align=obj.align or widget.styles.text_align
91+
obj, align=obj.justify or widget.styles.text_align
9292
)
9393

9494
# If its is a Rich renderable, wrap it with a RichVisual
@@ -268,6 +268,11 @@ def without_color(self) -> Style:
268268
_meta=self._meta,
269269
)
270270

271+
@cached_property
272+
def background_style(self) -> Style:
273+
"""Just the background color, with no other attributes."""
274+
return Style(self.background)
275+
271276
@classmethod
272277
def combine(cls, styles: Iterable[Style]) -> Style:
273278
"""Add a number of styles and get the result."""

0 commit comments

Comments
 (0)