ConsoleReaderOutputStream
public
class
ConsoleReaderOutputStream
extends Object
java.lang.Object | |
↳ | com.android.tradefed.log.ConsoleReaderOutputStream |
An OutputStream that can be used to make System.out.print()
play nice with the user's
ConsoleReader
buffer.
Summary
Public constructors | |
---|---|
ConsoleReaderOutputStream(ConsoleReader reader)
|
Public methods | |
---|---|
void
|
flush()
|
ConsoleReader
|
getConsoleReader()
Get the ConsoleReader instance that we're using internally |
void
|
setAsyncMode()
Set asynchronous mode. |
void
|
setSyncMode()
Set synchronous mode. |
void
|
write(byte[] b, int off, int len)
A special implementation to keep the user's command buffer visible when asynchronous tasks write to stdout. |
void
|
write(int b)
|
Public constructors
ConsoleReaderOutputStream
public ConsoleReaderOutputStream (ConsoleReader reader)
Parameters | |
---|---|
reader |
ConsoleReader |
Public methods
flush
public void flush ()
getConsoleReader
public ConsoleReader getConsoleReader ()
Get the ConsoleReader instance that we're using internally
Returns | |
---|---|
ConsoleReader |
setAsyncMode
public void setAsyncMode ()
Set asynchronous mode. This occurs immediately after we display the command prompt and begin waiting for user input. In this mode, the most recent line on the screen is guaranteed to be the command prompt. In particular, asynchronous tasks may attempt to print to the screen, and we will shuffle the prompt when they do so.
setSyncMode
public void setSyncMode ()
Set synchronous mode. This occurs after the user has taken some action, such that the most recent line on the screen is guaranteed to _not_ be the command prompt. In this case, we disable the prompt-shuffling behavior (which requires that the most recent line on the screen be the prompt)
write
public void write (byte[] b, int off, int len)
A special implementation to keep the user's command buffer visible when asynchronous tasks write to stdout.
If a full-line write is detected (one that terminates with "\n"), we:- Clear the current line (which will contain the prompt and the user's buffer
- Print the full line(s), which will drop us on a new line
- Redraw the prompt and the user's buffer
Parameters | |
---|---|
b |
byte |
off |
int |
len |
int |
write
public void write (int b)
Parameters | |
---|---|
b |
int |