public class WindowsTerminal extends TerminalSupport
init()
is accomplished by extracting the
jline_version.dll, saving it to the system temporary
directoy (determined by the setting of the java.io.tmpdir System
property), loading the library, and then calling the Win32 APIs SetConsoleMode and
GetConsoleMode to
disable character echoing.
By default, the wrapInIfNeeded(java.io.InputStream)
method will attempt
to test to see if the specified InputStream
is System.in
or a wrapper
around FileDescriptor.in
, and if so, will bypass the character reading to
directly invoke the readc() method in the JNI library. This is so the class
can read special keys (like arrow keys) which are otherwise inaccessible via
the System.in
stream. Using JNI reading can be bypassed by setting
the jline.WindowsTerminal.directConsole
system property
to false
.
Modifier and Type | Class and Description |
---|---|
static class |
WindowsTerminal.ConsoleMode
Console mode
Constants copied wincon.h.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ANSI |
static java.lang.String |
DIRECT_CONSOLE |
DEFAULT_HEIGHT, DEFAULT_WIDTH
Constructor and Description |
---|
WindowsTerminal() |
Modifier and Type | Method and Description |
---|---|
void |
disableInterruptCharacter() |
void |
enableInterruptCharacter() |
java.lang.Boolean |
getDirectConsole()
Whether or not to allow the use of the JNI console interaction.
|
int |
getHeight() |
java.lang.String |
getOutputEncoding() |
int |
getWidth() |
void |
init() |
protected boolean |
isSystemIn(java.io.InputStream in) |
void |
restore()
Restore the original terminal configuration, which can be used when
shutting down the console reader.
|
void |
setDirectConsole(boolean flag)
Whether or not to allow the use of the JNI console interaction.
|
void |
setEchoEnabled(boolean enabled) |
java.io.InputStream |
wrapInIfNeeded(java.io.InputStream in)
When using native support, return the InputStream to use for reading characters
else return the input stream passed as a parameter.
|
hasWeirdWrap, isAnsiSupported, isEchoEnabled, isSupported, reset, setAnsiSupported, wrapOutIfNeeded
public static final java.lang.String DIRECT_CONSOLE
public static final java.lang.String ANSI
public WindowsTerminal() throws java.lang.Exception
java.lang.Exception
public void init() throws java.lang.Exception
init
in interface Terminal
init
in class TerminalSupport
java.lang.Exception
public void restore() throws java.lang.Exception
restore
in interface Terminal
restore
in class TerminalSupport
java.lang.Exception
public int getWidth()
getWidth
in interface Terminal
getWidth
in class TerminalSupport
public int getHeight()
getHeight
in interface Terminal
getHeight
in class TerminalSupport
public void setEchoEnabled(boolean enabled)
setEchoEnabled
in interface Terminal
setEchoEnabled
in class TerminalSupport
public void disableInterruptCharacter()
disableInterruptCharacter
in interface Terminal
disableInterruptCharacter
in class TerminalSupport
public void enableInterruptCharacter()
enableInterruptCharacter
in interface Terminal
enableInterruptCharacter
in class TerminalSupport
public void setDirectConsole(boolean flag)
public java.lang.Boolean getDirectConsole()
public java.io.InputStream wrapInIfNeeded(java.io.InputStream in) throws java.io.IOException
Terminal
wrapInIfNeeded
in interface Terminal
wrapInIfNeeded
in class TerminalSupport
java.io.IOException
protected boolean isSystemIn(java.io.InputStream in) throws java.io.IOException
java.io.IOException
public java.lang.String getOutputEncoding()
getOutputEncoding
in interface Terminal
getOutputEncoding
in class TerminalSupport
Copyright © 2018. All Rights Reserved.