Interface Terminal
- All Superinterfaces:
Consumer<Problem>,ProblemSink
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charEllipsis character...static final CommandLine.Help.Ansi.TextConvenient constant to use in place of null for empty, un-styled, textstatic final List<CommandLine.Help.Ansi.IStyle>Convenient constant to denote no stylingFields inherited from interface nz.org.riskscape.problem.ProblemSink
DEVNULL -
Method Summary
Modifier and TypeMethodDescriptiongetAnsi()intintgetErr()getIn()getOut()booleanisTTY()default AnsiPrintStreamPrints a line of text to the console with a new line after, returning an ansi print stream in case you want to print moredefault voidprintProblems(List<Problem> problems) Prints an array of problems using the given terminal's problem logging mechanism.default voidprintProblems(Problem... problems) Prints an array of problems using the given terminal's problem logging mechanism.readline()setFallbackHandler(InterruptHandler newFallbackHandler) Specify an interrupt handler that will be called on ctrl-c when readline isn't in progress.default voidupdateStatus(List<String> lines) Update the terminal's status area with the following text.Methods inherited from interface nz.org.riskscape.problem.ProblemSink
accept, log
-
Field Details
-
NO_STYLES
Convenient constant to denote no styling
-
EMPTY_TEXT
Convenient constant to use in place of null for empty, un-styled, text
-
ELLIPSIS
static final char ELLIPSISEllipsis character
...- See Also:
-
-
Method Details
-
getIn
InputStream getIn() -
getOut
PrintStream getOut() -
getAnsiOut
AnsiPrintStream getAnsiOut()- Returns:
- an
AnsiPrintStreamto use, wrapping stdout.
-
getErr
PrintStream getErr() -
getAnsiErr
AnsiPrintStream getAnsiErr()- Returns:
- an
AnsiPrintStreamto use, wrapping stderr.
-
println
Prints a line of text to the console with a new line after, returning an ansi print stream in case you want to print more
-
printProblems
Prints an array of problems using the given terminal's problem logging mechanism. Note that this is likely to send the text to stderr and not stdout.
-
printProblems
Prints an array of problems using the given terminal's problem logging mechanism. Note that this is likely to send the text to stderr and not stdout.
-
updateStatus
Update the terminal's status area with the following text. This should be ignored if isTTY false. May also be ignored if the terminal implementation doesn't support it.
- Parameters:
lines- status lines to present to user. If null or empty any previous status should be removed.
-
getLocale
Locale getLocale()- Returns:
- the locale that the terminal is in - this should influence what text you send to it
-
readline
- Returns:
- a single line of text from the user
- Throws:
IOException- if the underlying stream threw an exceptionRuntimeException- if the underlying implementation supports it, this can also throw an exception if the input is interrupted, say, by ctrl-c
-
isTTY
boolean isTTY()- Returns:
- true if this terminal is a tty or tty emulated. Will be false if it looks like RiskScape is being used
as part of a unix pipeline e.g.
riskscape | less
-
getDisplayWidth
int getDisplayWidth()- Returns:
- the width (in standard character-width) of the user's terminal window.
-
getDisplayHeight
int getDisplayHeight()- Returns:
- the height (in standard character-height) of the user's terminal window.
-
getAnsi
CommandLine.Help.Ansi getAnsi()- Returns:
- an Ansi object to use for styling text - will be whatever this terminal can support or is configured to support
-
setFallbackHandler
Specify an interrupt handler that will be called on ctrl-c when readline isn't in progress. Should default to exiting.
- Returns:
- the previous handler.
-