Interface Terminal
- All Superinterfaces:
Consumer<Problem>
,ProblemSink
-
Field Summary
Modifier and TypeFieldDescriptionstatic final char
Ellipsis character...
static final CommandLine.Help.Ansi.Text
Convenient 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()
int
int
getErr()
getIn()
getOut()
boolean
isTTY()
default AnsiPrintStream
Prints a line of text to the console with a new line after, returning an ansi print stream in case you want to print moredefault void
printProblems
(List<Problem> problems) Prints an array of problems using the given terminal's problem logging mechanism.default void
printProblems
(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 void
updateStatus
(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
AnsiPrintStream
to use, wrapping stdout.
-
getErr
PrintStream getErr() -
getAnsiErr
AnsiPrintStream getAnsiErr()- Returns:
- an
AnsiPrintStream
to 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.
-