dim filter (#2323)

* dim filter

* optimization

* Remove test code

* move functions out of filter

* docstring

* move function to module scope

* docstring

* docstrings
This commit is contained in:
Will McGugan
2023-04-19 09:31:59 +01:00
committed by GitHub
parent 4981effcba
commit db1b784606
2 changed files with 144 additions and 25 deletions

18
tests/test_line_filter.py Normal file
View File

@@ -0,0 +1,18 @@
from rich.segment import Segment
from rich.style import Style
from textual.filter import DimFilter
def test_dim_apply():
"""Check dim filter changes color and resets dim attribute."""
dim_filter = DimFilter()
segments = [Segment("Hello, World!", Style.parse("dim #ffffff on #0000ff"))]
dimmed_segments = dim_filter.apply(segments)
expected = [Segment("Hello, World!", Style.parse("not dim #7f7fff on #0000ff"))]
assert dimmed_segments == expected