Class SystemHighlighter
- All Implemented Interfaces:
Highlighter
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.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final SyntaxHighlighter
protected final SyntaxHighlighter
protected int
protected final Map
<String, SystemHighlighter.FileHighlightCommand> protected final SyntaxHighlighter
protected final Map
<String, SyntaxHighlighter> protected final SystemRegistry
Fields inherited from class org.jline.reader.impl.DefaultHighlighter
errorIndex, errorPattern
-
Constructor Summary
ConstructorsConstructorDescriptionSystemHighlighter
(SyntaxHighlighter commandHighlighter, SyntaxHighlighter argsHighlighter, SyntaxHighlighter langHighlighter) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addExternalHighlighterRefresh
(Supplier<Boolean> refresh) void
addFileHighlight
(String... commands) void
addFileHighlight
(String command, String subcommand, Collection<String> fileOptions) protected AttributedString
doCommandHighlight
(String buffer) protected AttributedString
doFileArgsHighlight
(LineReader reader, String buffer, List<String> words, SystemHighlighter.FileHighlightCommand fhc) protected AttributedString
doFileOptsHighlight
(LineReader reader, String buffer, List<String> words, SystemHighlighter.FileHighlightCommand fhc) highlight
(LineReader reader, String buffer) Highlights the provided text buffer with appropriate styling.void
refresh
(LineReader lineReader) Refreshes the highlighter's configuration.void
setSpecificHighlighter
(String command, SyntaxHighlighter highlighter) protected AttributedString
systemHighlight
(LineReader reader, String buffer) Methods inherited from class org.jline.reader.impl.DefaultHighlighter
commandStyle, setErrorIndex, setErrorPattern
-
Field Details
-
commandHighlighter
-
argsHighlighter
-
langHighlighter
-
systemRegistry
-
fileHighlight
-
specificHighlighter
-
commandIndex
protected int commandIndex
-
-
Constructor Details
-
SystemHighlighter
public SystemHighlighter(SyntaxHighlighter commandHighlighter, SyntaxHighlighter argsHighlighter, SyntaxHighlighter langHighlighter)
-
-
Method Details
-
setSpecificHighlighter
-
refresh
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
-
highlight
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 interfaceHighlighter
- Overrides:
highlight
in classDefaultHighlighter
- Parameters:
reader
- The LineReader instance requesting highlightingbuffer
- The text buffer to be highlighted- Returns:
- An AttributedString containing the highlighted buffer with styling applied
-
addFileHighlight
-
addFileHighlight
-
systemHighlight
-
doFileOptsHighlight
protected AttributedString doFileOptsHighlight(LineReader reader, String buffer, List<String> words, SystemHighlighter.FileHighlightCommand fhc) -
doFileArgsHighlight
protected AttributedString doFileArgsHighlight(LineReader reader, String buffer, List<String> words, SystemHighlighter.FileHighlightCommand fhc) -
doCommandHighlight
-