Get the style of a character at give offset. Args: console (~Console): Console where text will be rendered. offset (int): Offset in to text (negative indexing supported) Returns: Style: A Style instance.
(self, console: "Console", offset: int)
| 550 | self.right_crop(len(suffix)) |
| 551 | |
| 552 | def get_style_at_offset(self, console: "Console", offset: int) -> Style: |
| 553 | """Get the style of a character at give offset. |
| 554 | |
| 555 | Args: |
| 556 | console (~Console): Console where text will be rendered. |
| 557 | offset (int): Offset in to text (negative indexing supported) |
| 558 | |
| 559 | Returns: |
| 560 | Style: A Style instance. |
| 561 | """ |
| 562 | # TODO: This is a little inefficient, it is only used by full justify |
| 563 | if offset < 0: |
| 564 | offset = len(self) + offset |
| 565 | get_style = console.get_style |
| 566 | style = get_style(self.style).copy() |
| 567 | for start, end, span_style in self._spans: |
| 568 | if end > offset >= start: |
| 569 | style += get_style(span_style, default="") |
| 570 | return style |
| 571 | |
| 572 | def extend_style(self, spaces: int) -> None: |
| 573 | """Extend the Text given number of spaces where the spaces have the same style as the last character. |