RichTextBuffer

A buffer for safely mutating both text and attributes of a RichTextState within an edit block. This class provides attribute operations by delegating to RichStringScope and adds text operations like insert, delete, and replace.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun delete(range: IntRange)

Deletes the text within the specified range.

Link copied to clipboard
fun editAll(ranges: <Error class: unknown class><IntRange>, editAction: <Error class: unknown class>.() -> Unit)

Applies a set of attribute mutations to all specified ranges using a DSL builder.

fun <T : Any> editAll(runs: <Error class: unknown class><<Error class: unknown class><T>>, editAction: <Error class: unknown class>.(<Error class: unknown class><T>) -> Unit)

Applies a set of attribute mutations to all specified runs using a DSL builder. The editAction receives each RichRun to allow conditional logic based on existing attributes.

Link copied to clipboard
fun editAttributes(range: IntRange = 0 until textLength, editAction: <Error class: unknown class>.() -> Unit)

Applies a set of attribute mutations to the specified range using a DSL builder.

Link copied to clipboard
fun RichTextBuffer.editAttributes(selection: TextRange, editAction: <Error class: unknown class>.() -> Unit)

Applies a set of attribute mutations to the range specified by the given TextRange. This is a convenience overload that converts TextRange to IntRange.

Link copied to clipboard
fun insert(index: Int, text: String)

Inserts the given text at the specified index.

fun insert(index: Int, text: String, editAction: <Error class: unknown class>.() -> Unit)

Inserts the given text at the specified index and applies attributes to the inserted text atomically.

Link copied to clipboard
fun <T> removeParagraphAttribute(key: <Error class: unknown class><T>, range: IntRange = 0 until textLength)

Removes any paragraph attributes associated with the specified key within the given range. The range is automatically expanded to span the entire paragraphs (separated by \n) it intersects with.

Link copied to clipboard
fun <T> removeSpanAttribute(key: <Error class: unknown class><T>, range: IntRange = 0 until textLength)

Removes any character span attributes associated with the specified key within the given range.

Link copied to clipboard
fun replace(range: IntRange, text: String)

Replaces the text within the specified range with the new text.

fun replace(range: IntRange, text: String, editAction: <Error class: unknown class>.() -> Unit)

Replaces the text within the specified range with the new text and applies attributes to the newly inserted text atomically.

Link copied to clipboard
fun <T> setParagraphAttribute(key: <Error class: unknown class><T>, value: T, range: IntRange = 0 until textLength)

Applies the specified paragraph attribute key and value to the given range. The range is automatically expanded to span the entire paragraphs (separated by \n) it intersects with.

Link copied to clipboard
fun <T> setSpanAttribute(key: <Error class: unknown class><T>, value: T, range: IntRange = 0 until textLength)

Applies the specified character span attribute key and value to the given range. Any existing span attributes of the same key within this range are completely overwritten.