Class SystemHighlighter

  • All Implemented Interfaces:
    Highlighter

    public class SystemHighlighter
    extends DefaultHighlighter
    Highlighter implementation that provides syntax highlighting for commands and languages.

    SystemHighlighter extends DefaultHighlighter to provide syntax highlighting for:

    • Command syntax (command names, options, arguments)
    • Programming language syntax (for various languages)
    • File content based on file extensions

    The highlighter uses nanorc syntax definitions for highlighting, making it compatible with existing nanorc configuration files. It can be customized with different styles and supports dynamic refreshing of highlighting rules.

    • Method Detail

      • setSpecificHighlighter

        public void setSpecificHighlighter​(java.lang.String command,
                                           SyntaxHighlighter highlighter)
      • refresh

        public void refresh​(LineReader lineReader)
        Description copied from interface: Highlighter
        Refreshes the highlighter's configuration.

        This method is called when the highlighter should reload or refresh its configuration, such as when color schemes change or when syntax rules are updated. The default implementation does nothing.

        Parameters:
        lineReader - The LineReader instance associated with this highlighter
      • addExternalHighlighterRefresh

        public void addExternalHighlighterRefresh​(java.util.function.Supplier<java.lang.Boolean> refresh)
      • highlight

        public AttributedString highlight​(LineReader reader,
                                          java.lang.String buffer)
        Description copied from interface: Highlighter
        Highlights the provided text buffer with appropriate styling.

        This method is called by the LineReader to apply syntax highlighting to the current input line. It should analyze the buffer content and return an AttributedString with appropriate styling applied based on the content's syntax, structure, or other relevant characteristics.

        Specified by:
        highlight in interface Highlighter
        Overrides:
        highlight in class DefaultHighlighter
        Parameters:
        reader - The LineReader instance requesting highlighting
        buffer - The text buffer to be highlighted
        Returns:
        An AttributedString containing the highlighted buffer with styling applied
      • addFileHighlight

        public void addFileHighlight​(java.lang.String... commands)
      • addFileHighlight

        public void addFileHighlight​(java.lang.String command,
                                     java.lang.String subcommand,
                                     java.util.Collection<java.lang.String> fileOptions)
      • doCommandHighlight

        protected AttributedString doCommandHighlight​(java.lang.String buffer)