MCPcopy
hub / github.com/Textualize/rich / append_text

Method append_text

rich/text.py:1008–1028  ·  rich/text.py::Text.append_text

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")

Source from the content-addressed store, hash-verified

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]]]

Callers 3

test_append_textFunction · 0.95
on_textMethod · 0.80

Calls 3

appendMethod · 0.45
extendMethod · 0.45
copyMethod · 0.45

Tested by 2

test_append_textFunction · 0.76