Package jline
Class WindowsTerminal
- java.lang.Object
-
- jline.TerminalSupport
-
- jline.WindowsTerminal
-
- All Implemented Interfaces:
Terminal
- Direct Known Subclasses:
AnsiWindowsTerminal
public class WindowsTerminal extends TerminalSupport
Terminal implementation for Microsoft Windows. Terminal initialization ininit()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 specifiedInputStreamisSystem.inor a wrapper aroundFileDescriptor.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 theSystem.instream. Using JNI reading can be bypassed by setting thejline.WindowsTerminal.directConsolesystem property tofalse.- Since:
- 2.0
- Author:
- Marc Prud'hommeaux, Jason Dillon
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWindowsTerminal.ConsoleModeConsole mode
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringANSIstatic java.lang.StringDIRECT_CONSOLE-
Fields inherited from class jline.TerminalSupport
DEFAULT_HEIGHT, DEFAULT_WIDTH
-
-
Constructor Summary
Constructors Constructor Description WindowsTerminal()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddisableInterruptCharacter()voidenableInterruptCharacter()java.lang.BooleangetDirectConsole()Whether or not to allow the use of the JNI console interaction.intgetHeight()java.lang.StringgetOutputEncoding()intgetWidth()voidinit()protected booleanisSystemIn(java.io.InputStream in)voidrestore()Restore the original terminal configuration, which can be used when shutting down the console reader.voidsetDirectConsole(boolean flag)Whether or not to allow the use of the JNI console interaction.voidsetEchoEnabled(boolean enabled)java.io.InputStreamwrapInIfNeeded(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.-
Methods inherited from class jline.TerminalSupport
hasWeirdWrap, isAnsiSupported, isEchoEnabled, isSupported, reset, setAnsiSupported, wrapOutIfNeeded
-
-
-
-
Method Detail
-
init
public void init() throws java.lang.Exception- Specified by:
initin interfaceTerminal- Overrides:
initin classTerminalSupport- Throws:
java.lang.Exception
-
restore
public void restore() throws java.lang.ExceptionRestore 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:
java.lang.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
public java.lang.Boolean getDirectConsole()
Whether or not to allow the use of the JNI console interaction.
-
wrapInIfNeeded
public java.io.InputStream wrapInIfNeeded(java.io.InputStream in) throws java.io.IOExceptionDescription 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:
java.io.IOException
-
isSystemIn
protected boolean isSystemIn(java.io.InputStream in) throws java.io.IOException- Throws:
java.io.IOException
-
getOutputEncoding
public java.lang.String getOutputEncoding()
- Specified by:
getOutputEncodingin interfaceTerminal- Overrides:
getOutputEncodingin classTerminalSupport
-
-