Interface Terminal

All Superinterfaces:
Consumer<Problem>, ProblemSink

public interface Terminal extends ProblemSink
  • Field Details

  • 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

      default AnsiPrintStream println(Object message)

      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

      default void printProblems(Problem... problems)

      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

      default void printProblems(List<Problem> problems)

      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

      default void updateStatus(List<String> lines)

      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

      String readline() throws IOException
      Returns:
      a single line of text from the user
      Throws:
      IOException - if the underlying stream threw an exception
      RuntimeException - 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

      Returns:
      an Ansi object to use for styling text - will be whatever this terminal can support or is configured to support
    • setFallbackHandler

      InterruptHandler setFallbackHandler(InterruptHandler newFallbackHandler)

      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.