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.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumBasic colors supported by a terminal. -
Method Summary
Modifier and TypeMethodDescriptionbold()Switches the terminal to bold text mode, if supported.bright()Switches the terminal to high intensity, if supported.Clears characters from the cursor position to the end of the current line.cursorDown(int count) Moves the cursor the given number of characters down.cursorLeft(int count) Moves the cursor the given number of characters to the left.cursorRight(int count) Moves the cursor the given number of characters to the right.Moves the cursor to the start of the current line.cursorUp(int count) Moves the cursor the given number of characters up.Sets the terminal foreground color to the default, if supported.dim()Switches the terminal to dim intensity, if supported.foreground(TerminalOutput.Color color) Sets the terminal foreground color, if supported.Returns anOutputStreamthat writes to this terminal.Returns the size of the terminal.Hides the cursor.newline()Writes line separator.normal()Switches the terminal to normal text mode.reset()Resets this terminal.Shows the cursor, if hidden.booleanReturns true if this terminal supports setting output colors.booleanReturns true if this terminal supports moving the cursor.booleanReturns true if this terminal supports hiding the cursor.booleanReturns true if this terminal supports setting text attributes, such as bold.write(char ch) Writes a character to this terminal.write(CharSequence text) Writes some text to this terminal.
-
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
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 anOutputStreamthat 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
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
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
Hides the cursor. Does nothing if this terminal does not support hiding the cursor.- Throws:
NativeException- On failure.
-
showCursor
Shows the cursor, if hidden. Supported by all terminals.- Throws:
NativeException- On failure.
-
cursorLeft
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
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
Moves the cursor the given number of characters up.- Throws:
NativeException- On failure, or if this terminal does not support cursor motion.
-
cursorDown
Moves the cursor the given number of characters down.- Throws:
NativeException- On failure, or if this terminal does not support cursor motion.
-
cursorStartOfLine
Moves the cursor to the start of the current line.- Throws:
NativeException- On failure, or if this terminal does not support cursor motion.
-
clearToEndOfLine
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.
-