Skip to content

Commit 46b9753

Browse files
committed
snapshots
1 parent e81471e commit 46b9753

File tree

52 files changed

+1059
-1077
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1059
-1077
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2020
- Added `OptionList.set_options` https://github.com/Textualize/textual/pull/6048
2121
- Added `TextArea.suggestion` https://github.com/Textualize/textual/pull/6048
2222
- Added `TextArea.placeholder` https://github.com/Textualize/textual/pull/6048
23+
- Added `Widget.get_line_filters`
2324

2425
### Changed
2526

2627
- Breaking change: The `renderable` property on the `Static` widget has been changed to `content`. https://github.com/Textualize/textual/pull/6041
2728
- Breaking change: Renamed `Label` constructor argument `renderable` to `content` for consistency https://github.com/Textualize/textual/pull/6045
29+
- Breaking change: Optimization to line API to avoid applying background styles to widget content. In practice this means that you can no longer rely on blank Segments automatically getting the background color.
2830

2931
# [5.3.0] - 2025-08-07
3032

src/textual/_styles_cache.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ def render_widget(self, widget: Widget, crop: Region) -> list[Strip]:
108108
border_title = widget._border_title
109109
border_subtitle = widget._border_subtitle
110110

111-
base_background, background = widget._opacity_background_colors
111+
base_background, background = widget.background_colors
112112
styles = widget.styles
113113
strips = self.render(
114114
styles,
115115
widget.region.size,
116116
base_background,
117117
background,
118118
widget.render_line,
119-
widget.app._enabled_filters,
119+
widget.get_line_filters(),
120120
(
121121
None
122122
if border_title is None
@@ -417,7 +417,7 @@ def post(segments: Iterable[Segment]) -> Iterable[Segment]:
417417
elif (pad_top and y < gutter.top) or (
418418
pad_bottom and y >= height - gutter.bottom
419419
):
420-
background_rich_style = from_color(bgcolor=background.rich_color)
420+
background_rich_style = inner.rich_style
421421
left_style = Style(
422422
foreground=base_background + border_left_color.multiply_alpha(opacity)
423423
)
@@ -444,8 +444,6 @@ def post(segments: Iterable[Segment]) -> Iterable[Segment]:
444444
else:
445445
line = Strip.blank(content_width, inner.rich_style)
446446

447-
if inner:
448-
line = Segment.apply_style(line, inner.rich_style)
449447
if (text_opacity := styles.text_opacity) != 1.0:
450448
line = TextOpacity.process_segments(line, text_opacity, ansi_theme)
451449
line = line_post(line_pad(line, pad_left, pad_right, inner.rich_style))

src/textual/dom.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,22 +1144,22 @@ def _get_subtitle_style_information(
11441144
VisualStyle.from_rich_style(styles.border_subtitle_style),
11451145
)
11461146

1147-
@property
1148-
def background_colors(self) -> tuple[Color, Color]:
1149-
"""The background color and the color of the parent's background.
1150-
1151-
Returns:
1152-
`(<background color>, <color>)`
1153-
"""
1154-
base_background = background = BLACK
1155-
for node in reversed(self.ancestors_with_self):
1156-
styles = node.styles
1157-
base_background = background
1158-
background += styles.background.tint(styles.background_tint)
1159-
return (base_background, background)
1147+
# @property
1148+
# def background_colors(self) -> tuple[Color, Color]:
1149+
# """The background color and the color of the parent's background.
1150+
1151+
# Returns:
1152+
# `(<background color>, <color>)`
1153+
# """
1154+
# base_background = background = BLACK
1155+
# for node in reversed(self.ancestors_with_self):
1156+
# styles = node.styles
1157+
# base_background = background
1158+
# background += styles.background.tint(styles.background_tint)
1159+
# return (base_background, background)
11601160

11611161
@property
1162-
def _opacity_background_colors(self) -> tuple[Color, Color]:
1162+
def background_colors(self) -> tuple[Color, Color]:
11631163
"""Background colors adjusted for opacity.
11641164
11651165
Returns:

src/textual/scrollbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def render(self) -> RenderableType:
287287
background = styles.scrollbar_background
288288
color = styles.scrollbar_color
289289
if background.a < 1:
290-
base_background, _ = self.parent._opacity_background_colors
290+
base_background, _ = self.parent.background_colors
291291
background = base_background + background
292292
color = background + color
293293
scrollbar_style = Style.from_color(color.rich_color, background.rich_color)

src/textual/widget.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
if TYPE_CHECKING:
9595
from textual.app import App, ComposeResult
9696
from textual.css.query import QueryType
97+
from textual.filter import LineFilter
9798
from textual.message_pump import MessagePump
9899
from textual.scrollbar import (
99100
ScrollBar,
@@ -674,6 +675,14 @@ def text_selection(self) -> Selection | None:
674675
"""Text selection information, or `None` if no text is selected in this widget."""
675676
return self.screen.selections.get(self, None)
676677

678+
def get_line_filters(self) -> Sequence[LineFilter]:
679+
"""Get the line filters enabled for this widget.
680+
681+
Returns:
682+
A sequence of LineFilter instances.
683+
"""
684+
return self.app._enabled_filters
685+
677686
def preflight_checks(self) -> None:
678687
"""Called in debug mode to do preflight checks.
679688
@@ -4088,7 +4097,7 @@ def render_line(self, y: int) -> Strip:
40884097
try:
40894098
line = self._render_cache.lines[y]
40904099
except IndexError:
4091-
line = Strip.blank(self.size.width, self.rich_style)
4100+
line = Strip.blank(self.size.width, self.visual_style.rich_style)
40924101

40934102
return line
40944103

src/textual/widgets/_input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ def is_valid(self) -> bool:
601601

602602
def render_line(self, y: int) -> Strip:
603603
if y != 0:
604-
return Strip.blank(self.size.width)
604+
return Strip.blank(self.size.width, self.rich_style)
605605

606606
console = self.app.console
607607
console_options = self.app.console_options

src/textual/widgets/_masked_input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ def set_classes() -> None:
553553

554554
def render_line(self, y: int) -> Strip:
555555
if y != 0:
556-
return Strip.blank(self.size.width)
556+
return Strip.blank(self.size.width, self.rich_style)
557557

558558
result = self._value
559559
width = self.content_size.width

src/textual/widgets/_option_list.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,10 @@ def render_line(self, y: int) -> Strip:
875875
option_index, line_offset = self._lines[line_number]
876876
option = self.options[option_index]
877877
except IndexError:
878-
return Strip.blank(self.scrollable_content_region.width)
878+
return Strip.blank(
879+
self.scrollable_content_region.width,
880+
self.get_visual_style("option-list--option").rich_style,
881+
)
879882

880883
mouse_over = self._mouse_hovering_over == option_index
881884
component_class = ""
@@ -895,7 +898,10 @@ def render_line(self, y: int) -> Strip:
895898
try:
896899
strip = strips[line_offset]
897900
except IndexError:
898-
return Strip.blank(self.scrollable_content_region.width)
901+
return Strip.blank(
902+
self.scrollable_content_region.width,
903+
self.get_visual_style("option-list--option").rich_style,
904+
)
899905
return strip
900906

901907
def validate_highlighted(self, highlighted: int | None) -> int | None:

src/textual/widgets/_text_area.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,6 +1264,11 @@ def _render_line(self, y: int) -> Strip:
12641264
A rendered line.
12651265
"""
12661266
theme = self._theme
1267+
base_style = (
1268+
theme.base_style
1269+
if theme and theme.base_style is not None
1270+
else self.rich_style
1271+
)
12671272

12681273
wrapped_document = self.wrapped_document
12691274
scroll_x, scroll_y = self.scroll_offset
@@ -1275,7 +1280,7 @@ def _render_line(self, y: int) -> Strip:
12751280
out_of_bounds = y_offset >= wrapped_document.height
12761281

12771282
if out_of_bounds:
1278-
return Strip.blank(self.size.width)
1283+
return Strip.blank(self.size.width, base_style)
12791284

12801285
# Get the line corresponding to this offset
12811286
try:
@@ -1284,7 +1289,7 @@ def _render_line(self, y: int) -> Strip:
12841289
line_info = None
12851290

12861291
if line_info is None:
1287-
return Strip.blank(self.size.width)
1292+
return Strip.blank(self.size.width, base_style)
12881293

12891294
line_index, section_offset = line_info
12901295

@@ -1474,11 +1479,7 @@ def _render_line(self, y: int) -> Strip:
14741479
text_strip = text_strip.extend_cell_length(target_width, line_style)
14751480
strip = Strip.join([Strip(gutter, cell_length=gutter_width), text_strip])
14761481

1477-
return strip.apply_style(
1478-
theme.base_style
1479-
if theme and theme.base_style is not None
1480-
else self.rich_style
1481-
)
1482+
return strip.apply_style(base_style)
14821483

14831484
@property
14841485
def text(self) -> str:

tests/snapshot_tests/__snapshots__/test_snapshots/test_add_separator.svg

Lines changed: 62 additions & 62 deletions
Loading

0 commit comments

Comments
 (0)