jline
Class WindowsTerminal

java.lang.Object
  extended by jline.TerminalSupport
      extended by jline.WindowsTerminal
All Implemented Interfaces:
Terminal
Direct Known Subclasses:
AnsiWindowsTerminal

public class WindowsTerminal
extends TerminalSupport

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
Author:
Marc Prud'hommeaux, Jason Dillon

Nested Class Summary
static class WindowsTerminal.ConsoleMode
          Console mode

Constants copied wincon.h.

 
Field Summary
static String ANSI
           
static String DIRECT_CONSOLE
           
 
Fields inherited from class jline.TerminalSupport
DEFAULT_HEIGHT, DEFAULT_WIDTH
 
Constructor Summary
WindowsTerminal()
           
 
Method Summary
 Boolean getDirectConsole()
          Whether or not to allow the use of the JNI console interaction.
 int getHeight()
           
 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.
 
Methods inherited from class jline.TerminalSupport
hasWeirdWrap, isAnsiSupported, isEchoEnabled, isSupported, reset, setAnsiSupported, wrapOutIfNeeded
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIRECT_CONSOLE

public static final String DIRECT_CONSOLE

ANSI

public static final String ANSI
Constructor Detail

WindowsTerminal

public WindowsTerminal()
                throws Exception
Throws:
Exception
Method Detail

init

public void init()
          throws Exception
Specified by:
init in interface Terminal
Overrides:
init in class TerminalSupport
Throws:
Exception

restore

public void restore()
             throws Exception
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 interface Terminal
Overrides:
restore in class TerminalSupport
Throws:
Exception

getWidth

public int getWidth()
Specified by:
getWidth in interface Terminal
Overrides:
getWidth in class TerminalSupport

getHeight

public int getHeight()
Specified by:
getHeight in interface Terminal
Overrides:
getHeight in class TerminalSupport

setEchoEnabled

public void setEchoEnabled(boolean enabled)
Specified by:
setEchoEnabled in interface Terminal
Overrides:
setEchoEnabled in class TerminalSupport

setDirectConsole

public void setDirectConsole(boolean flag)
Whether or not to allow the use of the JNI console interaction.


getDirectConsole

public Boolean getDirectConsole()
Whether or not to allow the use of the JNI console interaction.


wrapInIfNeeded

public InputStream wrapInIfNeeded(InputStream in)
                           throws IOException
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 interface Terminal
Overrides:
wrapInIfNeeded in class TerminalSupport
Throws:
IOException

isSystemIn

protected boolean isSystemIn(InputStream in)
                      throws IOException
Throws:
IOException


Copyright © 2013. All Rights Reserved.