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 SyntaxHighlighterprotected final SyntaxHighlighterprotected intprotected final Map<String, SystemHighlighter.FileHighlightCommand> protected final SyntaxHighlighterprotected final Map<String, SyntaxHighlighter> protected final SystemRegistryFields inherited from class DefaultHighlighter
errorIndex, errorPattern -
Constructor Summary
ConstructorsConstructorDescriptionSystemHighlighter(SyntaxHighlighter commandHighlighter, SyntaxHighlighter argsHighlighter, SyntaxHighlighter langHighlighter) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExternalHighlighterRefresh(Supplier<Boolean> refresh) voidaddFileHighlight(String... commands) voidaddFileHighlight(String command, String subcommand, Collection<String> fileOptions) protected AttributedStringdoCommandHighlight(String buffer) protected AttributedStringdoFileArgsHighlight(LineReader reader, String buffer, List<String> words, SystemHighlighter.FileHighlightCommand fhc) protected AttributedStringdoFileOptsHighlight(LineReader reader, String buffer, List<String> words, SystemHighlighter.FileHighlightCommand fhc) highlight(LineReader reader, String buffer) Highlights the provided text buffer with appropriate styling.voidrefresh(LineReader lineReader) Refreshes the highlighter's configuration.voidsetSpecificHighlighter(String command, SyntaxHighlighter highlighter) protected AttributedStringsystemHighlight(LineReader reader, String buffer) Methods inherited from class 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:HighlighterRefreshes 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:HighlighterHighlights 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:
highlightin interfaceHighlighter- Overrides:
highlightin 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
-