Package groovy.console.ui
Class ConsoleSupport
java.lang.Object
groovy.console.ui.ConsoleSupport
Base support class for consoles that evaluate Groovy scripts and render styled output.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddStylesToDocument(JTextPane outputArea) Initializes the styles used by the output document.protected ObjectEvaluates the supplied text and delegates failures tohandleException(String, Exception).Returns the style used for entered commands.Returns the style used for evaluated output.Returns the style used for prompts.getShell()Returns the shell used for script evaluation.protected abstract voidhandleException(String text, Exception e) Handles an exception raised while evaluating the supplied script text.
-
Constructor Details
-
ConsoleSupport
public ConsoleSupport()
-
-
Method Details
-
addStylesToDocument
Initializes the styles used by the output document.- Parameters:
outputArea- text pane whose styled document should be configured
-
getCommandStyle
Returns the style used for entered commands.- Returns:
- the command style
-
getOutputStyle
Returns the style used for evaluated output.- Returns:
- the output style
-
getPromptStyle
Returns the style used for prompts.- Returns:
- the prompt style
-
getShell
Returns the shell used for script evaluation.- Returns:
- the lazily created shell
-
evaluate
Evaluates the supplied text and delegates failures tohandleException(String, Exception).- Parameters:
text- script text to evaluate- Returns:
- the evaluation result, or
nullwhen evaluation fails
-
handleException
Handles an exception raised while evaluating the supplied script text.- Parameters:
text- script text being evaluatede- exception raised during evaluation
-