public class AnsiPrinter
extends java.io.PrintStream
| Modifier and Type | Class and Description |
|---|---|
static class |
AnsiPrinter.Color
Default 16-color scheme for foreground and background text
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
m_enabled
Whether ANSI codes are enabled.
|
| Constructor and Description |
|---|
AnsiPrinter(java.io.OutputStream out)
Instantiates an AnsiPrinter.
|
| Modifier and Type | Method and Description |
|---|---|
AnsiPrinter |
bg(AnsiPrinter.Color c)
Shortcut to
setBackgroundColor(Color). |
boolean |
colorsEnabled()
Determines if the display of colours is enabled
|
void |
disableColors()
Disables the output of ANSI codes in the output stream
|
void |
enableColors()
Enables the output of ANSI codes in the output stream
|
AnsiPrinter |
fg(AnsiPrinter.Color c)
Shortcut to
setForegroundColor(Color). |
static java.lang.String |
padToLength(java.lang.String s,
int length) |
java.lang.String |
readLine()
Reads a line from the standard input
|
AnsiPrinter |
resetColors()
Resets the colors to their default values
|
AnsiPrinter |
setBackgroundColor(AnsiPrinter.Color c)
Sets the background color for printed text.
|
AnsiPrinter |
setBackgroundColor(int r,
int g,
int b)
Sets the background color based on its RGB components.
|
AnsiPrinter |
setForegroundColor(AnsiPrinter.Color c)
Sets the foreground color for printed text.
|
AnsiPrinter |
setForegroundColor(int r,
int g,
int b)
Sets the foreground color based on its RGB components.
|
AnsiPrinter |
setUnderscore() |
AnsiPrinter |
setWhiteOnBlack() |
append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError, write, writeprotected boolean m_enabled
disableColors()), behaves like a normal PrintStreampublic AnsiPrinter(java.io.OutputStream out)
out - The OutputStream where the printer will send its outputpublic void enableColors()
public void disableColors()
public AnsiPrinter setForegroundColor(AnsiPrinter.Color c)
c - The colorpublic AnsiPrinter fg(AnsiPrinter.Color c)
setForegroundColor(Color).c - The colourpublic AnsiPrinter setForegroundColor(int r, int g, int b)
r - The amount of red (R), between 0 and 255g - The amount of green (G), between 0 and 255b - The amount of blue (B), between 0 and 255public AnsiPrinter setBackgroundColor(AnsiPrinter.Color c)
c - The colorpublic AnsiPrinter bg(AnsiPrinter.Color c)
setBackgroundColor(Color).c - The colourpublic AnsiPrinter setBackgroundColor(int r, int g, int b)
r - The amount of red (R), between 0 and 255g - The amount of green (G), between 0 and 255b - The amount of blue (B), between 0 and 255public AnsiPrinter resetColors()
public AnsiPrinter setUnderscore()
public static java.lang.String padToLength(java.lang.String s,
int length)
public java.lang.String readLine()
public boolean colorsEnabled()
public AnsiPrinter setWhiteOnBlack()
Copyright © Sylvain HallĂ©. All Rights Reserved.