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 Stringstatic final Stringprivate booleanprivate intFields inherited from class TerminalSupport
DEFAULT_HEIGHT, DEFAULT_WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidprivate static intprivate static intWhether or not to allow the use of the JNI console interaction.intintgetWidth()private static intprivate static intvoidinit()protected booleanprivate byte[]voidrestore()Restore the original terminal configuration, which can be used when shutting down the console reader.private static voidsetConsoleMode(int mode) voidsetDirectConsole(boolean flag) Whether or not to allow the use of the JNI console interaction.voidsetEchoEnabled(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 TerminalSupport
hasWeirdWrap, isAnsiSupported, isEchoEnabled, isSupported, reset, setAnsiSupported, wrapOutIfNeeded
-
Field Details
-
DIRECT_CONSOLE
-
ANSI
-
directConsole
private boolean directConsole -
originalMode
private int originalMode
-
-
Constructor Details
-
WindowsTerminal
-
-
Method Details
-
init
-
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:
restorein interfaceTerminal- Overrides:
restorein classTerminalSupport- Throws:
Exception
-
getWidth
public int getWidth()- Specified by:
getWidthin interfaceTerminal- Overrides:
getWidthin classTerminalSupport
-
getHeight
public int getHeight()- Specified by:
getHeightin interfaceTerminal- Overrides:
getHeightin classTerminalSupport
-
setEchoEnabled
public void setEchoEnabled(boolean enabled) - Specified by:
setEchoEnabledin interfaceTerminal- Overrides:
setEchoEnabledin classTerminalSupport
-
disableInterruptCharacter
public void disableInterruptCharacter()- Specified by:
disableInterruptCharacterin interfaceTerminal- Overrides:
disableInterruptCharacterin classTerminalSupport
-
enableInterruptCharacter
public void enableInterruptCharacter()- Specified by:
enableInterruptCharacterin interfaceTerminal- Overrides:
enableInterruptCharacterin 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:TerminalWhen using native support, return the InputStream to use for reading characters else return the input stream passed as a parameter.- Specified by:
wrapInIfNeededin interfaceTerminal- Overrides:
wrapInIfNeededin classTerminalSupport- Throws:
IOException
-
isSystemIn
- Throws:
IOException
-
getOutputEncoding
- Specified by:
getOutputEncodingin interfaceTerminal- Overrides:
getOutputEncodingin 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()
-