@CompileStatic
class GroovyPrinter
extends DefaultPrinter
A org.jline.console.impl.DefaultPrinter that resolves nanorc highlight-style names
case-insensitively.
JLine matches the /prnt -s STYLE value (and the
valueStyle/valueStyleAll options) against the
syntax "<NAME>" header of each nanorc grammar with a
case-sensitive String.equals (in
org.jline.builtins.SyntaxHighlighter), so -s json
would not match syntax "JSON".
Rather than blindly transforming the requested style (which would
break selecting a user's existing mixed-case grammars copied into
~/.groovy per the groovysh docs), this resolves the requested
name case-insensitively against the actually configured syntax
names — the same jnanorc org.jline.console.impl.DefaultPrinter itself
uses (user-config first, via org.jline.builtins.ConfigurationPath) plus the
grammars it includes. An exact match always wins; a unique
case-insensitive match is rewritten to the real name; an unknown or
an ambiguous name (where two grammars differ only by case)
is passed through untouched so JLine's own behaviour is preserved.
Discovery is failsafe per file and overall, the resolved set is
cached, and the cache is cleared on refresh() so a
/highlighter switch or a nanorc edit takes effect without a
restart.
| Constructor and description |
|---|
GroovyPrinter(ScriptEngine engine, ConfigurationPath configPath)Keeps configPath for nanorc lookup and passes the engine and
path through to org.jline.console.impl.DefaultPrinter. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
protected void |
highlightAndPrint(Map<String, Object> options, Throwable exception)Rewrites style names in options to the configured nanorc
spelling, then highlights exception. |
|
void |
println(Map<String, Object> options, Object object)Rewrites style names in options to the configured nanorc
spelling, then prints object. |
|
boolean |
refresh()Clears the cached syntax-name set before delegating, so a /highlighter theme switch or an edited/copied nanorc is
picked up on the next print rather than after a restart. |
Keeps configPath for nanorc lookup and passes the engine and
path through to org.jline.console.impl.DefaultPrinter.
Rewrites style names in options to the configured nanorc
spelling, then highlights exception.
Rewrites style names in options to the configured nanorc
spelling, then prints object.
Clears the cached syntax-name set before delegating, so a
/highlighter theme switch or an edited/copied nanorc is
picked up on the next print rather than after a restart.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.