|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjline.Terminal
jline.WindowsTerminal
public class WindowsTerminal
Terminal implementation for Microsoft Windows. Terminal initialization in
initializeTerminal() 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 WindowsTerminal.ReplayPrefixOneCharInputStream 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.
| Nested Class Summary | |
|---|---|
(package private) static class |
WindowsTerminal.ReplayPrefixOneCharInputStream
This is awkward and inefficient, but probably the minimal way to add UTF-8 support to JLine |
| Field Summary | |
|---|---|
static int |
DELETE_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the delete key was pressed. |
private java.lang.Boolean |
directConsole
|
static int |
DOWN_ARROW_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates an down arrow key press. |
private boolean |
echoEnabled
|
private static int |
ENABLE_ECHO_INPUT
Characters read by the ReadFile or ReadConsole function are written to the active screen buffer as they are read. |
private static int |
ENABLE_LINE_INPUT
The ReadFile or ReadConsole function returns only when a carriage return character is read. |
private static int |
ENABLE_MOUSE_INPUT
If the mouse pointer is within the borders of the console window and the window has the keyboard focus, mouse events generated by mouse movement and button presses are placed in the input buffer. |
private static int |
ENABLE_PROCESSED_INPUT
CTRL+C is processed by the system and is not placed in the input buffer. |
private static int |
ENABLE_PROCESSED_OUTPUT
When enabled, text entered in a console window will be inserted at the current cursor location and all text following that location will not be overwritten. |
private static int |
ENABLE_WINDOW_INPUT
User interactions that change the size of the console screen buffer are reported in the console's input buffee. |
private static int |
ENABLE_WRAP_AT_EOL_OUTPUT
This flag enables the user to use the mouse to select and edit text. |
(package private) java.lang.String |
encoding
|
static char |
END_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the end key was pressed. |
static char |
ESCAPE_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR, this character indicates that the escape key was pressed. |
static int |
HOME_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the home key was pressed. |
static char |
INSERT_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the insert key was pressed. |
static int |
LEFT_ARROW_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR, this character indicates an left arrow key press. |
static int |
NUMPAD_KEY_INDICATOR
On windows terminals, this character indicates that a special key on the number pad has been pressed. |
static char |
PAGE_DOWN_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the page down key was pressed. |
static char |
PAGE_UP_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates that the page up key was pressed. |
(package private) java.io.InputStreamReader |
replayReader
|
(package private) WindowsTerminal.ReplayPrefixOneCharInputStream |
replayStream
|
static int |
RIGHT_ARROW_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates an right arrow key press. |
static int |
SPECIAL_KEY_INDICATOR
On windows terminals, this character indicates that a 'special' key has been pressed. |
static int |
UP_ARROW_KEY
When following the SPECIAL_KEY_INDICATOR or NUMPAD_KEY_INDICATOR this character indicates an up arrow key press. |
| Fields inherited from interface jline.ConsoleOperations |
|---|
ADD, BACKSPACE, CHANGE_CASE, CHANGE_META, CLEAR_LINE, CLEAR_SCREEN, COMPLETE, CR, CTRL_A, CTRL_B, CTRL_C, CTRL_D, CTRL_E, CTRL_F, CTRL_K, CTRL_L, CTRL_N, CTRL_OB, CTRL_P, CTRL_QM, DELETE, DELETE_META, DELETE_NEXT_CHAR, DELETE_PREV_CHAR, DELETE_PREV_WORD, END_OF_HISTORY, END_WORD, EXIT, INSERT, KEYBOARD_BELL, KILL_LINE, KILL_LINE_PREV, MOVE_TO_BEG, MOVE_TO_END, NEWLINE, NEXT_CHAR, NEXT_HISTORY, NEXT_SPACE_WORD, NEXT_WORD, PASTE, PASTE_NEXT, PASTE_PREV, PREV_CHAR, PREV_HISTORY, PREV_SPACE_WORD, PREV_WORD, REDISPLAY, REPEAT_NEXT_CHAR, REPEAT_PREV_CHAR, REPEAT_SEARCH_NEXT, REPEAT_SEARCH_PREV, REPLACE_CHAR, REPLACE_MODE, RESET_LINE, SEARCH_NEXT, SEARCH_PREV, START_OF_HISTORY, SUBSTITUTE_CHAR, SUBSTITUTE_LINE, TO_END_WORD, TO_NEXT_CHAR, TO_PREV_CHAR, UNDO, UNKNOWN |
| Constructor Summary | |
|---|---|
WindowsTerminal()
|
|
| Method Summary | |
|---|---|
private void |
consumeException(java.lang.Throwable e)
No-op for exceptions we want to silently consume. |
void |
disableEcho()
Disable character echoing. |
void |
enableEcho()
Enable character echoing. |
private int |
getConsoleMode()
|
java.io.InputStream |
getDefaultBindings()
|
java.lang.Boolean |
getDirectConsole()
Whether or not to allow the use of the JNI console interaction. |
boolean |
getEcho()
Returns true if the terminal will echo all characters type. |
int |
getTerminalHeight()
Unsupported; return the default. |
int |
getTerminalWidth()
Unsupported; return the default. |
private int |
getWindowsTerminalHeight()
|
private int |
getWindowsTerminalWidth()
|
void |
initializeTerminal()
Initialize any system settings that are required for the console to be able to handle input correctly, such as setting tabtop, buffered input, and character echo. |
boolean |
isANSISupported()
Windows doesn't support ANSI codes by default; disable them. |
boolean |
isEchoEnabled()
Returns false if character echoing is disabled. |
boolean |
isSupported()
Returns true if this terminal is capable of initializing the terminal to use jline. |
private void |
loadLibrary(java.lang.String name)
|
private int |
readByte()
|
int |
readCharacter(java.io.InputStream in)
Read a single character from the input stream. |
int |
readVirtualKey(java.io.InputStream in)
Reads a virtual key from the console. |
private void |
setConsoleMode(int mode)
|
void |
setDirectConsole(java.lang.Boolean directConsole)
Whether or not to allow the use of the JNI console interaction. |
| Methods inherited from class jline.Terminal |
|---|
afterReadLine, beforeReadLine, getTerminal, resetTerminal, setupTerminal |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final int ENABLE_LINE_INPUT
private static final int ENABLE_ECHO_INPUT
private static final int ENABLE_PROCESSED_INPUT
private static final int ENABLE_WINDOW_INPUT
private static final int ENABLE_MOUSE_INPUT
private static final int ENABLE_PROCESSED_OUTPUT
private static final int ENABLE_WRAP_AT_EOL_OUTPUT
public static final int SPECIAL_KEY_INDICATOR
public static final int NUMPAD_KEY_INDICATOR
public static final int LEFT_ARROW_KEY
public static final int RIGHT_ARROW_KEY
public static final int UP_ARROW_KEY
public static final int DOWN_ARROW_KEY
public static final int DELETE_KEY
public static final int HOME_KEY
public static final char END_KEY
public static final char PAGE_UP_KEY
public static final char PAGE_DOWN_KEY
public static final char INSERT_KEY
public static final char ESCAPE_KEY
private java.lang.Boolean directConsole
private boolean echoEnabled
java.lang.String encoding
WindowsTerminal.ReplayPrefixOneCharInputStream replayStream
java.io.InputStreamReader replayReader
| Constructor Detail |
|---|
public WindowsTerminal()
| Method Detail |
|---|
private int getConsoleMode()
private void setConsoleMode(int mode)
private int readByte()
private int getWindowsTerminalWidth()
private int getWindowsTerminalHeight()
public int readCharacter(java.io.InputStream in)
throws java.io.IOException
Terminal
readCharacter in class Terminaljava.io.IOException
public void initializeTerminal()
throws java.lang.Exception
Terminal
initializeTerminal in class Terminaljava.lang.Exception
private void loadLibrary(java.lang.String name)
throws java.io.IOException
java.io.IOException
public int readVirtualKey(java.io.InputStream in)
throws java.io.IOException
Terminal
readVirtualKey in class Terminalin - the InputStream to read from
ConsoleOperations#VK_UP)
java.io.IOExceptionpublic boolean isSupported()
Terminal
isSupported in class Terminalpublic boolean isANSISupported()
isANSISupported in class Terminalpublic boolean getEcho()
Terminal
getEcho in class Terminalpublic int getTerminalWidth()
getTerminalWidth in class TerminalTerminal.getTerminalWidth()public int getTerminalHeight()
getTerminalHeight in class TerminalTerminal.getTerminalHeight()private void consumeException(java.lang.Throwable e)
public void setDirectConsole(java.lang.Boolean directConsole)
public java.lang.Boolean getDirectConsole()
public boolean isEchoEnabled()
Terminal
isEchoEnabled in class Terminalpublic void enableEcho()
Terminal
enableEcho in class Terminalpublic void disableEcho()
Terminal
disableEcho in class Terminalpublic java.io.InputStream getDefaultBindings()
getDefaultBindings in class Terminal
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||