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

Method write

src/textual/widgets/_markdown.py:78–93  ·  view source on GitHub ↗

Append or enqueue a markdown fragment. Args: markdown_fragment: A string to append at the end of the document.

(self, markdown_fragment: str)

Source from the content-addressed store, hash-verified

76 self._stopped = True
77
78 async def write(self, markdown_fragment: str) -> None:
79 """Append or enqueue a markdown fragment.
80
81 Args:
82 markdown_fragment: A string to append at the end of the document.
83 """
84 if self._stopped:
85 raise RuntimeError("Can't write to the stream after it has stopped.")
86 if not markdown_fragment:
87 # Nothing to do for empty strings.
88 return
89 # Append the new fragment, and set an event to tell the _run loop to wake up
90 self._pending.append(markdown_fragment)
91 self._new_markup.set()
92 # Allow the task to wake up and actually display the new markdown
93 await asyncio.sleep(0)
94
95 async def _run(self) -> None:
96 """Run a task to append markdown fragments when available."""

Callers

nothing calls this directly

Calls 3

sleepMethod · 0.80
appendMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected