diff --git a/sandbox/basic.css b/sandbox/basic.css index 439778337..5918ed2be 100644 --- a/sandbox/basic.css +++ b/sandbox/basic.css @@ -104,7 +104,7 @@ Tweet { .code { - height: 34; + height: auto; } diff --git a/sandbox/basic.py b/sandbox/basic.py index 65a829fda..22f701fb1 100644 --- a/sandbox/basic.py +++ b/sandbox/basic.py @@ -109,7 +109,10 @@ class BasicApp(App, css_path="basic.css"): content=Widget( Tweet(TweetBody()), Widget( - Static(Syntax(CODE, "python"), classes="code"), + Static( + Syntax(CODE, "python", line_numbers=True, indent_guides=True), + classes="code", + ), classes="scrollable", ), Error(), diff --git a/src/textual/widget.py b/src/textual/widget.py index 1eb0008c8..0de79ac93 100644 --- a/src/textual/widget.py +++ b/src/textual/widget.py @@ -72,9 +72,10 @@ class Widget(DOMNode): scrollbar-background: $panel-darken-2; scrollbar-background-hover: $panel-darken-3; scrollbar-color: $system; - scrollbar-color-active: $accent-darken-1; + scrollbar-color-active: $accent-darken-1; scrollbar-size-vertical: 2; scrollbar-size-horizontal: 1; + } """ diff --git a/tests/test_segment_tools.py b/tests/test_segment_tools.py index 6c29ea613..15347dcd6 100644 --- a/tests/test_segment_tools.py +++ b/tests/test_segment_tools.py @@ -12,9 +12,10 @@ def test_line_crop(): Segment("Hello", bold), Segment(" World!", italic), ] + total = sum(segment.cell_length for segment in segments) - assert line_crop(segments, 1, 2) == [Segment("e", bold)] - assert line_crop(segments, 4, 20) == [ + assert line_crop(segments, 1, 2, total) == [Segment("e", bold)] + assert line_crop(segments, 4, 20, total) == [ Segment("o", bold), Segment(" World!", italic), ] @@ -27,16 +28,23 @@ def test_line_crop_emoji(): Segment("Hello", bold), Segment("💩💩💩", italic), ] - assert line_crop(segments, 8, 11) == [Segment(" 💩", italic)] - assert line_crop(segments, 9, 11) == [Segment("💩", italic)] + total = sum(segment.cell_length for segment in segments) + assert line_crop(segments, 8, 11, total) == [Segment(" 💩", italic)] + assert line_crop(segments, 9, 11, total) == [Segment("💩", italic)] def test_line_crop_edge(): segments = [Segment("foo"), Segment("bar"), Segment("baz")] - assert line_crop(segments, 2, 9) == [Segment("o"), Segment("bar"), Segment("baz")] - assert line_crop(segments, 3, 9) == [Segment("bar"), Segment("baz")] - assert line_crop(segments, 4, 9) == [Segment("ar"), Segment("baz")] - assert line_crop(segments, 4, 8) == [Segment("ar"), Segment("ba")] + total = sum(segment.cell_length for segment in segments) + + assert line_crop(segments, 2, 9, total) == [ + Segment("o"), + Segment("bar"), + Segment("baz"), + ] + assert line_crop(segments, 3, 9, total) == [Segment("bar"), Segment("baz")] + assert line_crop(segments, 4, 9, total) == [Segment("ar"), Segment("baz")] + assert line_crop(segments, 4, 8, total) == [Segment("ar"), Segment("ba")] def test_line_crop_edge_2(): @@ -49,7 +57,8 @@ def test_line_crop_edge_2(): "─╮", ), ] - result = line_crop(segments, 30, 60) + total = sum(segment.cell_length for segment in segments) + result = line_crop(segments, 30, 60, total) expected = [] print(repr(result)) assert result == expected