RichStringScope

class RichStringScope(currentSpans: List<RichSpan>, text: String)

A DSL scope used to safely mutate the attributes of a RichString within an edit block. All mutations are accumulated internally and used to produce a completely new, immutable RichString instance when the block completes.

Note: This scope does not mutate the text itself. It is scoped exclusively to attribute operations.

Constructors

Link copied to clipboard
constructor(currentSpans: List<RichSpan>, text: String)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
fun clearAllAttributes(range: IntRange = 0 until textLength)

Removes all attributes (both span and paragraph level) within the given range. Paragraph attributes will be cleared from their entire respective paragraphs.

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

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

fun <T : Any> editAll(runs: <Error class: unknown class><RichRun<T>>, editAction: AttributeEditScope.(RichRun<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: AttributeEditScope.() -> Unit)

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

Link copied to clipboard
fun <T> removeParagraphAttribute(key: ParagraphAttributeKey<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: SpanAttributeKey<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 <T> setParagraphAttribute(key: ParagraphAttributeKey<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: SpanAttributeKey<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.