public class Terminal extends CharReader implements Closeable, LinePrinter
| Constructor and Description |
|---|
Terminal()
Construct a default RAW terminal.
|
Terminal(InputStream in,
OutputStream out,
LinePrinter lp,
STTYModeSwitcher switcher)
Constructor visible for testing.
|
Terminal(LinePrinter lp)
Construct a terminal with a custom line printer.
|
Terminal(STTYMode mode)
Construct a terminal with given mode.
|
Terminal(STTYMode mode,
LinePrinter lp)
Construct a terminal with a terminal mode and custom line printer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
boolean |
confirm(String what)
Make a user confirmation.
|
boolean |
confirm(String what,
boolean def)
Make a user confirmation.
|
void |
finish()
Finish the current set of lines and continue below.
|
void |
format(String format,
Object... args) |
void |
formatln(String format,
Object... args) |
void |
print(Char ch) |
void |
print(String message) |
void |
println() |
void |
println(String message)
Print a new line to the terminal.
|
readclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waiterror, fatal, info, warnpublic Terminal()
UncheckedIOException - If unable to set TTY mode.public Terminal(STTYMode mode)
mode - The terminal mode.UncheckedIOException - If unable to set TTY mode.public Terminal(LinePrinter lp)
lp - The line printer.UncheckedIOException - If unable to set TTY mode.public Terminal(STTYMode mode, LinePrinter lp)
mode - The terminal mode.lp - The line printer.UncheckedIOException - If unable to set TTY mode.public Terminal(InputStream in, OutputStream out, LinePrinter lp, STTYModeSwitcher switcher)
in - The input stream.out - The output stream.lp - The line printer or null.switcher - The TTY mode switcher.UncheckedIOException - If unable to set TTY mode.public boolean confirm(String what)
boolean really = term.confirm("Do you o'Really?");
Will print out "Do you o'Really? [Y/n]: ". If the user press
'y' and 'enter' will pass (return true), if 'n', and 'backspace' will return
false. Invalid characters will print a short error message.what - What to confirm. Basically the message before '[Y/n]'.public boolean confirm(String what, boolean def)
boolean really = term.confirm("Do you o'Really?", false);
Will print out "Do you o'Really? [y/N]: ". If the user press
'y' will pass (return true), if 'n', 'enter' and 'backspace' will return
false. Invalid characters will print a short error message.what - What to confirm. Basically the message before '[Y/n]'.def - the default response on 'enter'.public void print(Char ch)
public void print(String message)
public void println(String message)
LinePrinterprintln in interface LinePrintermessage - The message to write.public void println()
public void finish()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2016. All rights reserved.