SyntaxColoring
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
Properties
How long to wait, after the user stops editing codeArea, before recomputing the highlighting; see activate.
Whether activate has been called without a matching deactivate yet.
The OperatorSet whose functors are highlighted as keywords; reassigning it invalidates the cached pattern.
Functions
Starts observing codeArea for edits, recomputing and applying highlighting (on executor, debounced by delay) after each burst of changes settles.
Synchronously recomputes and applies highlighting for codeArea's current text, bypassing delay.
Stops observing codeArea for edits (undoing activate); does not clear any highlighting already applied.