Package jline
Class WindowsTerminal
java.lang.Object
jline.TerminalSupport
jline.WindowsTerminal
- All Implemented Interfaces:
Terminal
- Direct Known Subclasses:
AnsiWindowsTerminal
Terminal implementation for Microsoft Windows. Terminal initialization in
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
.
- Since:
- 2.0
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
private boolean
private int
Fields inherited from class jline.TerminalSupport
DEFAULT_HEIGHT, DEFAULT_WIDTH
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
private static int
private static int
Whether or not to allow the use of the JNI console interaction.int
int
getWidth()
private static int
private static int
void
init()
protected boolean
private byte[]
void
restore()
Restore the original terminal configuration, which can be used when shutting down the console reader.private static void
setConsoleMode
(int mode) void
setDirectConsole
(boolean flag) Whether or not to allow the use of the JNI console interaction.void
setEchoEnabled
(boolean enabled) When using native support, return the InputStream to use for reading characters else return the input stream passed as a parameter.Methods inherited from class jline.TerminalSupport
hasWeirdWrap, isAnsiSupported, isEchoEnabled, isSupported, reset, setAnsiSupported, wrapOutIfNeeded
-
Field Details
-
DIRECT_CONSOLE
-
ANSI
-
directConsole
private boolean directConsole -
originalMode
private int originalMode
-
-
Constructor Details
-
WindowsTerminal
- Throws:
Exception
-
-
Method Details
-
init
- Specified by:
init
in interfaceTerminal
- Overrides:
init
in classTerminalSupport
- Throws:
Exception
-
restore
Restore the original terminal configuration, which can be used when shutting down the console reader. The ConsoleReader cannot be used after calling this method.- Specified by:
restore
in interfaceTerminal
- Overrides:
restore
in classTerminalSupport
- Throws:
Exception
-
getWidth
public int getWidth()- Specified by:
getWidth
in interfaceTerminal
- Overrides:
getWidth
in classTerminalSupport
-
getHeight
public int getHeight()- Specified by:
getHeight
in interfaceTerminal
- Overrides:
getHeight
in classTerminalSupport
-
setEchoEnabled
public void setEchoEnabled(boolean enabled) - Specified by:
setEchoEnabled
in interfaceTerminal
- Overrides:
setEchoEnabled
in classTerminalSupport
-
disableInterruptCharacter
public void disableInterruptCharacter()- Specified by:
disableInterruptCharacter
in interfaceTerminal
- Overrides:
disableInterruptCharacter
in classTerminalSupport
-
enableInterruptCharacter
public void enableInterruptCharacter()- Specified by:
enableInterruptCharacter
in interfaceTerminal
- Overrides:
enableInterruptCharacter
in classTerminalSupport
-
setDirectConsole
public void setDirectConsole(boolean flag) Whether or not to allow the use of the JNI console interaction. -
getDirectConsole
Whether or not to allow the use of the JNI console interaction. -
wrapInIfNeeded
Description copied from interface:Terminal
When using native support, return the InputStream to use for reading characters else return the input stream passed as a parameter.- Specified by:
wrapInIfNeeded
in interfaceTerminal
- Overrides:
wrapInIfNeeded
in classTerminalSupport
- Throws:
IOException
-
isSystemIn
- Throws:
IOException
-
getOutputEncoding
- Specified by:
getOutputEncoding
in interfaceTerminal
- Overrides:
getOutputEncoding
in classTerminalSupport
-
getConsoleMode
private static int getConsoleMode() -
setConsoleMode
private static void setConsoleMode(int mode) -
readConsoleInput
private byte[] readConsoleInput() -
getConsoleOutputCodepage
private static int getConsoleOutputCodepage() -
getWindowsTerminalWidth
private static int getWindowsTerminalWidth() -
getWindowsTerminalHeight
private static int getWindowsTerminalHeight()
-