mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
implement dim fix (#2326)
* implement dim fix * docstrings * foreground fix * cached filters * cache default * fix for filter tests * docstring * optimization * Update src/textual/filter.py Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com> * Update src/textual/constants.py Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com> --------- Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
|
||||
from textual.color import Color
|
||||
from textual.filter import DimFilter
|
||||
|
||||
|
||||
@@ -11,7 +12,7 @@ def test_dim_apply():
|
||||
|
||||
segments = [Segment("Hello, World!", Style.parse("dim #ffffff on #0000ff"))]
|
||||
|
||||
dimmed_segments = dim_filter.apply(segments)
|
||||
dimmed_segments = dim_filter.apply(segments, Color(0, 0, 0))
|
||||
|
||||
expected = [Segment("Hello, World!", Style.parse("not dim #7f7fff on #0000ff"))]
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
|
||||
from textual._segment_tools import NoCellPositionForIndex
|
||||
from textual.color import Color
|
||||
from textual.filter import Monochrome
|
||||
from textual.strip import Strip
|
||||
|
||||
@@ -102,7 +103,7 @@ def test_apply_filter():
|
||||
expected = Strip([Segment("foo", Style.parse("#1b1b1b"))])
|
||||
print(repr(strip))
|
||||
print(repr(expected))
|
||||
assert strip.apply_filter(Monochrome()) == expected
|
||||
assert strip.apply_filter(Monochrome(), Color(0, 0, 0)) == expected
|
||||
|
||||
|
||||
def test_style_links():
|
||||
|
||||
Reference in New Issue
Block a user