Interface TerminalOutput
-
- All Known Implementing Classes:
AbstractTerminal,AnsiTerminal,TerminfoTerminal,WindowsTerminal
public interface TerminalOutputAllows 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 Classes Modifier and Type Interface Description static classTerminalOutput.ColorBasic colors supported by a terminal.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TerminalOutputbold()Switches the terminal to bold text mode, if supported.TerminalOutputbright()Switches the terminal to high intensity, if supported.TerminalOutputclearToEndOfLine()Clears characters from the cursor position to the end of the current line.TerminalOutputcursorDown(int count)Moves the cursor the given number of characters down.TerminalOutputcursorLeft(int count)Moves the cursor the given number of characters to the left.TerminalOutputcursorRight(int count)Moves the cursor the given number of characters to the right.TerminalOutputcursorStartOfLine()Moves the cursor to the start of the current line.TerminalOutputcursorUp(int count)Moves the cursor the given number of characters up.TerminalOutputdefaultForeground()Sets the terminal foreground color to the default, if supported.TerminalOutputdim()Switches the terminal to dim intensity, if supported.TerminalOutputforeground(TerminalOutput.Color color)Sets the terminal foreground color, if supported.java.io.OutputStreamgetOutputStream()Returns anOutputStreamthat writes to this terminal.TerminalSizegetTerminalSize()Returns the size of the terminal.TerminalOutputhideCursor()Hides the cursor.TerminalOutputnewline()Writes line separator.TerminalOutputnormal()Switches the terminal to normal text mode.TerminalOutputreset()Resets this terminal.TerminalOutputshowCursor()Shows the cursor, if hidden.booleansupportsColor()Returns true if this terminal supports setting output colors.booleansupportsCursorMotion()Returns true if this terminal supports moving the cursor.booleansupportsCursorVisibility()Returns true if this terminal supports hiding the cursor.booleansupportsTextAttributes()Returns true if this terminal supports setting text attributes, such as bold.TerminalOutputwrite(char ch)Writes a character to this terminal.TerminalOutputwrite(java.lang.CharSequence text)Writes some text to this terminal.
-
-
-
Method Detail
-
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
java.io.OutputStream getOutputStream()
Returns anOutputStreamthat writes to this terminal. The output stream is not buffered.
-
write
TerminalOutput write(java.lang.CharSequence text) throws NativeException
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
TerminalOutput newline() throws NativeException
Writes line separator.- Throws:
NativeException- On failure.
-
foreground
TerminalOutput foreground(TerminalOutput.Color color) throws NativeException
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
TerminalOutput bold() throws NativeException
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
TerminalOutput dim() throws NativeException
Switches the terminal to dim intensity, if supported. Does nothing if this terminal does not support dim mode.- Throws:
NativeException- On failure.
-
bright
TerminalOutput bright() throws NativeException
Switches the terminal to high intensity, if supported. Does nothing if this terminal does not support bright mode.- Throws:
NativeException- On failure.
-
normal
TerminalOutput normal() throws NativeException
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
TerminalOutput reset() throws NativeException
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.
-
-