Package org.python.util
Class JLineConsole
java.lang.Object
org.python.core.PlainConsole
org.python.util.JLineConsole
- All Implemented Interfaces:
Console
This class uses JLine to provide readline like
functionality to its console without requiring native readline support.
-
Field Summary
Fields inherited from class org.python.core.PlainConsole
encoding, encodingCharset
-
Constructor Summary
ConstructorDescriptionJLineConsole
(String encoding) Construct an instance of the console class specifying the character encoding. -
Method Summary
Modifier and TypeMethodDescriptionjline.console.ConsoleReader
void
install()
Complete initialization and (optionally) install a stream object with line-editing as the replacement forSystem.in
.void
setStartupHook
(PyObject hook) Sets the startup hook (called prior to each readline)Methods inherited from class org.python.core.PlainConsole
getEncoding, getEncodingCharset, uninstall
-
Field Details
-
reader
public jline.console.ConsoleReader readerMain interface to JLine.
-
-
Constructor Details
-
JLineConsole
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 andSystem.in
.- Parameters:
encoding
- name of a supported encoding ornull
forCharset.defaultCharset()
-
-
Method Details
-
install
public void install()Complete initialization and (optionally) install a stream object with line-editing as the replacement forSystem.in
.This implementation overrides that by setting
System.in
to aFilterInputStream
object that wraps JLine, andSystem.out
with a layer that buffers incomplete lines for use as the console prompt.- Specified by:
install
in interfaceConsole
- Overrides:
install
in classPlainConsole
-
getReader
public jline.console.ConsoleReader getReader()- Returns:
- the JLine console reader associated with this interpreter
-
getStartupHook
- Returns:
- the startup hook (called prior to each readline)
-
setStartupHook
Sets the startup hook (called prior to each readline)
-