LavaUI docs GitHub

struct HighlightRule

Swift

struct HighlightRule

A pattern-to-style mapping, applied per line.

Styles are indices, not colours: LavaText has no colour type and should not grow one. The view owns a palette and resolves indices against it, which also means a theme swap restyles code without touching rules.

Sources/LavaText/Highlighting.swift:8

Constructors

init(pattern: String, styleIndex: Int, priority: Int = 0)

Creates a rule.

Sources/LavaText/Highlighting.swift:19

Properties

var pattern: String

A regular expression (NSRegularExpression syntax) matched against each line. An invalid pattern is dropped, costing only its own highlighting.

Sources/LavaText/Highlighting.swift:11

var priority: Int

Higher wins where spans overlap. Keywords should outrank identifiers; comments and strings should outrank both.

Sources/LavaText/Highlighting.swift:16

var styleIndex: Int

Which palette entry colours the matched text.

Sources/LavaText/Highlighting.swift:13