Class JLineConsole

java.lang.Object
org.python.core.PlainConsole
org.python.util.JLineConsole
All Implemented Interfaces:
Console

public class JLineConsole extends PlainConsole
This class uses JLine to provide readline like functionality to its console without requiring native readline support.
  • Field Details

    • reader

      public jline.console.ConsoleReader reader
      Main interface to JLine.
  • Constructor Details

    • JLineConsole

      public JLineConsole(String encoding)
      Construct an instance of the console class specifying the character encoding. This encoding must be one supported by the JVM.

      Most of the initialisation is deferred to the install() method so that any prior console can uninstall itself before we change system console settings and System.in.

      Parameters:
      encoding - name of a supported encoding or null for Charset.defaultCharset()
  • Method Details

    • install

      public void install()
      Complete initialization and (optionally) install a stream object with line-editing as the replacement for System.in.

      This implementation overrides that by setting System.in to a FilterInputStream object that wraps JLine, and System.out with a layer that buffers incomplete lines for use as the console prompt.

      Specified by:
      install in interface Console
      Overrides:
      install in class PlainConsole
    • getReader

      public jline.console.ConsoleReader getReader()
      Returns:
      the JLine console reader associated with this interpreter
    • getStartupHook

      public PyObject getStartupHook()
      Returns:
      the startup hook (called prior to each readline)
    • setStartupHook

      public void setStartupHook(PyObject hook)
      Sets the startup hook (called prior to each readline)