Method: rich.text.Text.append_text
Calls: 1, Exceptions: 0, Paths: 1Back
Path 1: 1 calls (1.0)
Text (1)
Text (1)
1def append_text(self, text: "Text") -> "Text":
2 """Append another Text instance. This method is more performant that Text.append, but
3 only works for Text.
4
5 Returns:
6 Text: Returns self for chaining.
7 """
8 _Span = Span
9 text_length = self._length
10 if text.style is not None:
11 self._spans.append(_Span(text_length, text_length + len(text), text.style))
12 self._text.append(text.plain)
13 self._spans.extend(
14 _Span(start + text_length, end + text_length, style)
15 for start, end, style in text._spans
16 )
17 self._length += len(text)
18 return self