Package org.jline.builtins
Class SyntaxHighlighter
java.lang.Object
org.jline.builtins.SyntaxHighlighter
Java implementation of a syntax highlighter based on nanorc format.
This class provides syntax highlighting capabilities for JLine applications, using configuration files in a format similar to GNU nano's nanorc files. It supports:
- Regular expression based highlighting rules
- Theme-based styling
- File type detection
- Inclusion of other configuration files
The highlighter can be used to add syntax coloring to various text displays in terminal applications, such as file viewers, editors, and REPLs.
- Author:
- Matti Rinta-Nikkola
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidstatic SyntaxHighlighterBuild SyntaxHighlighterstatic SyntaxHighlighterBuild SyntaxHighlighterprotected static SyntaxHighlighterprotected static SyntaxHighlighterorg.jline.utils.AttributedStringorg.jline.utils.AttributedStringhighlight(org.jline.utils.AttributedString attributedString) org.jline.utils.AttributedStringhighlight(org.jline.utils.AttributedStringBuilder asb) protected static voidnanorcInclude(Path nanorc, String parameter, List<Path> syntaxFiles) protected static voidnanorcTheme(Path nanorc, String parameter, List<Path> syntaxFiles) voidrefresh()reset()voidsetCurrentTheme(Path currentTheme) voidsetParser(org.jline.builtins.SyntaxHighlighter.Parser parser)
-
Field Details
-
REGEX_TOKEN_NAME
- See Also:
-
TYPE_NANORCTHEME
- See Also:
-
DEFAULT_NANORC_FILE
- See Also:
-
DEFAULT_LESSRC_FILE
- See Also:
-
COMMAND_INCLUDE
- See Also:
-
COMMAND_THEME
- See Also:
-
-
Method Details
-
build
-
build
protected static SyntaxHighlighter build(List<Path> syntaxFiles, String file, String syntaxName, boolean ignoreErrors) -
build
Build SyntaxHighlighter- Parameters:
nanorc- Path of nano config file jnanorcsyntaxName- syntax name e.g 'Java'- Returns:
- SyntaxHighlighter
-
nanorcInclude
protected static void nanorcInclude(Path nanorc, String parameter, List<Path> syntaxFiles) throws IOException - Throws:
IOException
-
nanorcTheme
protected static void nanorcTheme(Path nanorc, String parameter, List<Path> syntaxFiles) throws IOException - Throws:
IOException
-
addFiles
protected static void addFiles(Path nanorc, String parameter, Consumer<Stream<Path>> consumer) throws IOException - Throws:
IOException
-
build
Build SyntaxHighlighterThis method builds a SyntaxHighlighter from a URL or classpath resource. The URL can be a file URL, an HTTP URL, or a classpath resource URL.
For classpath resources, use the "classpath:" prefix followed by the resource path. For example: "classpath:/nano/jnanorc"
- Parameters:
nanorcUrl- URL or classpath resource path of nanorc file- Returns:
- SyntaxHighlighter
-
setCurrentTheme
-
getCurrentTheme
-
setParser
public void setParser(org.jline.builtins.SyntaxHighlighter.Parser parser) -
reset
-
refresh
public void refresh() -
highlight
-
highlight
public org.jline.utils.AttributedString highlight(org.jline.utils.AttributedStringBuilder asb) -
highlight
public org.jline.utils.AttributedString highlight(org.jline.utils.AttributedString attributedString)
-