DecorationStyle

The look of a decoration in layer. A decoration is a view of the text, not part of it: it never enters the undo history or the edit stream, a copy, a drag, the saved state or an export, and adding or removing one lays out no line. It moves with the text as edits are made around and inside it until its owner replaces it; undo does not bring back one an edit removed.

It paints the text under it in textColor, fills behind it in drawBackground and draws over it in drawCustomStyle. Implement this to carry data a click can read (as spell check's styles carry suggestions), or use Decoration. A decoration must stay one: isDecoration true, and none of the line-shaping properties of RichSpanStyle set (stickyAtStart, reshapesLine, boundToParagraph, a block's height).

Inheritors

Properties

Link copied to clipboard

Whether a span of this style belongs to one paragraph: it covers its line and no other, an Enter at the paragraph's start or end carries a copy onto the new paragraph (an Enter inside it splits it), and a multi-line insert inside it keeps it on its own line; one at the paragraph's start keeps it on the first line and the paragraph's own text after the last. A paragraph's format is one; a block marker is not, since the block behavior continues it with its indent.

Link copied to clipboard
open override val isDecoration: Boolean

Whether a span of this style is an ephemeral view overlay rather than a change to the document's content. Content spans (highlight, link, horizontal rule, lists: the things that round-trip through markdown) default to false. Decorations painted by the editor itself (spell-check underlines, transient find highlights) override this to true.

Link copied to clipboard

Whether TextEditorState.findSpanAtPosition, and so a click, can find a span of this style. Default true, which spell check's decorations rely on to answer clicks. A span that only tints, like a find highlight, returns false, so a click inside it answers to the spans it covers instead, such as its line's list or quote marker.

Link copied to clipboard

Whether this span style is a list item's, bullet or ordered, at any level.

Link copied to clipboard
abstract val layer: DecorationLayer
Link copied to clipboard

This list span style's nesting level, or null for a style that is not a list's.

Link copied to clipboard

Whether adding or removing a span of this style changes how its line is shaped.

Link copied to clipboard

If true, an insert at the span's exact start boundary keeps start put (greedy-at-start) so the new text lands inside the span. Default false means standard text-span semantics — typing before a link doesn't extend the link backward, etc. Line-anchored gutter markers (bullet, blockquote) override this to true: they should track the whole line through edits, so an insert at column 0 of an empty bullet line must absorb the new character rather than push the span off the end.

Link copied to clipboard
open val textColor: Color

The colour the text under the decoration is painted in; Color.Unspecified leaves it. The text is tinted when drawn, never shaped again, so colouring a whole file costs no layout. The tint wins over a colour the text has of its own; colour glyphs (emoji), and text a span style gives a background (inline code), keep theirs. Where two decorations colour the same text, the one drawn last wins, and the order between layers is not defined.

Functions

Link copied to clipboard
open fun DrawScope.drawBackground(layoutResult: TextLayoutResult, lineWrap: LineWrap, textRange: TextRange, state: TextEditorState)

Paints behind the text — runs BEFORE drawText for the line, so opaque fills don't obscure the text on top. Default no-op; styles that want a transparent decoration over the text should keep using drawCustomStyle.

Link copied to clipboard
open override fun DrawScope.drawCustomStyle(layoutResult: TextLayoutResult, lineWrap: LineWrap, textRange: TextRange, state: TextEditorState)

Paints the span's decoration. Runs AFTER drawText for the line, so anything painted here overlays the text — good for foreground glyphs (bullet dots, ordered numerals), bars, borders, and underlines, but the caller must use translucent fills or the text will be obscured.