|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjline.Terminal
jline.UnixTerminal
public class UnixTerminal
Terminal that is used for unix platforms. Terminal initialization is handled by issuing the stty command against the /dev/tty file to disable character echoing and enable character input. All known unix systems (including Linux and Macintosh OS X) support the stty), so this implementation should work for an reasonable POSIX system.
| Nested Class Summary | |
|---|---|
(package private) static class |
UnixTerminal.ReplayPrefixOneCharInputStream
This is awkward and inefficient, but probably the minimal way to add UTF-8 support to JLine |
| Field Summary | |
|---|---|
static short |
ARROW_DOWN
|
static short |
ARROW_LEFT
|
static short |
ARROW_PREFIX
|
static short |
ARROW_RIGHT
|
static short |
ARROW_START
|
static short |
ARROW_UP
|
private boolean |
backspaceDeleteSwitched
|
static short |
DEL_SECOND
|
static short |
DEL_THIRD
|
private boolean |
echoEnabled
|
(package private) java.lang.String |
encoding
|
static short |
END_CODE
|
static short |
HOME_CODE
|
static short |
O_PREFIX
|
(package private) java.io.InputStreamReader |
replayReader
|
(package private) UnixTerminal.ReplayPrefixOneCharInputStream |
replayStream
|
private static java.lang.String |
sttyCommand
|
private java.util.Map |
terminfo
|
private java.lang.String |
ttyConfig
|
| 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 | |
|---|---|
UnixTerminal()
|
|
| Method Summary | |
|---|---|
protected void |
checkBackspace()
|
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 static java.lang.String |
exec(java.lang.String cmd)
Execute the specified command and return the output (both stdout and stderr). |
private static java.lang.String |
exec(java.lang.String[] cmd)
Execute the specified command and return the output (both stdout and stderr). |
boolean |
getEcho()
Returns true if the terminal will echo all characters type. |
static java.lang.String |
getSttyCommand()
The command to use to set the terminal options. |
int |
getTerminalHeight()
Returns the value of "stty size" height param. |
private static int |
getTerminalProperty(java.lang.String prop)
|
int |
getTerminalWidth()
Returns the value of "stty size" width param. |
void |
initializeTerminal()
Remove line-buffered input by invoking "stty -icanon min 1" against the current terminal. |
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. |
int |
readVirtualKey(java.io.InputStream in)
Reads a virtual key from the console. |
void |
restoreTerminal()
Restore the original terminal configuration, which can be used when shutting down the console reader. |
static void |
setSttyCommand(java.lang.String cmd)
The command to use to set the terminal options. |
private static java.lang.String |
stty(java.lang.String args)
Execute the stty command with the specified arguments against the current active terminal. |
| Methods inherited from class jline.Terminal |
|---|
afterReadLine, beforeReadLine, getDefaultBindings, getTerminal, isANSISupported, readCharacter, resetTerminal, setupTerminal |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final short ARROW_START
public static final short ARROW_PREFIX
public static final short ARROW_LEFT
public static final short ARROW_RIGHT
public static final short ARROW_UP
public static final short ARROW_DOWN
public static final short O_PREFIX
public static final short HOME_CODE
public static final short END_CODE
public static final short DEL_THIRD
public static final short DEL_SECOND
private java.util.Map terminfo
private boolean echoEnabled
private java.lang.String ttyConfig
private boolean backspaceDeleteSwitched
private static java.lang.String sttyCommand
java.lang.String encoding
UnixTerminal.ReplayPrefixOneCharInputStream replayStream
java.io.InputStreamReader replayReader
| Constructor Detail |
|---|
public UnixTerminal()
| Method Detail |
|---|
protected void checkBackspace()
public void initializeTerminal()
throws java.io.IOException,
java.lang.InterruptedException
initializeTerminal in class Terminaljava.io.IOException
java.lang.InterruptedException
public void restoreTerminal()
throws java.lang.Exception
java.lang.Exception
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.IOExceptionprivate void consumeException(java.lang.Throwable e)
public boolean isSupported()
Terminal
isSupported in class Terminalpublic boolean getEcho()
Terminal
getEcho in class Terminalpublic int getTerminalWidth()
getTerminalWidth in class Terminalpublic int getTerminalHeight()
getTerminalHeight in class Terminal
private static int getTerminalProperty(java.lang.String prop)
throws java.io.IOException,
java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
private static java.lang.String stty(java.lang.String args)
throws java.io.IOException,
java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
private static java.lang.String exec(java.lang.String cmd)
throws java.io.IOException,
java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
private static java.lang.String exec(java.lang.String[] cmd)
throws java.io.IOException,
java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedExceptionpublic static void setSttyCommand(java.lang.String cmd)
public static java.lang.String getSttyCommand()
public boolean isEchoEnabled()
Terminal
isEchoEnabled in class Terminalpublic void enableEcho()
Terminal
enableEcho in class Terminalpublic void disableEcho()
Terminal
disableEcho in class Terminal
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||