jline

Class WindowsTerminal

public class WindowsTerminal extends Terminal

Terminal implementation for Microsoft Windows. Terminal initialization in WindowsTerminal 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 WindowsTerminal 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.disableDirectConsole system property to true.

Author: Marc Prud'hommeaux

Field Summary
static intDELETE_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the delete key was pressed.
static intDOWN_ARROW_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates an down arrow key press.
static charEND_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the end key was pressed.
static charESCAPE_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR, this character indicates that the escape key was pressed.
static intHOME_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the home key was pressed.
static charINSERT_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the insert key was pressed.
static intLEFT_ARROW_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR, this character indicates an left arrow key press.
static intNUMPAD_KEY_INDICATOR
On windows terminals, this character indicates that a special key on the number pad has been pressed.
static charPAGE_DOWN_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the page down key was pressed.
static charPAGE_UP_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the page up key was pressed.
static intRIGHT_ARROW_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates an right arrow key press.
static intSPECIAL_KEY_INDICATOR
On windows terminals, this character indicates that a 'special' key has been pressed.
static intUP_ARROW_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates an up arrow key press.
Constructor Summary
WindowsTerminal()
Method Summary
voiddisableEcho()
voidenableEcho()
InputStreamgetDefaultBindings()
BooleangetDirectConsole()
Whether or not to allow the use of the JNI console interaction.
booleangetEcho()
intgetTerminalHeight()
Unsupported; return the default.
intgetTerminalWidth()
Unsupported; return the default.
voidinitializeTerminal()
booleanisANSISupported()
Windows doesn't support ANSI codes by default; disable them.
booleanisEchoEnabled()
booleanisSupported()
intreadCharacter(InputStream in)
intreadVirtualKey(InputStream in)
voidsetDirectConsole(Boolean directConsole)
Whether or not to allow the use of the JNI console interaction.

Field Detail

DELETE_KEY

public static final int DELETE_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the delete key was pressed.

DOWN_ARROW_KEY

public static final int DOWN_ARROW_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates an down arrow key press.

END_KEY

public static final char END_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the end key was pressed.

ESCAPE_KEY

public static final char ESCAPE_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR, this character indicates that the escape key was pressed.

HOME_KEY

public static final int HOME_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the home key was pressed.

INSERT_KEY

public static final char INSERT_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the insert key was pressed.

LEFT_ARROW_KEY

public static final int LEFT_ARROW_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR, this character indicates an left arrow key press.

NUMPAD_KEY_INDICATOR

public static final int NUMPAD_KEY_INDICATOR
On windows terminals, this character indicates that a special key on the number pad has been pressed.

PAGE_DOWN_KEY

public static final char PAGE_DOWN_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the page down key was pressed.

PAGE_UP_KEY

public static final char PAGE_UP_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the page up key was pressed.

RIGHT_ARROW_KEY

public static final int RIGHT_ARROW_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates an right arrow key press.

SPECIAL_KEY_INDICATOR

public static final int SPECIAL_KEY_INDICATOR
On windows terminals, this character indicates that a 'special' key has been pressed. This means that a key such as an arrow key, or delete, or home, etc. will be indicated by the next character.

UP_ARROW_KEY

public static final int UP_ARROW_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates an up arrow key press.

Constructor Detail

WindowsTerminal

public WindowsTerminal()

Method Detail

disableEcho

public void disableEcho()

enableEcho

public void enableEcho()

getDefaultBindings

public InputStream getDefaultBindings()

getDirectConsole

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

getEcho

public boolean getEcho()

getTerminalHeight

public int getTerminalHeight()
Unsupported; return the default.

See Also: Terminal

getTerminalWidth

public int getTerminalWidth()
Unsupported; return the default.

See Also: Terminal

initializeTerminal

public void initializeTerminal()

isANSISupported

public boolean isANSISupported()
Windows doesn't support ANSI codes by default; disable them.

isEchoEnabled

public boolean isEchoEnabled()

isSupported

public boolean isSupported()

readCharacter

public int readCharacter(InputStream in)

readVirtualKey

public int readVirtualKey(InputStream in)

setDirectConsole

public void setDirectConsole(Boolean directConsole)
Whether or not to allow the use of the JNI console interaction.
Copyright © 2002-2009 null. All Rights Reserved.