Class AnsiTerminal
- java.lang.Object
-
- net.rubygrapefruit.platform.internal.AbstractTerminal
-
- net.rubygrapefruit.platform.internal.AnsiTerminal
-
- All Implemented Interfaces:
Terminal
public class AnsiTerminal extends AbstractTerminal
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.rubygrapefruit.platform.Terminal
Terminal.Color
-
-
Constructor Summary
Constructors Constructor Description AnsiTerminal(java.io.OutputStream outputStream, Terminals.Output output)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Terminal
bold()
Switches the terminal to bold mode, if supported.Terminal
clearToEndOfLine()
Clears characters from the cursor position to the end of the current line.Terminal
cursorDown(int count)
Moves the cursor the given number of characters down.Terminal
cursorLeft(int count)
Moves the cursor the given number of characters to the left.Terminal
cursorRight(int count)
Moves the cursor the given number of characters to the right.Terminal
cursorStartOfLine()
Moves the cursor to the start of the current line.Terminal
cursorUp(int count)
Moves the cursor the given number of characters up.Terminal
foreground(Terminal.Color color)
Sets the terminal foreground color, if supported.TerminalSize
getTerminalSize()
Returns the size of the terminal.protected void
init()
Terminal
normal()
Switches the terminal to normal mode.Terminal
reset()
Switches the terminal to normal mode and restores default colors.boolean
supportsColor()
Returns true if this terminal supports setting output colors.boolean
supportsCursorMotion()
Returns true if this terminal supports moving the cursor.boolean
supportsTextAttributes()
Returns true if this terminal supports setting text attributes, such as bold.java.lang.String
toString()
-
-
-
Constructor Detail
-
AnsiTerminal
public AnsiTerminal(java.io.OutputStream outputStream, Terminals.Output output)
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
init
protected void init()
- Specified by:
init
in classAbstractTerminal
-
supportsTextAttributes
public boolean supportsTextAttributes()
Description copied from interface:Terminal
Returns true if this terminal supports setting text attributes, such as bold.
-
supportsColor
public boolean supportsColor()
Description copied from interface:Terminal
Returns true if this terminal supports setting output colors.
-
supportsCursorMotion
public boolean supportsCursorMotion()
Description copied from interface:Terminal
Returns true if this terminal supports moving the cursor.
-
getTerminalSize
public TerminalSize getTerminalSize() throws NativeException
Description copied from interface:Terminal
Returns the size of the terminal. Supported by all terminals.- Returns:
- The current terminal size. Never returns null.
- Throws:
NativeException
- On failure.
-
foreground
public Terminal foreground(Terminal.Color color) throws NativeException
Description copied from interface:Terminal
Sets the terminal foreground color, if supported. Does nothing if this terminal does not support setting the foreground color.- Throws:
NativeException
- On failure.
-
bold
public Terminal bold() throws NativeException
Description copied from interface:Terminal
Switches the terminal to bold mode, if supported. Does nothing if this terminal does not support bold mode.- Throws:
NativeException
- On failure.
-
normal
public Terminal normal() throws NativeException
Description copied from interface:Terminal
Switches the terminal to normal mode. Supported by all terminals.- Throws:
NativeException
- On failure.
-
reset
public Terminal reset() throws NativeException
Description copied from interface:Terminal
Switches the terminal to normal mode and restores default colors. Supported by all terminals.- Throws:
NativeException
- On failure.
-
cursorLeft
public Terminal cursorLeft(int count) throws NativeException
Description copied from interface:Terminal
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
public Terminal cursorRight(int count) throws NativeException
Description copied from interface:Terminal
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
public Terminal cursorUp(int count) throws NativeException
Description copied from interface:Terminal
Moves the cursor the given number of characters up.- Throws:
NativeException
- On failure, or if this terminal does not support cursor motion.
-
cursorDown
public Terminal cursorDown(int count) throws NativeException
Description copied from interface:Terminal
Moves the cursor the given number of characters down.- Throws:
NativeException
- On failure, or if this terminal does not support cursor motion.
-
cursorStartOfLine
public Terminal cursorStartOfLine() throws NativeException
Description copied from interface:Terminal
Moves the cursor to the start of the current line.- Throws:
NativeException
- On failure, or if this terminal does not support cursor motion.
-
clearToEndOfLine
public Terminal clearToEndOfLine() throws NativeException
Description copied from interface:Terminal
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.
-
-