diff options
Diffstat (limited to 'libs/rich/live_render.py')
-rw-r--r-- | libs/rich/live_render.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/libs/rich/live_render.py b/libs/rich/live_render.py index 4294b9923..f6fa7b2da 100644 --- a/libs/rich/live_render.py +++ b/libs/rich/live_render.py @@ -1,7 +1,11 @@ -from threading import RLock +import sys from typing import Optional, Tuple -from typing_extensions import Literal +if sys.version_info >= (3, 8): + from typing import Literal +else: + from typing_extensions import Literal # pragma: no cover + from ._loop import loop_last from .console import Console, ConsoleOptions, RenderableType, RenderResult @@ -80,16 +84,15 @@ class LiveRender: ) -> RenderResult: renderable = self.renderable - _Segment = Segment style = console.get_style(self.style) lines = console.render_lines(renderable, options, style=style, pad=False) - shape = _Segment.get_shape(lines) + shape = Segment.get_shape(lines) _, height = shape if height > options.size.height: if self.vertical_overflow == "crop": lines = lines[: options.size.height] - shape = _Segment.get_shape(lines) + shape = Segment.get_shape(lines) elif self.vertical_overflow == "ellipsis": lines = lines[: (options.size.height - 1)] overflow_text = Text( @@ -100,10 +103,11 @@ class LiveRender: style="live.ellipsis", ) lines.append(list(console.render(overflow_text))) - shape = _Segment.get_shape(lines) + shape = Segment.get_shape(lines) self._shape = shape + new_line = Segment.line() for last, line in loop_last(lines): yield from line if not last: - yield _Segment.line() + yield new_line |