Top Description Fields Constructors Methods
org.fusesource.jansi.io

public Class AnsiProcessor

extends Object
Class Inheritance
Known Direct Subclasses
org.fusesource.jansi.io.ColorsAnsiProcessor, org.fusesource.jansi.io.WindowsAnsiProcessor
Annotations
@SuppressWarnings:unused
Imports
java.io.IOException, .OutputStream, java.util.ArrayList, .Iterator

ANSI processor providing process* corresponding to ANSI escape codes. This class methods implementations are empty: subclasses should actually perform the ANSI escape behaviors by implementing active code in process* methods.

For more information about ANSI escape codes, see Wikipedia article

Since
1.19

Field Summary

Modifier and TypeField and Description
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected final OutputStream
protected static final int
protected static final int
protected static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected int
getNextOptionInt(Iterator<Object>
the underlying iterator
optionsIterator
)

Helper for processEscapeCommand() to iterate over integer options

private int
optionInt(ArrayList<Object> options, int index)

private int
optionInt(ArrayList<Object> options, int index, int defaultValue)

protected void
processAttributeReset()

process SGR 0 corresponding to Reset / Normal

protected void
processChangeIconName(String
icon label
label
)

process OSC 1;text BEL corresponding to Change Icon label

protected void
processChangeIconNameAndWindowTitle(String
window title name
label
)

process OSC 0;text BEL corresponding to Change Window and Icon label

protected void
processChangeWindowTitle(String
window title text
label
)

process OSC 2;text BEL corresponding to Change Window title

protected boolean

Returns:

true if the charcter set select command was processed.
processCharsetSelect
(ArrayList<Object>
options
options
)

Process character set sequence.

protected void
processCharsetSelect(int set, char seq)

protected void
processCursorDown(int
count
count
)

process CSI n B corresponding to CUD – Cursor Down

protected void
processCursorDownLine(int
line count
count
)

process CSI n E corresponding to CNL – Cursor Next Line

protected void
processCursorLeft(int
count
count
)

process CSI n D corresponding to CUB – Cursor Back

protected void
processCursorRight(int
count
count
)

process CSI n C corresponding to CUF – Cursor Forward

protected void
processCursorTo(int
row
row
,
int
col
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
the column
x
)

process CSI n G corresponding to CHA – Cursor Horizontal Absolute

protected void
processCursorUp(int
count
count
)

process CSI n A corresponding to CUU – Cursor Up

protected void
processCursorUpLine(int
line count
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
option
optionInt
)

Process CSI M ANSI code, corresponding to DL – Delete Line

protected void
processEraseLine(int
eraseOption
eraseOption
)

Process CSI n K ANSI code, corresponding to ED – Erase in Line

protected void
processEraseScreen(int
eraseOption
eraseOption
)

Process CSI n J ANSI code, corresponding to ED – Erase in Display

protected boolean

Returns:

true if the escape command was processed.
processEscapeCommand
(ArrayList<Object> options, int command)

protected void
processInsertLine(int
option
optionInt
)

Process CSI L ANSI code, corresponding to IL – Insert Line

protected boolean

Returns:

true if the operating system command was processed.
processOperatingSystemCommand
(ArrayList<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
option
optionInt
)

Process CSI n T ANSI code, corresponding to SD – Scroll Down

protected void
processScrollUp(int
option
optionInt
)

Process CSI n U ANSI code, corresponding to SU – Scroll Up

protected void
processSetAttribute(int
attribute
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
the background color
color
)

process SGR 40-47 corresponding to Set background color.

protected void
processSetBackgroundColor(int
the background color
color
,
boolean
is high intensity?
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
the background color in the palette
paletteIndex
)

process SGR 48 corresponding to extended set background color with a palette of 255 colors.

protected void
processSetBackgroundColorExt(int
red
r
,
int
green
g
,
int
blue
b
)

process SGR 48 corresponding to extended set background color with a 24 bits RGB definition of the color.

protected void
processSetForegroundColor(int
the text color
color
)

process SGR 30-37 corresponding to Set text color (foreground).

protected void
processSetForegroundColor(int
the text color
color
,
boolean
is high intensity?
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
the text color in the palette
paletteIndex
)

process SGR 38 corresponding to extended set text color (foreground) with a palette of 255 colors.

protected void
processSetForegroundColorExt(int
red
r
,
int
green
g
,
int
blue
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
options
,
int
command
command
)

Process Unknown Extension

protected void
processUnknownOperatingSystemCommand(int
command
command
,
String
param
param
)

Process unknown OSC command.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ATTRIBUTE_CONCEAL_OFFback to summary
protected static final int ATTRIBUTE_CONCEAL_OFF
ATTRIBUTE_CONCEAL_ONback to summary
protected static final int ATTRIBUTE_CONCEAL_ON
ATTRIBUTE_INTENSITY_BOLDback to summary
protected static final int ATTRIBUTE_INTENSITY_BOLD
ATTRIBUTE_INTENSITY_FAINTback to summary
protected static final int ATTRIBUTE_INTENSITY_FAINT
ATTRIBUTE_INTENSITY_NORMALback to summary
protected static final int ATTRIBUTE_INTENSITY_NORMAL
ATTRIBUTE_ITALICback to summary
protected static final int ATTRIBUTE_ITALIC
ATTRIBUTE_NEGATIVE_OFFback to summary
protected static final int ATTRIBUTE_NEGATIVE_OFF
ATTRIBUTE_NEGATIVE_ONback to summary
protected static final int ATTRIBUTE_NEGATIVE_ON
ATTRIBUTE_UNDERLINEback to summary
protected static final int ATTRIBUTE_UNDERLINE
ATTRIBUTE_UNDERLINE_DOUBLEback to summary
protected static final int ATTRIBUTE_UNDERLINE_DOUBLE
ATTRIBUTE_UNDERLINE_OFFback to summary
protected static final int ATTRIBUTE_UNDERLINE_OFF
BLACKback to summary
protected static final int BLACK
BLUEback to summary
protected static final int BLUE
CYANback to summary
protected static final int CYAN
ERASE_LINEback to summary
protected static final int ERASE_LINE
ERASE_LINE_TO_BEGININGback to summary
protected static final int ERASE_LINE_TO_BEGINING
ERASE_LINE_TO_ENDback to summary
protected static final int ERASE_LINE_TO_END
ERASE_SCREENback to summary
protected static final int ERASE_SCREEN
ERASE_SCREEN_TO_BEGININGback to summary
protected static final int ERASE_SCREEN_TO_BEGINING
ERASE_SCREEN_TO_ENDback to summary
protected static final int ERASE_SCREEN_TO_END
GREENback to summary
protected static final int GREEN
MAGENTAback to summary
protected static final int MAGENTA
osback to summary
protected final OutputStream os
REDback to summary
protected static final int RED
WHITEback to summary
protected static final int WHITE
YELLOWback to summary
protected static final int YELLOW

Constructor Detail

AnsiProcessorback to summary
public AnsiProcessor(OutputStream os)

Method Detail

getNextOptionIntback to summary
protected int getNextOptionInt(Iterator<Object> optionsIterator) throws IOException

Helper for processEscapeCommand() to iterate over integer options

Parameters
optionsIterator:Iterator<Object>

the underlying iterator

Exceptions
IOException:
if no more non-null values left
optionIntback to summary
private int optionInt(ArrayList<Object> options, int index)
optionIntback to summary
private int optionInt(ArrayList<Object> options, int index, int defaultValue)
processAttributeResetback to summary
protected void processAttributeReset() throws IOException

process SGR 0 corresponding to Reset / Normal

Exceptions
IOException:
IOException
processChangeIconNameback to summary
protected void processChangeIconName(String label)

process OSC 1;text BEL corresponding to Change Icon label

Parameters
label:String

icon label

processChangeIconNameAndWindowTitleback to summary
protected void processChangeIconNameAndWindowTitle(String label)

process OSC 0;text BEL corresponding to Change Window and Icon label

Parameters
label:String

window title name

processChangeWindowTitleback to summary
protected void processChangeWindowTitle(String label)

process OSC 2;text BEL corresponding to Change Window title

Parameters
label:String

window title text

processCharsetSelectback to summary
protected boolean processCharsetSelect(ArrayList<Object> options)

Process character set sequence.

Parameters
options:ArrayList<Object>

options

Returns:boolean

true if the charcter set select command was processed.

processCharsetSelectback to summary
protected void processCharsetSelect(int set, char seq)
processCursorDownback to summary
protected void processCursorDown(int count) throws IOException

process CSI n B corresponding to CUD – Cursor Down

Parameters
count:int

count

Exceptions
IOException:
IOException
processCursorDownLineback to summary
protected void processCursorDownLine(int count) throws IOException

process CSI n E corresponding to CNL – Cursor Next Line

Parameters
count:int

line count

Exceptions
IOException:
IOException
processCursorLeftback to summary
protected void processCursorLeft(int count) throws IOException

process CSI n D corresponding to CUB – Cursor Back

Parameters
count:int

count

Exceptions
IOException:
IOException
processCursorRightback to summary
protected void processCursorRight(int count) throws IOException

process CSI n C corresponding to CUF – Cursor Forward

Parameters
count:int

count

Exceptions
IOException:
IOException
processCursorToback to summary
protected void processCursorTo(int row, int col) throws IOException

process CSI n ; m H corresponding to CUP – Cursor Position or CSI n ; m f corresponding to HVP – Horizontal and Vertical Position

Parameters
row:int

row

col:int

col

Exceptions
IOException:
IOException
processCursorToColumnback to summary
protected void processCursorToColumn(int x) throws IOException

process CSI n G corresponding to CHA – Cursor Horizontal Absolute

Parameters
x:int

the column

Exceptions
IOException:
IOException
processCursorUpback to summary
protected void processCursorUp(int count) throws IOException

process CSI n A corresponding to CUU – Cursor Up

Parameters
count:int

count

Exceptions
IOException:
IOException
processCursorUpLineback to summary
protected void processCursorUpLine(int count) throws IOException

process CSI n F corresponding to CPL – Cursor Previous Line

Parameters
count:int

line count

Exceptions
IOException:
IOException
processDefaultBackgroundColorback to summary
protected void processDefaultBackgroundColor() throws IOException

process SGR 49 corresponding to Default background color

Exceptions
IOException:
IOException
processDefaultTextColorback to summary
protected void processDefaultTextColor() throws IOException

process SGR 39 corresponding to Default text color (foreground)

Exceptions
IOException:
IOException
processDeleteLineback to summary
protected void processDeleteLine(int optionInt) throws IOException

Process CSI M ANSI code, corresponding to DL – Delete Line

Parameters
optionInt:int

option

Exceptions
IOException:
IOException
Since
1.16
processEraseLineback to summary
protected void processEraseLine(int eraseOption) throws IOException

Process CSI n K ANSI code, corresponding to ED – Erase in Line

Parameters
eraseOption:int

eraseOption

Exceptions
IOException:
IOException
processEraseScreenback to summary
protected void processEraseScreen(int eraseOption) throws IOException

Process CSI n J ANSI code, corresponding to ED – Erase in Display

Parameters
eraseOption:int

eraseOption

Exceptions
IOException:
IOException
processEscapeCommandback to summary
protected boolean processEscapeCommand(ArrayList<Object> options, int command) throws IOException
Returns:boolean

true if the escape command was processed.

processInsertLineback to summary
protected void processInsertLine(int optionInt) throws IOException

Process CSI L ANSI code, corresponding to IL – Insert Line

Parameters
optionInt:int

option

Exceptions
IOException:
IOException
Since
1.16
processOperatingSystemCommandback to summary
protected boolean processOperatingSystemCommand(ArrayList<Object> options)
Returns:boolean

true if the operating system command was processed.

processRestoreCursorPositionback to summary
protected void processRestoreCursorPosition() throws IOException

Process CSI u ANSI code, corresponding to RCP – Restore Cursor Position

Exceptions
IOException:
IOException
processSaveCursorPositionback to summary
protected void processSaveCursorPosition() throws IOException

Process CSI s ANSI code, corresponding to SCP – Save Cursor Position

Exceptions
IOException:
IOException
processScrollDownback to summary
protected void processScrollDown(int optionInt) throws IOException

Process CSI n T ANSI code, corresponding to SD – Scroll Down

Parameters
optionInt:int

option

Exceptions
IOException:
IOException
processScrollUpback to summary
protected void processScrollUp(int optionInt) throws IOException

Process CSI n U ANSI code, corresponding to SU – Scroll Up

Parameters
optionInt:int

option

Exceptions
IOException:
IOException
processSetAttributeback to summary
protected void processSetAttribute(int attribute) throws IOException

process SGR other than 0 (reset), 30-39 (foreground), 40-49 (background), 90-97 (foreground high intensity) or 100-107 (background high intensity)

Parameters
attribute:int

attribute

Exceptions
IOException:
IOException
See Also
processAttributeReset(), processSetForegroundColor(int), processSetForegroundColor(int, boolean), processSetForegroundColorExt(int), processSetForegroundColorExt(int, int, int), processDefaultTextColor(), processDefaultBackgroundColor()
processSetBackgroundColorback to summary
protected void processSetBackgroundColor(int color) throws IOException

process SGR 40-47 corresponding to Set background color.

Parameters
color:int

the background color

Exceptions
IOException:
IOException
processSetBackgroundColorback to summary
protected void processSetBackgroundColor(int color, boolean bright) throws IOException

process SGR 40-47 or SGR 100-107 corresponding to Set background color either in normal mode or high intensity.

Parameters
color:int

the background color

bright:boolean

is high intensity?

Exceptions
IOException:
IOException
processSetBackgroundColorExtback to summary
protected void processSetBackgroundColorExt(int paletteIndex) throws IOException

process SGR 48 corresponding to extended set background color with a palette of 255 colors.

Parameters
paletteIndex:int

the background color in the palette

Exceptions
IOException:
IOException
processSetBackgroundColorExtback to summary
protected void processSetBackgroundColorExt(int r, int g, int b) throws IOException

process SGR 48 corresponding to extended set background color with a 24 bits RGB definition of the color.

Parameters
r:int

red

g:int

green

b:int

blue

Exceptions
IOException:
IOException
processSetForegroundColorback to summary
protected void processSetForegroundColor(int color) throws IOException

process SGR 30-37 corresponding to Set text color (foreground).

Parameters
color:int

the text color

Exceptions
IOException:
IOException
processSetForegroundColorback to summary
protected void processSetForegroundColor(int color, boolean bright) throws IOException

process SGR 30-37 or SGR 90-97 corresponding to Set text color (foreground) either in normal mode or high intensity.

Parameters
color:int

the text color

bright:boolean

is high intensity?

Exceptions
IOException:
IOException
processSetForegroundColorExtback to summary
protected void processSetForegroundColorExt(int paletteIndex) throws IOException

process SGR 38 corresponding to extended set text color (foreground) with a palette of 255 colors.

Parameters
paletteIndex:int

the text color in the palette

Exceptions
IOException:
IOException
processSetForegroundColorExtback to summary
protected void processSetForegroundColorExt(int r, int g, int b) throws IOException

process SGR 38 corresponding to extended set text color (foreground) with a 24 bits RGB definition of the color.

Parameters
r:int

red

g:int

green

b:int

blue

Exceptions
IOException:
IOException
processUnknownExtensionback to summary
protected void processUnknownExtension(ArrayList<Object> options, int command)

Process Unknown Extension

Parameters
options:ArrayList<Object>

options

command:int

command

processUnknownOperatingSystemCommandback to summary
protected void processUnknownOperatingSystemCommand(int command, String param)

Process unknown OSC command.

Parameters
command:int

command

param:String

param