Method: rich.align.VerticalCenter.__rich_console__
Calls: 1, Exceptions: 0, Paths: 1Back
Path 1: 1 calls (1.0)
Console (1)
ConsoleOptions (1)
Segment (12) None (1)
1def __rich_console__(
2 self, console: "Console", options: "ConsoleOptions"
3 ) -> "RenderResult":
4 style = console.get_style(self.style) if self.style is not None else None
5 lines = console.render_lines(
6 self.renderable, options.update(height=None), pad=False
7 )
8 width, _height = Segment.get_shape(lines)
9 new_line = Segment.line()
10 height = options.height or options.size.height
11 top_space = (height - len(lines)) // 2
12 bottom_space = height - top_space - len(lines)
13 blank_line = Segment(f"{' ' * width}", style)
14
15 def blank_lines(count: int) -> Iterable[Segment]:
16 for _ in range(count):
17 yield blank_line
18 yield new_line
19
20 if top_space > 0:
21 yield from blank_lines(top_space)
22 for line in lines:
23 yield from line
24 yield new_line
25 if bottom_space > 0:
26 yield from blank_lines(bottom_space)