Skip to content

Commit 1c6374f

Browse files
committed
snaphots
1 parent 54db93d commit 1c6374f

24 files changed

+607
-591
lines changed

src/textual/_styles_cache.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,9 @@ def post(segments: Iterable[Segment]) -> Iterable[Segment]:
350350
ansi_theme = DEFAULT_TERMINAL_THEME
351351

352352
if styles.tint.a:
353-
segments = Tint.process_segments(segments, styles.tint, ansi_theme)
353+
segments = Tint.process_segments(
354+
segments, styles.tint, ansi_theme, background
355+
)
354356
if opacity != 1.0:
355357
segments = _apply_opacity(segments, base_background, opacity)
356358
return segments

src/textual/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,6 @@ def _get_textual_animations() -> AnimationLevel:
167167
"""
168168

169169
DIM_FACTOR: Final[float] = (
170-
_get_environ_int("TEXTUAL_DIM_FACTOR", 50, minimum=0, maximum=100) / 100
170+
_get_environ_int("TEXTUAL_DIM_FACTOR", 66, minimum=0, maximum=100) / 100
171171
)
172172
"""Percentage to use as opacity when converting ANSI 'dim' attribute to RGB."""

src/textual/filter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,9 @@ def truecolor_style(self, style: Style, background: RichColor) -> Style:
253253
# Convert dim style to RGB
254254
if style.dim and color is not None:
255255
color = dim_color(background, color)
256+
style += NO_DIM
256257

257-
return Style.from_color(color, bgcolor)
258+
return style + Style.from_color(color, bgcolor)
258259

259260
def apply(self, segments: list[Segment], background: Color) -> list[Segment]:
260261
"""Transform a list of segments.

src/textual/renderables/text_opacity.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,18 @@ def __init__(self, renderable: RenderableType, opacity: float = 1.0) -> None:
5252

5353
@classmethod
5454
def process_segments(
55-
cls, segments: Iterable[Segment], opacity: float, ansi_theme: TerminalTheme
55+
cls,
56+
segments: Iterable[Segment],
57+
opacity: float,
58+
ansi_theme: TerminalTheme,
5659
) -> Iterable[Segment]:
5760
"""Apply opacity to segments.
5861
5962
Args:
6063
segments: Incoming segments.
6164
opacity: Opacity to apply.
6265
ansi_theme: Terminal theme.
66+
background: Color of background.
6367
6468
Returns:
6569
Segments with applied opacity.

src/textual/renderables/tint.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from rich.style import Style
88
from rich.terminal_theme import TerminalTheme
99

10-
from textual.color import Color
10+
from textual.color import TRANSPARENT, Color
1111
from textual.filter import ANSIToTruecolor
1212

1313

@@ -30,14 +30,19 @@ def __init__(
3030

3131
@classmethod
3232
def process_segments(
33-
cls, segments: Iterable[Segment], color: Color, ansi_theme: TerminalTheme
33+
cls,
34+
segments: Iterable[Segment],
35+
color: Color,
36+
ansi_theme: TerminalTheme,
37+
background: Color = TRANSPARENT,
3438
) -> Iterable[Segment]:
3539
"""Apply tint to segments.
3640
3741
Args:
3842
segments: Incoming segments.
3943
color: Color of tint.
4044
ansi_theme: The TerminalTheme defining how to map ansi colors to hex.
45+
background: Background color.
4146
4247
Returns:
4348
Segments with applied tint.
@@ -54,7 +59,11 @@ def process_segments(
5459
if control:
5560
yield segment
5661
else:
57-
style = truecolor_style(style) if style is not None else NULL_STYLE
62+
style = (
63+
truecolor_style(style, background)
64+
if style is not None
65+
else NULL_STYLE
66+
)
5867
yield _Segment(
5968
text,
6069
(

tests/snapshot_tests/__snapshots__/test_snapshots/test_ansi_color_mapping[textual-dark].svg

Lines changed: 68 additions & 68 deletions
Loading

tests/snapshot_tests/__snapshots__/test_snapshots/test_ansi_color_mapping[textual-light].svg

Lines changed: 70 additions & 70 deletions
Loading

tests/snapshot_tests/__snapshots__/test_snapshots/test_disable_command_palette.svg

Lines changed: 2 additions & 2 deletions
Loading

tests/snapshot_tests/__snapshots__/test_snapshots/test_dynamic_bindings.svg

Lines changed: 59 additions & 59 deletions
Loading

tests/snapshot_tests/__snapshots__/test_snapshots/test_example_markdown.svg

Lines changed: 3 additions & 3 deletions
Loading

0 commit comments

Comments
 (0)