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 void
static SyntaxHighlighter
Build SyntaxHighlighterstatic SyntaxHighlighter
Build SyntaxHighlighterprotected static SyntaxHighlighter
protected static SyntaxHighlighter
highlight
(AttributedString attributedString) protected static void
nanorcInclude
(Path nanorc, String parameter, List<Path> syntaxFiles) protected static void
nanorcTheme
(Path nanorc, String parameter, List<Path> syntaxFiles) void
refresh()
reset()
void
setCurrentTheme
(Path currentTheme) void
setParser
(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
-
highlight
-