MCPcopy
hub / github.com/Textualize/textual / append

Method append

src/textual/content.py:895–917  ·  view source on GitHub ↗

Append text or content to this content. Note this is a little inefficient, if you have many strings to append, consider [`join`][textual.content.Content.join]. Args: content: A content instance, or a string. Returns: New content.

(self, content: Content | str)

Source from the content-addressed store, hash-verified

893 return spans
894
895 def append(self, content: Content | str) -> Content:
896 """Append text or content to this content.
897
898 Note this is a little inefficient, if you have many strings to append, consider [`join`][textual.content.Content.join].
899
900 Args:
901 content: A content instance, or a string.
902
903 Returns:
904 New content.
905 """
906 if isinstance(content, str):
907 return Content(
908 f"{self.plain}{content}",
909 self._spans,
910 (
911 None
912 if self._cell_length is None
913 else self._cell_length + cell_len(content)
914 ),
915 strip_control_codes=False,
916 )
917 return EMPTY_CONTENT.join([self, content])
918
919 def append_text(self, text: str, style: Style | str = "") -> Content:
920 """Append text give as a string, with an optional style.

Callers 15

append_textMethod · 0.95
_matchMethod · 0.45
get_offsetsMethod · 0.45
put_nowaitMethod · 0.45
subscribeMethod · 0.45
decoratorFunction · 0.45
highlightFunction · 0.45
_appendMethod · 0.45
_css_basesMethod · 0.45
_merge_bindingsMethod · 0.45
_get_default_cssMethod · 0.45
css_identifierMethod · 0.45

Calls 2

ContentClass · 0.70
joinMethod · 0.45

Tested by 15

get_content_lineFunction · 0.36
action_recordMethod · 0.36
on_keyMethod · 0.36
on_label_clickedMethod · 0.36
refreshMethod · 0.36
action_registerMethod · 0.36
test_taskFunction · 0.36
watch_first_nameMethod · 0.36
watch_last_nameMethod · 0.36
validate_countMethod · 0.36
watch_countMethod · 0.36