public class POSIXTerminal extends AbstractTerminal
| Modifier and Type | Field and Description |
|---|---|
private boolean |
echoEnabled |
private ConsoleInputSession |
input |
private static java.util.logging.Logger |
LOGGER |
private boolean |
restored |
private TerminalSize |
size |
private java.io.PrintStream |
stdErr |
private java.io.PrintStream |
stdOut |
private static long |
TIMEOUT_PERIOD |
private java.lang.String |
ttyConfig |
private java.lang.String |
ttyProps |
private long |
ttyPropsLastFetched |
settings| Constructor and Description |
|---|
POSIXTerminal() |
| Modifier and Type | Method and Description |
|---|---|
void |
changeOutputStream(java.io.PrintStream output)
During runtime, change the output stream
|
void |
close() |
java.io.PrintStream |
err()
Returns the
PrintStream associated with the std err |
private static java.lang.String |
exec(java.lang.String cmd)
Run a command and return the output
|
private static java.lang.String |
exec(java.lang.String[] cmd)
Run a command and return the output
|
private int |
getHeight() |
TerminalSize |
getSize() |
private int |
getTerminalProperty(java.lang.String prop) |
private int |
getWidth() |
boolean |
hasInput()
Check if the terminal has input waiting to be read.
|
void |
init(Settings settings)
Initialize the Terminal with which input/output stream it should use
|
boolean |
isEchoEnabled() |
java.io.PrintStream |
out()
Returns the
PrintStream associated with the std out |
private boolean |
propertiesTimedOut() |
int[] |
read()
Read from the input stream (char by char)
|
void |
reset()
Set it back to normal when we exit
|
protected static java.lang.String |
stty(java.lang.String args)
Run stty with arguments on the active terminal
|
void |
writeToInputStream(java.lang.String data) |
clear, enableAlternateBuffer, enableMainBuffer, getCursor, getShell, in, isMainBuffer, moveCursor, setCursorprivate TerminalSize size
private boolean echoEnabled
private java.lang.String ttyConfig
private java.lang.String ttyProps
private long ttyPropsLastFetched
private boolean restored
private ConsoleInputSession input
private java.io.PrintStream stdOut
private java.io.PrintStream stdErr
private static final long TIMEOUT_PERIOD
private static final java.util.logging.Logger LOGGER
public void init(Settings settings)
Terminalpublic int[] read()
throws java.io.IOException
Terminaljava.io.IOExceptionTerminalpublic boolean hasInput()
Terminalpublic TerminalSize getSize()
private int getHeight()
private int getWidth()
public boolean isEchoEnabled()
Terminalpublic void reset()
throws java.io.IOException
Terminaljava.io.IOException - streamTerminalpublic void writeToInputStream(java.lang.String data)
public void changeOutputStream(java.io.PrintStream output)
Terminaloutput - streampublic void close()
throws java.io.IOException
java.io.IOExceptionprivate boolean propertiesTimedOut()
private int getTerminalProperty(java.lang.String prop)
throws java.io.IOException,
java.lang.InterruptedException
java.io.IOExceptionjava.lang.InterruptedExceptionprotected static java.lang.String stty(java.lang.String args)
throws java.io.IOException,
java.lang.InterruptedException
args - argumentsjava.io.IOException - streamjava.lang.InterruptedException - streamprivate static java.lang.String exec(java.lang.String cmd)
throws java.io.IOException,
java.lang.InterruptedException
cmd - what to executejava.io.IOException - streamjava.lang.InterruptedException - streamprivate static java.lang.String exec(java.lang.String[] cmd)
throws java.io.IOException,
java.lang.InterruptedException
cmd - the commandjava.io.IOException - streamjava.lang.InterruptedException - streampublic java.io.PrintStream err()
ShellPrintStream associated with the std errpublic java.io.PrintStream out()
ShellPrintStream associated with the std out