public class AnsiWriter extends FilterWriter
Writer
and calls corresponding process*
methods.
For more information about ANSI escape codes, see:
http://en.wikipedia.org/wiki/ANSI_escape_code
This class just filters out the escape codes so that they are not
sent out to the underlying Writer
: process*
methods
are empty. Subclasses should actually perform the ANSI escape behaviors
by implementing active code in process*
methods.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 |
protected static int |
ATTRIBUTE_NEGATIVE_ON |
protected static int |
ATTRIBUTE_UNDERLINE |
protected static int |
ATTRIBUTE_UNDERLINE_DOUBLE |
protected static int |
ATTRIBUTE_UNDERLINE_OFF |
protected static int |
BLACK |
protected static int |
BLUE |
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 |
protected static int |
GREEN |
protected static int |
MAGENTA |
protected static int |
RED |
protected static int |
WHITE |
protected static int |
YELLOW |
out
Constructor and Description |
---|
AnsiWriter(Writer out) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
processAttributeRest()
process
SGR 0 corresponding to Reset / Normal |
protected void |
processChangeIconName(String name)
process
OSC 1;text BEL corresponding to Change Icon label |
protected void |
processChangeIconNameAndWindowTitle(String label)
process
OSC 0;text BEL corresponding to Change Window and Icon label |
protected void |
processChangeWindowTitle(String title)
process
OSC 2;text BEL corresponding to Change Window title |
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 s 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 |
protected void |
processInsertLine(int optionInt)
Process
CSI s ANSI code, corresponding to IL – Insert Line |
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(ArrayList<Object> options,
int command) |
protected void |
processUnknownOperatingSystemCommand(int command,
String param)
Process unknown
OSC command. |
void |
write(char[] cbuf,
int off,
int len) |
void |
write(int data) |
void |
write(String str,
int off,
int len) |
flush
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
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 AnsiWriter(Writer out)
public void write(int data) throws IOException
write
in class FilterWriter
IOException
protected void processRestoreCursorPosition() throws IOException
CSI u
ANSI code, corresponding to RCP – Restore Cursor Position
IOException
- if an error occursprotected void processSaveCursorPosition() throws IOException
CSI s
ANSI code, corresponding to SCP – Save Cursor Position
IOException
- if an error occursprotected void processInsertLine(int optionInt) throws IOException
CSI s
ANSI code, corresponding to IL – Insert Line
optionInt
- the optionIOException
- if an error occursprotected void processDeleteLine(int optionInt) throws IOException
CSI s
ANSI code, corresponding to DL – Delete Line
optionInt
- the optionIOException
- if an error occursprotected void processScrollDown(int optionInt) throws IOException
CSI n T
ANSI code, corresponding to SD – Scroll Down
optionInt
- the optionIOException
- if an error occursprotected void processScrollUp(int optionInt) throws IOException
CSI n U
ANSI code, corresponding to SU – Scroll Up
optionInt
- the optionIOException
- if an error occursprotected void processEraseScreen(int eraseOption) throws IOException
CSI n J
ANSI code, corresponding to ED – Erase in Display
eraseOption
- the erase optionIOException
- if an error occursprotected void processEraseLine(int eraseOption) throws IOException
CSI n K
ANSI code, corresponding to ED – Erase in Line
eraseOption
- the erase optionIOException
- if an error occursprotected void processSetAttribute(int attribute) throws IOException
SGR
other than 0
(reset), 30-39
(foreground),
40-49
(background), 90-97
(foreground high intensity) or
100-107
(background high intensity)attribute
- the attribute to setIOException
- if an error occursAnsiWriter.processAttributeRest()
,
AnsiWriter.processSetForegroundColor(int)
,
AnsiWriter.processSetForegroundColor(int, boolean)
,
AnsiWriter.processSetForegroundColorExt(int)
,
AnsiWriter.processSetForegroundColorExt(int, int, int)
,
AnsiWriter.processDefaultTextColor()
,
AnsiWriter.processDefaultBackgroundColor()
protected void processSetForegroundColor(int color) throws IOException
SGR 30-37
corresponding to Set text color (foreground)
.color
- the text colorIOException
- if an error occursprotected void processSetForegroundColor(int color, boolean bright) throws 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?IOException
- if an error occursprotected void processSetForegroundColorExt(int paletteIndex) throws IOException
SGR 38
corresponding to extended set text color (foreground)
with a palette of 255 colors.paletteIndex
- the text color in the paletteIOException
- if an error occursprotected void processSetForegroundColorExt(int r, int g, int b) throws IOException
SGR 38
corresponding to extended set text color (foreground)
with a 24 bits RGB definition of the color.r
- redg
- greenb
- blueIOException
- if an error occursprotected void processSetBackgroundColor(int color) throws IOException
SGR 40-47
corresponding to Set background color
.color
- the background colorIOException
- if an error occursprotected void processSetBackgroundColor(int color, boolean bright) throws 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?IOException
- if an error occursprotected void processSetBackgroundColorExt(int paletteIndex) throws IOException
SGR 48
corresponding to extended set background color
with a palette of 255 colors.paletteIndex
- the background color in the paletteIOException
- if an error occursprotected void processSetBackgroundColorExt(int r, int g, int b) throws IOException
SGR 48
corresponding to extended set background color
with a 24 bits RGB definition of the color.r
- redg
- greenb
- blueIOException
- if an error occursprotected void processDefaultTextColor() throws IOException
SGR 39
corresponding to Default text color (foreground)
IOException
- if an error occursprotected void processDefaultBackgroundColor() throws IOException
SGR 49
corresponding to Default background color
IOException
- if an error occursprotected void processAttributeRest() throws IOException
SGR 0
corresponding to Reset / Normal
IOException
- if an error occursprotected void processCursorTo(int row, int col) throws IOException
CSI n ; m H
corresponding to CUP – Cursor Position
or
CSI n ; m f
corresponding to HVP – Horizontal and Vertical Position
row
- the rowcol
- the columnIOException
- if an error occursprotected void processCursorToColumn(int x) throws IOException
CSI n G
corresponding to CHA – Cursor Horizontal Absolute
x
- the columnIOException
- if an error occursprotected void processCursorUpLine(int count) throws IOException
CSI n F
corresponding to CPL – Cursor Previous Line
count
- line countIOException
- if an error occursprotected void processCursorDownLine(int count) throws IOException
CSI n E
corresponding to CNL – Cursor Next Line
count
- line countIOException
- if an error occursprotected void processCursorLeft(int count) throws IOException
CSI n D
corresponding to CUB – Cursor Back
count
- the countIOException
- if an error occursprotected void processCursorRight(int count) throws IOException
CSI n C
corresponding to CUF – Cursor Forward
count
- the countIOException
- if an error occursprotected void processCursorDown(int count) throws IOException
CSI n B
corresponding to CUD – Cursor Down
count
- the countIOException
- if an error occursprotected void processCursorUp(int count) throws IOException
CSI n A
corresponding to CUU – Cursor Up
count
- the countIOException
- if an error occursprotected void processUnknownExtension(ArrayList<Object> options, int command)
protected void processChangeIconNameAndWindowTitle(String label)
OSC 0;text BEL
corresponding to Change Window and Icon label
label
- the labelprotected void processChangeIconName(String name)
OSC 1;text BEL
corresponding to Change Icon label
name
- the icon nameprotected void processChangeWindowTitle(String title)
OSC 2;text BEL
corresponding to Change Window title
title
- the titleprotected void processUnknownOperatingSystemCommand(int command, String param)
OSC
command.command
- the commandparam
- the paramprotected void processCharsetSelect(int set, char seq)
public void write(char[] cbuf, int off, int len) throws IOException
write
in class FilterWriter
IOException
public void write(String str, int off, int len) throws IOException
write
in class FilterWriter
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class FilterWriter
IOException