Method
write(_:indent:)
Writes text to the buffer with optional automatic indentation.
func write(_ text: String, indent: Bool = true)
Parameters
text-
The text to write
indent-
Whether to apply indentation if at line start (default: true)
Discussion
If the writer is at the start of a line and indent is true, the current indentation is written before the text. The text is then appended to the buffer.
Example
let writer = MTLWriter(indentation: MTLIndentation(level: 1))
await writer.write("Hello") // " Hello"
await writer.write(" World") // " Hello World"
await writer.newLine()
await writer.write("Next", indent: false) // " Hello World\nNext" (no indent)