public class AnsiOutputStream
extends java.io.FilterOutputStream
process* methods.
For more information about ANSI escape codes, see Wikipedia article
This class just filters out the escape codes so that they are not
sent out to the underlying OutputStream: process* methods
are empty. Subclasses should actually perform the ANSI escape behaviors
by implementing active code in process* methods.
AnsiPrintStream| Modifier and Type | Field and Description |
|---|---|
protected static int |
ATTRIBUTE_BLINK_FAST |
protected static int |
ATTRIBUTE_BLINK_OFF |
protected static int |
ATTRIBUTE_BLINK_SLOW |
protected static int |
ATTRIBUTE_CONCEAL_OFF |
protected static int |
ATTRIBUTE_CONCEAL_ON |
protected static int |
ATTRIBUTE_INTENSITY_BOLD |
protected static int |
ATTRIBUTE_INTENSITY_FAINT |
protected static int |
ATTRIBUTE_INTENSITY_NORMAL |
protected static int |
ATTRIBUTE_ITALIC |
protected static int |
ATTRIBUTE_NEGATIVE_Off
Deprecated.
|
protected static int |
ATTRIBUTE_NEGATIVE_OFF |
protected static int |
ATTRIBUTE_NEGATIVE_ON |
protected static int |
ATTRIBUTE_UNDERLINE |
protected static int |
ATTRIBUTE_UNDERLINE_DOUBLE |
protected static int |
ATTRIBUTE_UNDERLINE_OFF |
private static int |
BEL |
protected static int |
BLACK |
protected static int |
BLUE |
private byte[] |
buffer |
protected static int |
CYAN |
protected static int |
ERASE_LINE |
protected static int |
ERASE_LINE_TO_BEGINING |
protected static int |
ERASE_LINE_TO_END |
protected static int |
ERASE_SCREEN |
protected static int |
ERASE_SCREEN_TO_BEGINING |
protected static int |
ERASE_SCREEN_TO_END |
private static int |
FIRST_ESC_CHAR |
protected static int |
GREEN |
private static int |
LOOKING_FOR_CHARSET |
private static int |
LOOKING_FOR_FIRST_ESC_CHAR |
private static int |
LOOKING_FOR_INT_ARG_END |
private static int |
LOOKING_FOR_NEXT_ARG |
private static int |
LOOKING_FOR_OSC_COMMAND |
private static int |
LOOKING_FOR_OSC_COMMAND_END |
private static int |
LOOKING_FOR_OSC_PARAM |
private static int |
LOOKING_FOR_SECOND_ESC_CHAR |
private static int |
LOOKING_FOR_ST |
private static int |
LOOKING_FOR_STR_ARG_END |
protected static int |
MAGENTA |
private static int |
MAX_ESCAPE_SEQUENCE_LENGTH |
private java.util.ArrayList<java.lang.Object> |
options |
private int |
pos |
protected static int |
RED |
static byte[] |
RESET_CODE |
static byte[] |
REST_CODE
Deprecated.
|
private static int |
SECOND_CHARSET0_CHAR |
private static int |
SECOND_CHARSET1_CHAR |
private static int |
SECOND_ESC_CHAR |
private static int |
SECOND_OSC_CHAR |
private static int |
SECOND_ST_CHAR |
private int |
startOfValue |
(package private) int |
state |
protected static int |
WHITE |
protected static int |
YELLOW |
| Constructor and Description |
|---|
AnsiOutputStream(java.io.OutputStream os) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
private int |
getNextOptionInt(java.util.Iterator<java.lang.Object> optionsIterator)
Helper for processEscapeCommand() to iterate over integer options
|
private int |
optionInt(java.util.ArrayList<java.lang.Object> options,
int index) |
private int |
optionInt(java.util.ArrayList<java.lang.Object> options,
int index,
int defaultValue) |
protected void |
processAttributeRest()
process
SGR 0 corresponding to Reset / Normal |
protected void |
processChangeIconName(java.lang.String label)
process
OSC 1;text BEL corresponding to Change Icon label |
protected void |
processChangeIconNameAndWindowTitle(java.lang.String label)
process
OSC 0;text BEL corresponding to Change Window and Icon label |
protected void |
processChangeWindowTitle(java.lang.String label)
process
OSC 2;text BEL corresponding to Change Window title |
private boolean |
processCharsetSelect(java.util.ArrayList<java.lang.Object> options)
Process character set sequence.
|
protected void |
processCharsetSelect(int set,
char seq) |
protected void |
processCursorDown(int count)
process
CSI n B corresponding to CUD – Cursor Down |
protected void |
processCursorDownLine(int count)
process
CSI n E corresponding to CNL – Cursor Next Line |
protected void |
processCursorLeft(int count)
process
CSI n D corresponding to CUB – Cursor Back |
protected void |
processCursorRight(int count)
process
CSI n C corresponding to CUF – Cursor Forward |
protected void |
processCursorTo(int row,
int col)
process
CSI n ; m H corresponding to CUP – Cursor Position or
CSI n ; m f corresponding to HVP – Horizontal and Vertical Position |
protected void |
processCursorToColumn(int x)
process
CSI n G corresponding to CHA – Cursor Horizontal Absolute |
protected void |
processCursorUp(int count)
process
CSI n A corresponding to CUU – Cursor Up |
protected void |
processCursorUpLine(int count)
process
CSI n F corresponding to CPL – Cursor Previous Line |
protected void |
processDefaultBackgroundColor()
process
SGR 49 corresponding to Default background color |
protected void |
processDefaultTextColor()
process
SGR 39 corresponding to Default text color (foreground) |
protected void |
processDeleteLine(int optionInt)
Process
CSI M ANSI code, corresponding to DL – Delete Line |
protected void |
processEraseLine(int eraseOption)
Process
CSI n K ANSI code, corresponding to ED – Erase in Line |
protected void |
processEraseScreen(int eraseOption)
Process
CSI n J ANSI code, corresponding to ED – Erase in Display |
private boolean |
processEscapeCommand(java.util.ArrayList<java.lang.Object> options,
int command) |
protected void |
processInsertLine(int optionInt)
Process
CSI L ANSI code, corresponding to IL – Insert Line |
private boolean |
processOperatingSystemCommand(java.util.ArrayList<java.lang.Object> options) |
protected void |
processRestoreCursorPosition()
Process
CSI u ANSI code, corresponding to RCP – Restore Cursor Position |
protected void |
processSaveCursorPosition()
Process
CSI s ANSI code, corresponding to SCP – Save Cursor Position |
protected void |
processScrollDown(int optionInt)
Process
CSI n T ANSI code, corresponding to SD – Scroll Down |
protected void |
processScrollUp(int optionInt)
Process
CSI n U ANSI code, corresponding to SU – Scroll Up |
protected void |
processSetAttribute(int attribute)
process
SGR other than 0 (reset), 30-39 (foreground),
40-49 (background), 90-97 (foreground high intensity) or
100-107 (background high intensity) |
protected void |
processSetBackgroundColor(int color)
process
SGR 40-47 corresponding to Set background color. |
protected void |
processSetBackgroundColor(int color,
boolean bright)
process
SGR 40-47 or SGR 100-107 corresponding to
Set background color either in normal mode or high intensity. |
protected void |
processSetBackgroundColorExt(int paletteIndex)
process
SGR 48 corresponding to extended set background color
with a palette of 255 colors. |
protected void |
processSetBackgroundColorExt(int r,
int g,
int b)
process
SGR 48 corresponding to extended set background color
with a 24 bits RGB definition of the color. |
protected void |
processSetForegroundColor(int color)
process
SGR 30-37 corresponding to Set text color (foreground). |
protected void |
processSetForegroundColor(int color,
boolean bright)
process
SGR 30-37 or SGR 90-97 corresponding to
Set text color (foreground) either in normal mode or high intensity. |
protected void |
processSetForegroundColorExt(int paletteIndex)
process
SGR 38 corresponding to extended set text color (foreground)
with a palette of 255 colors. |
protected void |
processSetForegroundColorExt(int r,
int g,
int b)
process
SGR 38 corresponding to extended set text color (foreground)
with a 24 bits RGB definition of the color. |
protected void |
processUnknownExtension(java.util.ArrayList<java.lang.Object> options,
int command) |
protected void |
processUnknownOperatingSystemCommand(int command,
java.lang.String param)
Process unknown
OSC command. |
private void |
reset(boolean skipBuffer)
Resets all state to continue with regular parsing
|
void |
write(int data) |
public static final byte[] RESET_CODE
@Deprecated public static final byte[] REST_CODE
private static final int MAX_ESCAPE_SEQUENCE_LENGTH
private final byte[] buffer
private int pos
private int startOfValue
private final java.util.ArrayList<java.lang.Object> options
private static final int LOOKING_FOR_FIRST_ESC_CHAR
private static final int LOOKING_FOR_SECOND_ESC_CHAR
private static final int LOOKING_FOR_NEXT_ARG
private static final int LOOKING_FOR_STR_ARG_END
private static final int LOOKING_FOR_INT_ARG_END
private static final int LOOKING_FOR_OSC_COMMAND
private static final int LOOKING_FOR_OSC_COMMAND_END
private static final int LOOKING_FOR_OSC_PARAM
private static final int LOOKING_FOR_ST
private static final int LOOKING_FOR_CHARSET
int state
private static final int FIRST_ESC_CHAR
private static final int SECOND_ESC_CHAR
private static final int SECOND_OSC_CHAR
private static final int BEL
private static final int SECOND_ST_CHAR
private static final int SECOND_CHARSET0_CHAR
private static final int SECOND_CHARSET1_CHAR
protected static final int ERASE_SCREEN_TO_END
protected static final int ERASE_SCREEN_TO_BEGINING
protected static final int ERASE_SCREEN
protected static final int ERASE_LINE_TO_END
protected static final int ERASE_LINE_TO_BEGINING
protected static final int ERASE_LINE
protected static final int ATTRIBUTE_INTENSITY_BOLD
protected static final int ATTRIBUTE_INTENSITY_FAINT
protected static final int ATTRIBUTE_ITALIC
protected static final int ATTRIBUTE_UNDERLINE
protected static final int ATTRIBUTE_BLINK_SLOW
protected static final int ATTRIBUTE_BLINK_FAST
protected static final int ATTRIBUTE_NEGATIVE_ON
protected static final int ATTRIBUTE_CONCEAL_ON
protected static final int ATTRIBUTE_UNDERLINE_DOUBLE
protected static final int ATTRIBUTE_INTENSITY_NORMAL
protected static final int ATTRIBUTE_UNDERLINE_OFF
protected static final int ATTRIBUTE_BLINK_OFF
@Deprecated protected static final int ATTRIBUTE_NEGATIVE_Off
protected static final int ATTRIBUTE_NEGATIVE_OFF
protected static final int ATTRIBUTE_CONCEAL_OFF
protected static final int BLACK
protected static final int RED
protected static final int GREEN
protected static final int YELLOW
protected static final int BLUE
protected static final int MAGENTA
protected static final int CYAN
protected static final int WHITE
public void write(int data)
throws java.io.IOException
write in class java.io.FilterOutputStreamjava.io.IOExceptionprivate void reset(boolean skipBuffer)
throws java.io.IOException
skipBuffer - if current buffer should be skipped or written to outjava.io.IOExceptionprivate int getNextOptionInt(java.util.Iterator<java.lang.Object> optionsIterator)
throws java.io.IOException
optionsIterator - the underlying iteratorjava.io.IOException - if no more non-null values leftprivate boolean processEscapeCommand(java.util.ArrayList<java.lang.Object> options,
int command)
throws java.io.IOException
options - command - java.io.IOExceptionprivate boolean processOperatingSystemCommand(java.util.ArrayList<java.lang.Object> options)
throws java.io.IOException
options - java.io.IOExceptionprotected void processRestoreCursorPosition()
throws java.io.IOException
CSI u ANSI code, corresponding to RCP – Restore Cursor Positionjava.io.IOException - IOExceptionprotected void processSaveCursorPosition()
throws java.io.IOException
CSI s ANSI code, corresponding to SCP – Save Cursor Positionjava.io.IOException - IOExceptionprotected void processInsertLine(int optionInt)
throws java.io.IOException
CSI L ANSI code, corresponding to IL – Insert LineoptionInt - optionjava.io.IOException - IOExceptionprotected void processDeleteLine(int optionInt)
throws java.io.IOException
CSI M ANSI code, corresponding to DL – Delete LineoptionInt - optionjava.io.IOException - IOExceptionprotected void processScrollDown(int optionInt)
throws java.io.IOException
CSI n T ANSI code, corresponding to SD – Scroll DownoptionInt - optionjava.io.IOException - IOExceptionprotected void processScrollUp(int optionInt)
throws java.io.IOException
CSI n U ANSI code, corresponding to SU – Scroll UpoptionInt - optionjava.io.IOException - IOExceptionprotected void processEraseScreen(int eraseOption)
throws java.io.IOException
CSI n J ANSI code, corresponding to ED – Erase in DisplayeraseOption - eraseOptionjava.io.IOException - IOExceptionprotected void processEraseLine(int eraseOption)
throws java.io.IOException
CSI n K ANSI code, corresponding to ED – Erase in LineeraseOption - eraseOptionjava.io.IOException - IOExceptionprotected void processSetAttribute(int attribute)
throws java.io.IOException
SGR other than 0 (reset), 30-39 (foreground),
40-49 (background), 90-97 (foreground high intensity) or
100-107 (background high intensity)attribute - attributejava.io.IOException - IOExceptionprocessAttributeRest(),
processSetForegroundColor(int),
processSetForegroundColor(int, boolean),
processSetForegroundColorExt(int),
processSetForegroundColorExt(int, int, int),
processDefaultTextColor(),
processDefaultBackgroundColor()protected void processSetForegroundColor(int color)
throws java.io.IOException
SGR 30-37 corresponding to Set text color (foreground).color - the text colorjava.io.IOException - IOExceptionprotected void processSetForegroundColor(int color,
boolean bright)
throws java.io.IOException
SGR 30-37 or SGR 90-97 corresponding to
Set text color (foreground) either in normal mode or high intensity.color - the text colorbright - is high intensity?java.io.IOException - IOExceptionprotected void processSetForegroundColorExt(int paletteIndex)
throws java.io.IOException
SGR 38 corresponding to extended set text color (foreground)
with a palette of 255 colors.paletteIndex - the text color in the palettejava.io.IOException - IOExceptionprotected void processSetForegroundColorExt(int r,
int g,
int b)
throws java.io.IOException
SGR 38 corresponding to extended set text color (foreground)
with a 24 bits RGB definition of the color.r - redg - greenb - bluejava.io.IOException - IOExceptionprotected void processSetBackgroundColor(int color)
throws java.io.IOException
SGR 40-47 corresponding to Set background color.color - the background colorjava.io.IOException - IOExceptionprotected void processSetBackgroundColor(int color,
boolean bright)
throws java.io.IOException
SGR 40-47 or SGR 100-107 corresponding to
Set background color either in normal mode or high intensity.color - the background colorbright - is high intensity?java.io.IOException - IOExceptionprotected void processSetBackgroundColorExt(int paletteIndex)
throws java.io.IOException
SGR 48 corresponding to extended set background color
with a palette of 255 colors.paletteIndex - the background color in the palettejava.io.IOException - IOExceptionprotected void processSetBackgroundColorExt(int r,
int g,
int b)
throws java.io.IOException
SGR 48 corresponding to extended set background color
with a 24 bits RGB definition of the color.r - redg - greenb - bluejava.io.IOException - IOExceptionprotected void processDefaultTextColor()
throws java.io.IOException
SGR 39 corresponding to Default text color (foreground)java.io.IOException - IOExceptionprotected void processDefaultBackgroundColor()
throws java.io.IOException
SGR 49 corresponding to Default background colorjava.io.IOException - IOExceptionprotected void processAttributeRest()
throws java.io.IOException
SGR 0 corresponding to Reset / Normaljava.io.IOException - IOExceptionprotected void processCursorTo(int row,
int col)
throws java.io.IOException
CSI n ; m H corresponding to CUP – Cursor Position or
CSI n ; m f corresponding to HVP – Horizontal and Vertical Positionrow - rowcol - columnjava.io.IOException - IOExceptionprotected void processCursorToColumn(int x)
throws java.io.IOException
CSI n G corresponding to CHA – Cursor Horizontal Absolutex - the columnjava.io.IOException - IOExceptionprotected void processCursorUpLine(int count)
throws java.io.IOException
CSI n F corresponding to CPL – Cursor Previous Linecount - line countjava.io.IOException - IOExceptionprotected void processCursorDownLine(int count)
throws java.io.IOException
CSI n E corresponding to CNL – Cursor Next Linecount - line countjava.io.IOException - IOExceptionprotected void processCursorLeft(int count)
throws java.io.IOException
CSI n D corresponding to CUB – Cursor Backcount - numer of characters to move leftjava.io.IOException - IOExceptionprotected void processCursorRight(int count)
throws java.io.IOException
CSI n C corresponding to CUF – Cursor Forwardcount - number of characters to move onjava.io.IOException - IOExceptionprotected void processCursorDown(int count)
throws java.io.IOException
CSI n B corresponding to CUD – Cursor Downcount - numer of linejava.io.IOException - IOExceptionprotected void processCursorUp(int count)
throws java.io.IOException
CSI n A corresponding to CUU – Cursor Upcount - number of linesjava.io.IOException - IOExceptionprotected void processUnknownExtension(java.util.ArrayList<java.lang.Object> options,
int command)
protected void processChangeIconNameAndWindowTitle(java.lang.String label)
OSC 0;text BEL corresponding to Change Window and Icon labellabel - window labelprotected void processChangeIconName(java.lang.String label)
OSC 1;text BEL corresponding to Change Icon labellabel - icon label nameprotected void processChangeWindowTitle(java.lang.String label)
OSC 2;text BEL corresponding to Change Window titlelabel - window labelprotected void processUnknownOperatingSystemCommand(int command,
java.lang.String param)
OSC command.command - commandparam - command paramprivate boolean processCharsetSelect(java.util.ArrayList<java.lang.Object> options)
options - set of optionsprotected void processCharsetSelect(int set,
char seq)
private int optionInt(java.util.ArrayList<java.lang.Object> options,
int index)
private int optionInt(java.util.ArrayList<java.lang.Object> options,
int index,
int defaultValue)
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.FilterOutputStreamjava.io.IOException