Append another Text instance. This method is more performant than Text.append, but only works for Text. Args: text (Text): The Text instance to append to this instance. Returns: Text: Returns self for chaining.
(self, text: "Text")
| 1006 | return self |
| 1007 | |
| 1008 | def append_text(self, text: class="st">"Text") -> class="st">"Text": |
| 1009 | class="st">"""Append another Text instance. This method is more performant than Text.append, but |
| 1010 | only works for Text. |
| 1011 | |
| 1012 | Args: |
| 1013 | text (Text): The Text instance to append to this instance. |
| 1014 | |
| 1015 | Returns: |
| 1016 | Text: Returns self for chaining. |
| 1017 | class="st">""" |
| 1018 | _Span = Span |
| 1019 | text_length = self._length |
| 1020 | if text.style: |
| 1021 | self._spans.append(_Span(text_length, text_length + len(text), text.style)) |
| 1022 | self._text.append(text.plain) |
| 1023 | self._spans.extend( |
| 1024 | _Span(start + text_length, end + text_length, style) |
| 1025 | for start, end, style in text._spans.copy() |
| 1026 | ) |
| 1027 | self._length += len(text) |
| 1028 | return self |
| 1029 | |
| 1030 | def append_tokens( |
| 1031 | self, tokens: Iterable[Tuple[str, Optional[StyleType]]] |