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.
ARROW_DOWN
public static final short ARROW_DOWN
ARROW_LEFT
public static final short ARROW_LEFT
ARROW_PREFIX
public static final short ARROW_PREFIX
ARROW_RIGHT
public static final short ARROW_RIGHT
ARROW_START
public static final short ARROW_START
ARROW_UP
public static final short ARROW_UP
DEL_SECOND
public static final short DEL_SECOND
DEL_THIRD
public static final short DEL_THIRD
END_CODE
public static final short END_CODE
HOME_CODE
public static final short HOME_CODE
O_PREFIX
public static final short O_PREFIX
backspaceDeleteSwitched
private boolean backspaceDeleteSwitched
echoEnabled
private boolean echoEnabled
encoding
(package private) String encoding
replayReader
(package private) InputStreamReader replayReader
sttyCommand
private static String sttyCommand
terminfo
private Map terminfo
ttyConfig
private String ttyConfig
checkBackspace
protected void checkBackspace()
consumeException
private void consumeException(Throwable e)
No-op for exceptions we want to silently consume.
exec
private static String exec(String cmd)
throws IOException,
InterruptedException
Execute the specified command and return the output
(both stdout and stderr).
exec
private static String exec(String[] cmd)
throws IOException,
InterruptedException
Execute the specified command and return the output
(both stdout and stderr).
getSttyCommand
public static String getSttyCommand()
The command to use to set the terminal options. Defaults
to "stty", or the value of the system property "jline.sttyCommand".
getTerminalHeight
public int getTerminalHeight()
Returns the value of "stty size" height param.
Note: this method caches the value from the
first time it is called in order to increase speed, which means
that changing to size of the terminal will not be reflected
in the console.
- getTerminalHeight in interface Terminal
getTerminalProperty
private static int getTerminalProperty(String prop)
throws IOException,
InterruptedException
getTerminalWidth
public int getTerminalWidth()
Returns the value of "stty size" width param.
Note: this method caches the value from the
first time it is called in order to increase speed, which means
that changing to size of the terminal will not be reflected
in the console.
- getTerminalWidth in interface Terminal
initializeTerminal
public void initializeTerminal()
throws IOException,
InterruptedException
Remove line-buffered input by invoking "stty -icanon min 1"
against the current terminal.
- initializeTerminal in interface Terminal
readVirtualKey
public int readVirtualKey(InputStream in)
throws IOException
- readVirtualKey in interface Terminal
restoreTerminal
public void restoreTerminal()
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.
setSttyCommand
public static void setSttyCommand(String cmd)
The command to use to set the terminal options. Defaults
to "stty", or the value of the system property "jline.sttyCommand".
stty
private static String stty(String args)
throws IOException,
InterruptedException
Execute the stty command with the specified arguments
against the current active terminal.