Package org.fusesource.jansi.io
Class AnsiProcessor
- java.lang.Object
-
- org.fusesource.jansi.io.AnsiProcessor
-
- Direct Known Subclasses:
ColorsAnsiProcessor
,WindowsAnsiProcessor
public class AnsiProcessor extends Object
ANSI processor providingprocess*
corresponding to ANSI escape codes. This class methods implementations are empty: subclasses should actually perform the ANSI escape behaviors by implementing active code inprocess*
methods.For more information about ANSI escape codes, see Wikipedia article
- Since:
- 1.19
-
-
Field Summary
Fields Modifier and Type Field 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 OutputStream
os
protected static int
RED
protected static int
WHITE
protected static int
YELLOW
-
Constructor Summary
Constructors Constructor Description AnsiProcessor(OutputStream os)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
getNextOptionInt(Iterator<Object> optionsIterator)
Helper for processEscapeCommand() to iterate over integer optionsprotected void
processAttributeReset()
processSGR 0
corresponding toReset / Normal
protected void
processChangeIconName(String label)
processOSC 1;text BEL
corresponding toChange Icon label
protected void
processChangeIconNameAndWindowTitle(String label)
processOSC 0;text BEL
corresponding toChange Window and Icon label
protected void
processChangeWindowTitle(String label)
processOSC 2;text BEL
corresponding toChange Window title
protected void
processCharsetSelect(int set, char seq)
protected boolean
processCharsetSelect(ArrayList<Object> options)
Process character set sequence.protected void
processCursorDown(int count)
processCSI n B
corresponding toCUD – Cursor Down
protected void
processCursorDownLine(int count)
processCSI n E
corresponding toCNL – Cursor Next Line
protected void
processCursorLeft(int count)
processCSI n D
corresponding toCUB – Cursor Back
protected void
processCursorRight(int count)
processCSI n C
corresponding toCUF – Cursor Forward
protected void
processCursorTo(int row, int col)
processCSI n ; m H
corresponding toCUP – Cursor Position
orCSI n ; m f
corresponding toHVP – Horizontal and Vertical Position
protected void
processCursorToColumn(int x)
processCSI n G
corresponding toCHA – Cursor Horizontal Absolute
protected void
processCursorUp(int count)
processCSI n A
corresponding toCUU – Cursor Up
protected void
processCursorUpLine(int count)
processCSI n F
corresponding toCPL – Cursor Previous Line
protected void
processDefaultBackgroundColor()
processSGR 49
corresponding toDefault background color
protected void
processDefaultTextColor()
processSGR 39
corresponding toDefault text color (foreground)
protected void
processDeleteLine(int optionInt)
ProcessCSI M
ANSI code, corresponding toDL – Delete Line
protected void
processEraseLine(int eraseOption)
ProcessCSI n K
ANSI code, corresponding toED – Erase in Line
protected void
processEraseScreen(int eraseOption)
ProcessCSI n J
ANSI code, corresponding toED – Erase in Display
protected boolean
processEscapeCommand(ArrayList<Object> options, int command)
protected void
processInsertLine(int optionInt)
ProcessCSI L
ANSI code, corresponding toIL – Insert Line
protected boolean
processOperatingSystemCommand(ArrayList<Object> options)
protected void
processRestoreCursorPosition()
ProcessCSI u
ANSI code, corresponding toRCP – Restore Cursor Position
protected void
processSaveCursorPosition()
ProcessCSI s
ANSI code, corresponding toSCP – Save Cursor Position
protected void
processScrollDown(int optionInt)
ProcessCSI n T
ANSI code, corresponding toSD – Scroll Down
protected void
processScrollUp(int optionInt)
ProcessCSI n U
ANSI code, corresponding toSU – Scroll Up
protected void
processSetAttribute(int attribute)
processSGR
other than0
(reset),30-39
(foreground),40-49
(background),90-97
(foreground high intensity) or100-107
(background high intensity)protected void
processSetBackgroundColor(int color)
processSGR 40-47
corresponding toSet background color
.protected void
processSetBackgroundColor(int color, boolean bright)
processSGR 40-47
orSGR 100-107
corresponding toSet background color
either in normal mode or high intensity.protected void
processSetBackgroundColorExt(int paletteIndex)
processSGR 48
corresponding toextended set background color
with a palette of 255 colors.protected void
processSetBackgroundColorExt(int r, int g, int b)
processSGR 48
corresponding toextended set background color
with a 24 bits RGB definition of the color.protected void
processSetForegroundColor(int color)
processSGR 30-37
corresponding toSet text color (foreground)
.protected void
processSetForegroundColor(int color, boolean bright)
processSGR 30-37
orSGR 90-97
corresponding toSet text color (foreground)
either in normal mode or high intensity.protected void
processSetForegroundColorExt(int paletteIndex)
processSGR 38
corresponding toextended set text color (foreground)
with a palette of 255 colors.protected void
processSetForegroundColorExt(int r, int g, int b)
processSGR 38
corresponding toextended set text color (foreground)
with a 24 bits RGB definition of the color.protected void
processUnknownExtension(ArrayList<Object> options, int command)
Process Unknown Extensionprotected void
processUnknownOperatingSystemCommand(int command, String param)
Process unknownOSC
command.
-
-
-
Field Detail
-
os
protected final OutputStream os
-
ERASE_SCREEN_TO_END
protected static final int ERASE_SCREEN_TO_END
- See Also:
- Constant Field Values
-
ERASE_SCREEN_TO_BEGINING
protected static final int ERASE_SCREEN_TO_BEGINING
- See Also:
- Constant Field Values
-
ERASE_SCREEN
protected static final int ERASE_SCREEN
- See Also:
- Constant Field Values
-
ERASE_LINE_TO_END
protected static final int ERASE_LINE_TO_END
- See Also:
- Constant Field Values
-
ERASE_LINE_TO_BEGINING
protected static final int ERASE_LINE_TO_BEGINING
- See Also:
- Constant Field Values
-
ERASE_LINE
protected static final int ERASE_LINE
- See Also:
- Constant Field Values
-
ATTRIBUTE_INTENSITY_BOLD
protected static final int ATTRIBUTE_INTENSITY_BOLD
- See Also:
- Constant Field Values
-
ATTRIBUTE_INTENSITY_FAINT
protected static final int ATTRIBUTE_INTENSITY_FAINT
- See Also:
- Constant Field Values
-
ATTRIBUTE_ITALIC
protected static final int ATTRIBUTE_ITALIC
- See Also:
- Constant Field Values
-
ATTRIBUTE_UNDERLINE
protected static final int ATTRIBUTE_UNDERLINE
- See Also:
- Constant Field Values
-
ATTRIBUTE_BLINK_SLOW
protected static final int ATTRIBUTE_BLINK_SLOW
- See Also:
- Constant Field Values
-
ATTRIBUTE_BLINK_FAST
protected static final int ATTRIBUTE_BLINK_FAST
- See Also:
- Constant Field Values
-
ATTRIBUTE_NEGATIVE_ON
protected static final int ATTRIBUTE_NEGATIVE_ON
- See Also:
- Constant Field Values
-
ATTRIBUTE_CONCEAL_ON
protected static final int ATTRIBUTE_CONCEAL_ON
- See Also:
- Constant Field Values
-
ATTRIBUTE_UNDERLINE_DOUBLE
protected static final int ATTRIBUTE_UNDERLINE_DOUBLE
- See Also:
- Constant Field Values
-
ATTRIBUTE_INTENSITY_NORMAL
protected static final int ATTRIBUTE_INTENSITY_NORMAL
- See Also:
- Constant Field Values
-
ATTRIBUTE_UNDERLINE_OFF
protected static final int ATTRIBUTE_UNDERLINE_OFF
- See Also:
- Constant Field Values
-
ATTRIBUTE_BLINK_OFF
protected static final int ATTRIBUTE_BLINK_OFF
- See Also:
- Constant Field Values
-
ATTRIBUTE_NEGATIVE_OFF
protected static final int ATTRIBUTE_NEGATIVE_OFF
- See Also:
- Constant Field Values
-
ATTRIBUTE_CONCEAL_OFF
protected static final int ATTRIBUTE_CONCEAL_OFF
- See Also:
- Constant Field Values
-
BLACK
protected static final int BLACK
- See Also:
- Constant Field Values
-
RED
protected static final int RED
- See Also:
- Constant Field Values
-
GREEN
protected static final int GREEN
- See Also:
- Constant Field Values
-
YELLOW
protected static final int YELLOW
- See Also:
- Constant Field Values
-
BLUE
protected static final int BLUE
- See Also:
- Constant Field Values
-
MAGENTA
protected static final int MAGENTA
- See Also:
- Constant Field Values
-
CYAN
protected static final int CYAN
- See Also:
- Constant Field Values
-
WHITE
protected static final int WHITE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AnsiProcessor
public AnsiProcessor(OutputStream os)
-
-
Method Detail
-
getNextOptionInt
protected int getNextOptionInt(Iterator<Object> optionsIterator) throws IOException
Helper for processEscapeCommand() to iterate over integer options- Parameters:
optionsIterator
- the underlying iterator- Throws:
IOException
- if no more non-null values left
-
processEscapeCommand
protected boolean processEscapeCommand(ArrayList<Object> options, int command) throws IOException
- Returns:
- true if the escape command was processed.
- Throws:
IOException
-
processOperatingSystemCommand
protected boolean processOperatingSystemCommand(ArrayList<Object> options)
- Returns:
- true if the operating system command was processed.
-
processCharsetSelect
protected boolean processCharsetSelect(ArrayList<Object> options)
Process character set sequence.- Parameters:
options
- options- Returns:
- true if the charcter set select command was processed.
-
processRestoreCursorPosition
protected void processRestoreCursorPosition() throws IOException
ProcessCSI u
ANSI code, corresponding toRCP – Restore Cursor Position
- Throws:
IOException
- IOException
-
processSaveCursorPosition
protected void processSaveCursorPosition() throws IOException
ProcessCSI s
ANSI code, corresponding toSCP – Save Cursor Position
- Throws:
IOException
- IOException
-
processInsertLine
protected void processInsertLine(int optionInt) throws IOException
ProcessCSI L
ANSI code, corresponding toIL – Insert Line
- Parameters:
optionInt
- option- Throws:
IOException
- IOException- Since:
- 1.16
-
processDeleteLine
protected void processDeleteLine(int optionInt) throws IOException
ProcessCSI M
ANSI code, corresponding toDL – Delete Line
- Parameters:
optionInt
- option- Throws:
IOException
- IOException- Since:
- 1.16
-
processScrollDown
protected void processScrollDown(int optionInt) throws IOException
ProcessCSI n T
ANSI code, corresponding toSD – Scroll Down
- Parameters:
optionInt
- option- Throws:
IOException
- IOException
-
processScrollUp
protected void processScrollUp(int optionInt) throws IOException
ProcessCSI n U
ANSI code, corresponding toSU – Scroll Up
- Parameters:
optionInt
- option- Throws:
IOException
- IOException
-
processEraseScreen
protected void processEraseScreen(int eraseOption) throws IOException
ProcessCSI n J
ANSI code, corresponding toED – Erase in Display
- Parameters:
eraseOption
- eraseOption- Throws:
IOException
- IOException
-
processEraseLine
protected void processEraseLine(int eraseOption) throws IOException
ProcessCSI n K
ANSI code, corresponding toED – Erase in Line
- Parameters:
eraseOption
- eraseOption- Throws:
IOException
- IOException
-
processSetAttribute
protected void processSetAttribute(int attribute) throws IOException
processSGR
other than0
(reset),30-39
(foreground),40-49
(background),90-97
(foreground high intensity) or100-107
(background high intensity)- Parameters:
attribute
- attribute- Throws:
IOException
- IOException- See Also:
processAttributeReset()
,processSetForegroundColor(int)
,processSetForegroundColor(int, boolean)
,processSetForegroundColorExt(int)
,processSetForegroundColorExt(int, int, int)
,processDefaultTextColor()
,processDefaultBackgroundColor()
-
processSetForegroundColor
protected void processSetForegroundColor(int color) throws IOException
processSGR 30-37
corresponding toSet text color (foreground)
.- Parameters:
color
- the text color- Throws:
IOException
- IOException
-
processSetForegroundColor
protected void processSetForegroundColor(int color, boolean bright) throws IOException
processSGR 30-37
orSGR 90-97
corresponding toSet text color (foreground)
either in normal mode or high intensity.- Parameters:
color
- the text colorbright
- is high intensity?- Throws:
IOException
- IOException
-
processSetForegroundColorExt
protected void processSetForegroundColorExt(int paletteIndex) throws IOException
processSGR 38
corresponding toextended set text color (foreground)
with a palette of 255 colors.- Parameters:
paletteIndex
- the text color in the palette- Throws:
IOException
- IOException
-
processSetForegroundColorExt
protected void processSetForegroundColorExt(int r, int g, int b) throws IOException
processSGR 38
corresponding toextended set text color (foreground)
with a 24 bits RGB definition of the color.- Parameters:
r
- redg
- greenb
- blue- Throws:
IOException
- IOException
-
processSetBackgroundColor
protected void processSetBackgroundColor(int color) throws IOException
processSGR 40-47
corresponding toSet background color
.- Parameters:
color
- the background color- Throws:
IOException
- IOException
-
processSetBackgroundColor
protected void processSetBackgroundColor(int color, boolean bright) throws IOException
processSGR 40-47
orSGR 100-107
corresponding toSet background color
either in normal mode or high intensity.- Parameters:
color
- the background colorbright
- is high intensity?- Throws:
IOException
- IOException
-
processSetBackgroundColorExt
protected void processSetBackgroundColorExt(int paletteIndex) throws IOException
processSGR 48
corresponding toextended set background color
with a palette of 255 colors.- Parameters:
paletteIndex
- the background color in the palette- Throws:
IOException
- IOException
-
processSetBackgroundColorExt
protected void processSetBackgroundColorExt(int r, int g, int b) throws IOException
processSGR 48
corresponding toextended set background color
with a 24 bits RGB definition of the color.- Parameters:
r
- redg
- greenb
- blue- Throws:
IOException
- IOException
-
processDefaultTextColor
protected void processDefaultTextColor() throws IOException
processSGR 39
corresponding toDefault text color (foreground)
- Throws:
IOException
- IOException
-
processDefaultBackgroundColor
protected void processDefaultBackgroundColor() throws IOException
processSGR 49
corresponding toDefault background color
- Throws:
IOException
- IOException
-
processAttributeReset
protected void processAttributeReset() throws IOException
processSGR 0
corresponding toReset / Normal
- Throws:
IOException
- IOException
-
processCursorTo
protected void processCursorTo(int row, int col) throws IOException
processCSI n ; m H
corresponding toCUP – Cursor Position
orCSI n ; m f
corresponding toHVP – Horizontal and Vertical Position
- Parameters:
row
- rowcol
- col- Throws:
IOException
- IOException
-
processCursorToColumn
protected void processCursorToColumn(int x) throws IOException
processCSI n G
corresponding toCHA – Cursor Horizontal Absolute
- Parameters:
x
- the column- Throws:
IOException
- IOException
-
processCursorUpLine
protected void processCursorUpLine(int count) throws IOException
processCSI n F
corresponding toCPL – Cursor Previous Line
- Parameters:
count
- line count- Throws:
IOException
- IOException
-
processCursorDownLine
protected void processCursorDownLine(int count) throws IOException
processCSI n E
corresponding toCNL – Cursor Next Line
- Parameters:
count
- line count- Throws:
IOException
- IOException
-
processCursorLeft
protected void processCursorLeft(int count) throws IOException
processCSI n D
corresponding toCUB – Cursor Back
- Parameters:
count
- count- Throws:
IOException
- IOException
-
processCursorRight
protected void processCursorRight(int count) throws IOException
processCSI n C
corresponding toCUF – Cursor Forward
- Parameters:
count
- count- Throws:
IOException
- IOException
-
processCursorDown
protected void processCursorDown(int count) throws IOException
processCSI n B
corresponding toCUD – Cursor Down
- Parameters:
count
- count- Throws:
IOException
- IOException
-
processCursorUp
protected void processCursorUp(int count) throws IOException
processCSI n A
corresponding toCUU – Cursor Up
- Parameters:
count
- count- Throws:
IOException
- IOException
-
processUnknownExtension
protected void processUnknownExtension(ArrayList<Object> options, int command)
Process Unknown Extension- Parameters:
options
- optionscommand
- command
-
processChangeIconNameAndWindowTitle
protected void processChangeIconNameAndWindowTitle(String label)
processOSC 0;text BEL
corresponding toChange Window and Icon label
- Parameters:
label
- window title name
-
processChangeIconName
protected void processChangeIconName(String label)
processOSC 1;text BEL
corresponding toChange Icon label
- Parameters:
label
- icon label
-
processChangeWindowTitle
protected void processChangeWindowTitle(String label)
processOSC 2;text BEL
corresponding toChange Window title
- Parameters:
label
- window title text
-
processUnknownOperatingSystemCommand
protected void processUnknownOperatingSystemCommand(int command, String param)
Process unknownOSC
command.- Parameters:
command
- commandparam
- param
-
processCharsetSelect
protected void processCharsetSelect(int set, char seq)
-
-