Interface TerminalOutput

All Known Implementing Classes:
AbstractTerminal, AnsiTerminal, TerminfoTerminal, WindowsTerminal

public interface TerminalOutput
Allows output to be written to the terminal/console.

On UNIX based platforms, this provides access to the terminal. On Windows platforms, this provides access to the console.

To create an instance of this interface use the Terminals.getTerminal(Terminals.Output) method.

  • Method Details

    • supportsTextAttributes

      boolean supportsTextAttributes()
      Returns true if this terminal supports setting text attributes, such as bold.
    • supportsColor

      boolean supportsColor()
      Returns true if this terminal supports setting output colors.
    • supportsCursorMotion

      boolean supportsCursorMotion()
      Returns true if this terminal supports moving the cursor.
    • supportsCursorVisibility

      boolean supportsCursorVisibility()
      Returns true if this terminal supports hiding the cursor.
    • getTerminalSize

      TerminalSize getTerminalSize() throws NativeException
      Returns the size of the terminal. Supported by all terminals.
      Returns:
      The current terminal size. Never returns null.
      Throws:
      NativeException - On failure.
    • getOutputStream

      OutputStream getOutputStream()
      Returns an OutputStream that writes to this terminal. The output stream is not buffered.
    • write

      Writes some text to this terminal. Uses the system encoding.
      Throws:
      NativeException - On failure.
    • write

      TerminalOutput write(char ch) throws NativeException
      Writes a character to this terminal. Uses the system encoding.
      Throws:
      NativeException - On failure.
    • newline

      Writes line separator.
      Throws:
      NativeException - On failure.
    • foreground

      Sets the terminal foreground color, if supported. Does nothing if this terminal does not support setting the foreground color.
      Throws:
      NativeException - On failure.
    • defaultForeground

      TerminalOutput defaultForeground() throws NativeException
      Sets the terminal foreground color to the default, if supported. Does nothing if this terminal does not support setting the foreground color.
      Throws:
      NativeException - On failure.
    • bold

      Switches the terminal to bold text mode, if supported. Does nothing if this terminal does not support bold mode.

      Often the same as bright().

      Throws:
      NativeException - On failure.
    • dim

      Switches the terminal to dim intensity, if supported. Does nothing if this terminal does not support dim mode.
      Throws:
      NativeException - On failure.
    • bright

      Switches the terminal to high intensity, if supported. Does nothing if this terminal does not support bright mode.
      Throws:
      NativeException - On failure.
    • normal

      Switches the terminal to normal text mode. Switches off bold text mode and sets normal intensity. Supported by all terminals.
      Throws:
      NativeException - On failure.
    • reset

      Resets this terminal. Switches to normal text mode, restores default foreground color and shows the cursor. Supported by all terminals.
      Throws:
      NativeException - On failure.
    • hideCursor

      TerminalOutput hideCursor() throws NativeException
      Hides the cursor. Does nothing if this terminal does not support hiding the cursor.
      Throws:
      NativeException - On failure.
    • showCursor

      TerminalOutput showCursor() throws NativeException
      Shows the cursor, if hidden. Supported by all terminals.
      Throws:
      NativeException - On failure.
    • cursorLeft

      TerminalOutput cursorLeft(int count) throws NativeException
      Moves the cursor the given number of characters to the left.
      Throws:
      NativeException - On failure, or if this terminal does not support cursor motion.
    • cursorRight

      TerminalOutput cursorRight(int count) throws NativeException
      Moves the cursor the given number of characters to the right.
      Throws:
      NativeException - On failure, or if this terminal does not support cursor motion.
    • cursorUp

      TerminalOutput cursorUp(int count) throws NativeException
      Moves the cursor the given number of characters up.
      Throws:
      NativeException - On failure, or if this terminal does not support cursor motion.
    • cursorDown

      TerminalOutput cursorDown(int count) throws NativeException
      Moves the cursor the given number of characters down.
      Throws:
      NativeException - On failure, or if this terminal does not support cursor motion.
    • cursorStartOfLine

      TerminalOutput cursorStartOfLine() throws NativeException
      Moves the cursor to the start of the current line.
      Throws:
      NativeException - On failure, or if this terminal does not support cursor motion.
    • clearToEndOfLine

      TerminalOutput clearToEndOfLine() throws NativeException
      Clears characters from the cursor position to the end of the current line.
      Throws:
      NativeException - On failure, or if this terminal does not support clearing.