SyntaxColoring

class SyntaxColoring(codeArea: CodeArea, delay: Duration = DEFAULT_UPDATE_DELAY, operators: OperatorSet = OperatorSet.DEFAULT, executor: ExecutorService = ForkJoinPool.commonPool())

Regex-based Prolog syntax highlighter for a RichTextFX CodeArea, as used by FileTabView for the editor pane.

It recognizes comments, string/quoted-atom literals, numbers (integer, float, hex/octal/binary, character codes), parentheses/braces/brackets, clause-terminating full stops, variables, functors, plain atoms, and (via operators) the current OperatorSet's functors as keywords, then applies a JavaFX CSS style class per matched token (see the stylesheets in Resources) using RichTextFX's org.fxmisc.richtext.model.StyleSpans.

A single regex combining all token patterns is built lazily and cached; it is invalidated and rebuilt whenever operators is reassigned, so that keywords stay in sync with the theory currently loaded into the solver (see FileTabView.notifyOperators).

Example:

val coloring = SyntaxColoring(codeArea)
coloring.activate() // highlights on every edit, debounced by `delay`

Constructors

Link copied to clipboard
constructor(codeArea: CodeArea, delay: Duration = DEFAULT_UPDATE_DELAY, operators: OperatorSet = OperatorSet.DEFAULT, executor: ExecutorService = ForkJoinPool.commonPool())

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

How long to wait, after the user stops editing codeArea, before recomputing the highlighting; see activate.

Link copied to clipboard

Whether activate has been called without a matching deactivate yet.

Link copied to clipboard

The OperatorSet whose functors are highlighted as keywords; reassigning it invalidates the cached pattern.

Functions

Link copied to clipboard

Starts observing codeArea for edits, recomputing and applying highlighting (on executor, debounced by delay) after each burst of changes settles.

Link copied to clipboard

Synchronously recomputes and applies highlighting for codeArea's current text, bypassing delay.

Link copied to clipboard

Stops observing codeArea for edits (undoing activate); does not clear any highlighting already applied.