TextContentBuilder

A utility class for building and manipulating textual content.

Provides methods for constructing formatted strings with features such as inserting text, adding new lines, and applying padding. The builder pattern supports a fluent and convenient approach to managing text content.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
data class Caret(val line: Int, val offset: Int)

Represents the position of a caret within a text document.

Properties

Link copied to clipboard

Represents the current caret position in the text being built.

Functions

Link copied to clipboard
fun br()

Adds two consecutive newline characters to the text content.

Link copied to clipboard
fun build(): String

Constructs and returns the accumulated textual content stored in the builder.

Link copied to clipboard
fun newline()

Appends a newline character to the underlying text builder.

Link copied to clipboard
operator fun String.not()

Defines a custom operator function for the String class. This unary not operator (!) is invoked on a String instance and performs a custom action defined by the text function.

Link copied to clipboard

Extension function for TextContentBuilder that adds line numbering to the content.

Link copied to clipboard
fun padding(padding: String, body: TextContentBuilder.() -> Unit)

Adds padding to each line of the content produced by the provided builder block.

Link copied to clipboard
fun text(text: String)

Appends the given text to the current content.

Link copied to clipboard

Adds the given text to the content. If the caret is not at the beginning of the line, a newline is added before appending the text.

Link copied to clipboard
open operator fun String.unaryPlus()

Adds the given string as a new line of text to the content being built by the TextContentBuilder.