Package groovy.console.ui

# Class ConsoleSupport

java.lang.Object
groovy.console.ui.ConsoleSupport

public abstract class ConsoleSupport extends Object
Base support class for consoles that evaluate Groovy scripts and render styled output.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ConsoleSupport()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `addStylesToDocument(JTextPane outputArea)`
  Initializes the styles used by the output document.
  `protected Object`
  `evaluate(String text)`
  Evaluates the supplied text and delegates failures to `handleException(String, Exception)`.
  `Style`
  `getCommandStyle()`
  Returns the style used for entered commands.
  `Style`
  `getOutputStyle()`
  Returns the style used for evaluated output.
  `Style`
  `getPromptStyle()`
  Returns the style used for prompts.
  `GroovyShell`
  `getShell()`
  Returns the shell used for script evaluation.
  `protected abstract void`
  `handleException(String text, Exception e)`
  Handles an exception raised while evaluating the supplied script text.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ConsoleSupport

    public ConsoleSupport()

- ## Method Details

  - ### addStylesToDocument

    protected void addStylesToDocument(JTextPane outputArea)
    Initializes the styles used by the output document.
    Parameters:
      `outputArea` - text pane whose styled document should be configured

  - ### getCommandStyle

    public Style getCommandStyle()
    Returns the style used for entered commands.
    Returns:
      the command style

  - ### getOutputStyle

    public Style getOutputStyle()
    Returns the style used for evaluated output.
    Returns:
      the output style

  - ### getPromptStyle

    public Style getPromptStyle()
    Returns the style used for prompts.
    Returns:
      the prompt style

  - ### getShell

    public GroovyShell getShell()
    Returns the shell used for script evaluation.
    Returns:
      the lazily created shell

  - ### evaluate

    protected Object evaluate(String text)
    Evaluates the supplied text and delegates failures to `handleException(String, Exception)`.
    Parameters:
      `text` - script text to evaluate
    Returns:
      the evaluation result, or `null` when evaluation fails

  - ### handleException

    protected abstract void handleException(String text, Exception e)
    Handles an exception raised while evaluating the supplied script text.
    Parameters:
      `text` - script text being evaluated
      `e` - exception raised during evaluation