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 readCharacter(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.

static class WindowsTerminal.WindowsKey
          Windows keys.
 
Nested classes/interfaces inherited from class jline.TerminalSupport
TerminalSupport.RestoreHook
 
Field Summary
static String ANSI
           
static String JLINE_WINDOWS_TERMINAL_DIRECT_CONSOLE
           
static String JLINE_WINDOWS_TERMINAL_INPUT_ENCODING
           
static String JLINE_WINDOWS_TERMINAL_OUTPUT_ENCODING
           
static String WINDOWSBINDINGS_PROPERTIES
           
 
Fields inherited from class jline.TerminalSupport
DEFAULT_HEIGHT, DEFAULT_KEYBINDINGS_PROPERTIES, DEFAULT_WIDTH
 
Constructor Summary
WindowsTerminal()
           
 
Method Summary
 InputStream getDefaultBindings()
           
 Boolean getDirectConsole()
          Whether or not to allow the use of the JNI console interaction.
 int getHeight()
           
 int getWidth()
           
 void init()
           
 int readCharacter(InputStream in)
           
 int readVirtualKey(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)
           
 
Methods inherited from class jline.TerminalSupport
installShutdownHook, isAnsiSupported, isEchoEnabled, isSupported, removeShutdownHook, reset, setAnsiSupported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JLINE_WINDOWS_TERMINAL_INPUT_ENCODING

public static final String JLINE_WINDOWS_TERMINAL_INPUT_ENCODING
See Also:
Constant Field Values

JLINE_WINDOWS_TERMINAL_OUTPUT_ENCODING

public static final String JLINE_WINDOWS_TERMINAL_OUTPUT_ENCODING
See Also:
Constant Field Values

JLINE_WINDOWS_TERMINAL_DIRECT_CONSOLE

public static final String JLINE_WINDOWS_TERMINAL_DIRECT_CONSOLE
See Also:
Constant Field Values

WINDOWSBINDINGS_PROPERTIES

public static final String WINDOWSBINDINGS_PROPERTIES
See Also:
Constant Field Values

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.


readCharacter

public int readCharacter(InputStream in)
                  throws IOException
Specified by:
readCharacter in interface Terminal
Overrides:
readCharacter in class TerminalSupport
Throws:
IOException

readVirtualKey

public int readVirtualKey(InputStream in)
                   throws IOException
Specified by:
readVirtualKey in interface Terminal
Overrides:
readVirtualKey in class TerminalSupport
Throws:
IOException

getDefaultBindings

public InputStream getDefaultBindings()
Specified by:
getDefaultBindings in interface Terminal
Overrides:
getDefaultBindings in class TerminalSupport


Copyright © 2008-2011 Sonatype. All Rights Reserved.