Skip to content

Commit bd20c04

Browse files
authored
Merge pull request #4138 from Textualize/ansi-fix
always perform ansi filter
2 parents 7c7dec0 + 718f698 commit bd20c04

File tree

6 files changed

+580
-595
lines changed

6 files changed

+580
-595
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## Unreleased
8+
## [0.49.1] - 2023-02-08
99

1010
### Fixed
1111

12+
- Fixed issue with ANSI colors not being converted to truecolor https://github.com/Textualize/textual/pull/4138
1213
- Fixed duplicate watch methods being attached to DOM nodes https://github.com/Textualize/textual/pull/4030
1314
- Fixed using `watch` to create additional watchers would trigger other watch methods https://github.com/Textualize/textual/issues/3878
1415

@@ -1671,6 +1672,7 @@ https://textual.textualize.io/blog/2022/11/08/version-040/#version-040
16711672
- New handler system for messages that doesn't require inheritance
16721673
- Improved traceback handling
16731674

1675+
[0.49.1]: https://github.com/Textualize/textual/compare/v0.49.0...v0.49.1
16741676
[0.49.0]: https://github.com/Textualize/textual/compare/v0.48.2...v0.49.0
16751677
[0.48.2]: https://github.com/Textualize/textual/compare/v0.48.1...v0.48.2
16761678
[0.48.1]: https://github.com/Textualize/textual/compare/v0.48.0...v0.48.1

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "textual"
3-
version = "0.49.0"
3+
version = "0.49.1"
44
homepage = "https://github.com/Textualize/textual"
55
repository = "https://github.com/Textualize/textual"
66
documentation = "https://textual.textualize.io/"

src/textual/app.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
from .errors import NoWidget
9595
from .features import FeatureFlag, parse_features
9696
from .file_monitor import FileMonitor
97+
from .filter import ANSIToTruecolor, DimFilter, Monochrome
9798
from .geometry import Offset, Region, Size
9899
from .keys import (
99100
REPLACED_KEYS,
@@ -420,21 +421,17 @@ def __init__(
420421
super().__init__()
421422
self.features: frozenset[FeatureFlag] = parse_features(os.getenv("TEXTUAL", ""))
422423

423-
self._filters: list[LineFilter] = []
424+
self._filters: list[LineFilter] = [
425+
ANSIToTruecolor(terminal_theme.DIMMED_MONOKAI)
426+
]
424427
environ = dict(os.environ)
425428
no_color = environ.pop("NO_COLOR", None)
426429
if no_color is not None:
427-
from .filter import ANSIToTruecolor, Monochrome
428-
429-
self._filters.append(ANSIToTruecolor(terminal_theme.DIMMED_MONOKAI))
430430
self._filters.append(Monochrome())
431431

432432
for filter_name in constants.FILTERS.split(","):
433433
filter = filter_name.lower().strip()
434434
if filter == "dim":
435-
from .filter import ANSIToTruecolor, DimFilter
436-
437-
self._filters.append(ANSIToTruecolor(terminal_theme.DIMMED_MONOKAI))
438435
self._filters.append(DimFilter())
439436

440437
self.console = Console(

src/textual/renderables/background_screen.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
from typing import TYPE_CHECKING, Iterable
44

5-
from rich import terminal_theme
65
from rich.console import Console, ConsoleOptions, RenderResult
76
from rich.segment import Segment
87
from rich.style import Style
98

109
from ..color import Color
11-
from ..filter import ANSIToTruecolor
1210

1311
if TYPE_CHECKING:
1412
from ..screen import Screen
@@ -51,17 +49,13 @@ def process_segments(
5149
_Segment = Segment
5250

5351
NULL_STYLE = Style()
54-
truecolor_style = ANSIToTruecolor(terminal_theme.DIMMED_MONOKAI).truecolor_style
52+
5553
for segment in segments:
5654
text, style, control = segment
5755
if control:
5856
yield segment
5957
else:
60-
style = (
61-
NULL_STYLE
62-
if style is None
63-
else truecolor_style(style.clear_meta_and_links())
64-
)
58+
style = NULL_STYLE if style is None else style.clear_meta_and_links()
6559
yield _Segment(
6660
text,
6761
(

src/textual/renderables/tint.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
from typing import Iterable
44

5-
from rich import terminal_theme
65
from rich.console import Console, ConsoleOptions, RenderableType, RenderResult
76
from rich.segment import Segment
87
from rich.style import Style
98

109
from ..color import Color
11-
from ..filter import ANSIToTruecolor
1210

1311

1412
class Tint:
@@ -45,19 +43,13 @@ def process_segments(
4543
style_from_color = Style.from_color
4644
_Segment = Segment
4745

48-
ansi_filter = ANSIToTruecolor(terminal_theme.DIMMED_MONOKAI)
49-
5046
NULL_STYLE = Style()
5147
for segment in segments:
5248
text, style, control = segment
5349
if control:
5450
yield segment
5551
else:
56-
style = (
57-
ansi_filter.truecolor_style(style)
58-
if style is not None
59-
else NULL_STYLE
60-
)
52+
style = style if style is not None else NULL_STYLE
6153
yield _Segment(
6254
text,
6355
(

tests/snapshot_tests/__snapshots__/test_snapshots.ambr

Lines changed: 569 additions & 569 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)