java.lang.Object
org.jline.shell.impl.CommandHighlighter
- All Implemented Interfaces:
org.jline.reader.Highlighter
Command-aware syntax highlighter for the shell.
Highlights the first word of the command line based on whether it is a known command in the dispatcher:
- Known commands are highlighted in bold
- Unknown commands are highlighted in red
- Pipeline operators (
|,&&,||,;, etc.) are highlighted in cyan
An optional delegate Highlighter can be provided for composability.
If provided, the delegate is called first, then command highlighting is applied
on top.
- Since:
- 4.0
-
Constructor Summary
ConstructorsConstructorDescriptionCommandHighlighter(CommandDispatcher dispatcher) Creates a command highlighter with no delegate.CommandHighlighter(CommandDispatcher dispatcher, org.jline.reader.Highlighter delegate) Creates a command highlighter with an optional delegate. -
Method Summary
Modifier and TypeMethodDescriptionorg.jline.utils.AttributedStringvoidsetErrorIndex(int errorIndex) voidsetErrorPattern(Pattern errorPattern) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jline.reader.Highlighter
refresh
-
Constructor Details
-
CommandHighlighter
Creates a command highlighter with no delegate.- Parameters:
dispatcher- the command dispatcher for command lookup
-
CommandHighlighter
Creates a command highlighter with an optional delegate.When a delegate is provided, it is used to highlight the buffer first, and then command-specific highlighting is applied on top.
- Parameters:
dispatcher- the command dispatcher for command lookupdelegate- the delegate highlighter, or null
-
-
Method Details
-
highlight
public org.jline.utils.AttributedString highlight(org.jline.reader.LineReader reader, String buffer) - Specified by:
highlightin interfaceorg.jline.reader.Highlighter
-
setErrorPattern
- Specified by:
setErrorPatternin interfaceorg.jline.reader.Highlighter
-
setErrorIndex
public void setErrorIndex(int errorIndex) - Specified by:
setErrorIndexin interfaceorg.jline.reader.Highlighter
-