adds Strip primitive

This commit is contained in:
Will McGugan
2022-12-26 18:06:35 +00:00
parent 87329b6d07
commit 6f82ad9c4a
11 changed files with 2294 additions and 2127 deletions

View File

@@ -4,13 +4,14 @@ from rich.segment import Segment
from rich.style import Style
from textual._styles_cache import StylesCache
from textual._types import Lines
from textual._types import Strips
from textual.color import Color
from textual.css.styles import Styles
from textual.geometry import Region, Size
from textual.strip import Strip
def _extract_content(lines: Lines):
def _extract_content(lines: Strips):
"""Extract the text content from lines."""
content = ["".join(segment.text for segment in line) for line in lines]
return content
@@ -44,10 +45,11 @@ def test_no_styles():
)
style = Style.from_color(bgcolor=Color.parse("green").rich_color)
expected = [
[Segment("foo", style)],
[Segment("bar", style)],
[Segment("baz", style)],
Strip([Segment("foo", style)], 3),
Strip([Segment("bar", style)], 3),
Strip([Segment("baz", style)], 3),
]
assert lines == expected