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 String |
ANSI |
static String |
DIRECT_CONSOLE |
DEFAULT_HEIGHT, DEFAULT_WIDTH
Constructor and Description |
---|
WindowsTerminal() |
Modifier and Type | Method and Description |
---|---|
Boolean |
getDirectConsole()
Whether or not to allow the use of the JNI console interaction.
|
int |
getHeight() |
String |
getOutputEncoding() |
int |
getWidth() |
void |
init() |
protected boolean |
isSystemIn(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) |
InputStream |
wrapInIfNeeded(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 String DIRECT_CONSOLE
public static final String ANSI
public void init() throws Exception
init
in interface Terminal
init
in class TerminalSupport
Exception
public void restore() throws Exception
restore
in interface Terminal
restore
in class TerminalSupport
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 setDirectConsole(boolean flag)
public Boolean getDirectConsole()
public InputStream wrapInIfNeeded(InputStream in) throws IOException
Terminal
wrapInIfNeeded
in interface Terminal
wrapInIfNeeded
in class TerminalSupport
IOException
protected boolean isSystemIn(InputStream in) throws IOException
IOException
public String getOutputEncoding()
getOutputEncoding
in interface Terminal
getOutputEncoding
in class TerminalSupport
Copyright © 2017. All Rights Reserved.