-
Notifications
You must be signed in to change notification settings - Fork 217
Highlighting and parsing
The LineReader
can be given an implementation of the Highlighter and Parser interfaces which are responsible for highlightning and parsing of the command line.
DefaultHighlighter is JLine provided implementation of Highlighter
interface.
SyntaxHighlighter is a JLine implementation of nanorc syntax highlighter that works with standard nanorc syntaxfiles.
JLine supported keywords: the syntax, color, and icolor are used to define syntax highlighting rules for different text patterns. Other nanorc keywords are quietly ignored.
To the commands color and icolor first parameter has been added style field.
color fgcolor,bgcolor,style ...
Fields fgcolor and bgcolor defines foreground and background colors respectively. Valid color names are: white, black, blue, green, red, cyan, yellow, magenta, and normal -- where normal means the default foreground or background color. You may use the prefix bright for the foreground color to get a stronger highlight. If your terminal supports transparency, not specifying a bgcolor it will try to use a transparent background. Field style defines an additional style to the foreground text. Valid style names are blink, bold, conceal, faint, hidden, inverse, italic and underline.
SyntaxHighlighter
does not implement Highlighter
interface but it might be useful for implementing one or it can be just used to highlight command output and/or descriptions.
ConfigurationPath configPath = new ConfigurationPath(Paths.get("/pub/myApp"), // application-wide settings
Paths.get(System.getProperty("user.home"), ".myApp")); // user-specific settings
SyntaxHighlighter javaSyntax = SyntaxHighlighter.build(configPath.getConfig("jnanorc"), "Java");
AttributedString as = javaSyntax.highlight("public AttributedString highlight(String string)")