Class SimpleRegexSyntaxHighlighter

    • Constructor Detail

      • SimpleRegexSyntaxHighlighter

        protected SimpleRegexSyntaxHighlighter​(java.lang.String languageName,
                                               SimpleRegexSyntaxHighlighter.RegexHighlightGrammar grammar)
        Creates a highlighter given a name for the language and a "regex grammar".
        Parameters:
        languageName - The language name
        grammar - The grammar
    • Method Detail

      • computeHighlighting

        public org.fxmisc.richtext.model.StyleSpans<java.util.Collection<java.lang.String>> computeHighlighting​(java.lang.String text)
        Description copied from interface: SyntaxHighlighter
        Computes the syntax highlighting on the given text. The returned spans are exactly the length of the given text.
        Specified by:
        computeHighlighting in interface SyntaxHighlighter
        Parameters:
        text - The text
        Returns:
        The computed style spans
      • getLanguageTerseName

        public final java.lang.String getLanguageTerseName()
        Description copied from interface: SyntaxHighlighter
        Gets the terse name of the language this highlighter cares for. That's used as a css class for text regions.
        Specified by:
        getLanguageTerseName in interface SyntaxHighlighter
        Returns:
        The terse name of the language
      • alternation

        protected static java.lang.String alternation​(java.lang.String[] alternatives)
        Returns a regex alternation for the given words. The words must not begin with an escaped character.
        Parameters:
        alternatives - Words to join
      • asWord

        protected static java.lang.String asWord​(java.lang.String regex)
      • grammarBuilder

        protected static SimpleRegexSyntaxHighlighter.RegexHighlightGrammarBuilder grammarBuilder​(java.util.Collection<java.lang.String> cssClass,
                                                                                                  java.lang.String pattern)
        Gets a builder to make a grammar to build a highlighter.
        Parameters:
        cssClass - The css class of the first pattern
        pattern - The first pattern
        Returns:
        A builder