Lexer

io.worxbend.tui.widgets.Lexer
See theLexer companion object
trait Lexer

Turns one line of source into styled io.worxbend.tui.core.Spans — the open extension point behind SyntaxHighlighter, a Markdown fence and TextAreaOptions.lexer.

Highlighting is line-oriented, with a LexState carried from the end of one line to the start of the next: the three-argument highlightLine takes the state the previous line ended in and answers the state this one ends in, so a block comment, a triple-quoted string or a YAML block scalar that spans lines is highlighted on every line it covers. highlight threads it through a whole text, and so do a Markdown fence and a TextArea. The two-argument form lexes one line on its own, from LexState.Initial; a lexer that keeps no state implements only that one, and the stateful form defaults to it. The spans of the returned Line must concatenate back to line exactly — an editor maps them onto its grapheme clusters, and a lexer that drops or adds characters has its styling ignored there.

Implementations are immutable values and safe to share between threads; aliases are the lower-case info-string names ( ```yaml) a Markdown fence resolves through Lexer.among.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def aliases: Set[String]

Lower-case info-string names this lexer answers to.

Lower-case info-string names this lexer answers to.

Attributes

def highlightLine(line: String, theme: SyntaxTheme): Line

Highlights a single line of code on its own, as if it were the first line of a document.

Highlights a single line of code on its own, as if it were the first line of a document.

Attributes

def name: String

A short lower-case name, for diagnostics and documentation.

A short lower-case name, for diagnostics and documentation.

Attributes

Concrete methods

def highlight(code: String, theme: SyntaxTheme): Text

Highlights multi-line code, one Line per source line, carrying the LexState from line to line.

Highlights multi-line code, one Line per source line, carrying the LexState from line to line.

Attributes

def highlightLine(line: String, theme: SyntaxTheme, state: LexState): LexedLine

Highlights one line that begins in state — what the line before it ended in — and answers the line with the state it ends in. The default keeps no state: it lexes the line alone and always answers LexState.Initial.

Highlights one line that begins in state — what the line before it ended in — and answers the line with the state it ends in. The default keeps no state: it lexes the line alone and always answers LexState.Initial.

Attributes