Package org.jline.utils
Class AnsiWriter
java.lang.Object
java.io.Writer
java.io.FilterWriter
org.jline.utils.AnsiWriter
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
A ANSI writer extracts ANSI escape codes written to
a
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.- Since:
- 1.0
- Author:
- Hiram Chirino, Joris Kuipers
-
Field Summary
Modifier and TypeFieldDescriptionprotected 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
Deprecated.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
Fields inherited from class java.io.FilterWriter
out
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected void
processSGR 0
corresponding toReset / Normal
protected void
processChangeIconName
(String name) processOSC 1;text BEL
corresponding toChange Icon label
protected void
processOSC 0;text BEL
corresponding toChange Window and Icon label
protected void
processChangeWindowTitle
(String title) processOSC 2;text BEL
corresponding toChange Window title
protected void
processCharsetSelect
(int set, char seq) 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
processSGR 49
corresponding toDefault background color
protected void
processSGR 39
corresponding toDefault text color (foreground)
protected void
processDeleteLine
(int optionInt) ProcessCSI s
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 void
processInsertLine
(int optionInt) ProcessCSI s
ANSI code, corresponding toIL – Insert Line
protected void
ProcessCSI u
ANSI code, corresponding toRCP – Restore Cursor Position
protected void
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) protected void
processUnknownOperatingSystemCommand
(int command, String param) Process unknownOSC
command.void
write
(char[] cbuf, int off, int len) void
write
(int data) void
Methods inherited from class java.io.FilterWriter
flush
-
Field Details
-
ERASE_SCREEN_TO_END
protected static final int ERASE_SCREEN_TO_END- See Also:
-
ERASE_SCREEN_TO_BEGINING
protected static final int ERASE_SCREEN_TO_BEGINING- See Also:
-
ERASE_SCREEN
protected static final int ERASE_SCREEN- See Also:
-
ERASE_LINE_TO_END
protected static final int ERASE_LINE_TO_END- See Also:
-
ERASE_LINE_TO_BEGINING
protected static final int ERASE_LINE_TO_BEGINING- See Also:
-
ERASE_LINE
protected static final int ERASE_LINE- See Also:
-
ATTRIBUTE_INTENSITY_BOLD
protected static final int ATTRIBUTE_INTENSITY_BOLD- See Also:
-
ATTRIBUTE_INTENSITY_FAINT
protected static final int ATTRIBUTE_INTENSITY_FAINT- See Also:
-
ATTRIBUTE_ITALIC
protected static final int ATTRIBUTE_ITALIC- See Also:
-
ATTRIBUTE_UNDERLINE
protected static final int ATTRIBUTE_UNDERLINE- See Also:
-
ATTRIBUTE_BLINK_SLOW
protected static final int ATTRIBUTE_BLINK_SLOW- See Also:
-
ATTRIBUTE_BLINK_FAST
protected static final int ATTRIBUTE_BLINK_FAST- See Also:
-
ATTRIBUTE_NEGATIVE_ON
protected static final int ATTRIBUTE_NEGATIVE_ON- See Also:
-
ATTRIBUTE_CONCEAL_ON
protected static final int ATTRIBUTE_CONCEAL_ON- See Also:
-
ATTRIBUTE_UNDERLINE_DOUBLE
protected static final int ATTRIBUTE_UNDERLINE_DOUBLE- See Also:
-
ATTRIBUTE_INTENSITY_NORMAL
protected static final int ATTRIBUTE_INTENSITY_NORMAL- See Also:
-
ATTRIBUTE_UNDERLINE_OFF
protected static final int ATTRIBUTE_UNDERLINE_OFF- See Also:
-
ATTRIBUTE_BLINK_OFF
protected static final int ATTRIBUTE_BLINK_OFF- See Also:
-
ATTRIBUTE_NEGATIVE_Off
Deprecated.- See Also:
-
ATTRIBUTE_NEGATIVE_OFF
protected static final int ATTRIBUTE_NEGATIVE_OFF- See Also:
-
ATTRIBUTE_CONCEAL_OFF
protected static final int ATTRIBUTE_CONCEAL_OFF- See Also:
-
BLACK
protected static final int BLACK- See Also:
-
RED
protected static final int RED- See Also:
-
GREEN
protected static final int GREEN- See Also:
-
YELLOW
protected static final int YELLOW- See Also:
-
BLUE
protected static final int BLUE- See Also:
-
MAGENTA
protected static final int MAGENTA- See Also:
-
CYAN
protected static final int CYAN- See Also:
-
WHITE
protected static final int WHITE- See Also:
-
-
Constructor Details
-
AnsiWriter
-
-
Method Details
-
write
- Overrides:
write
in classFilterWriter
- Throws:
IOException
-
processRestoreCursorPosition
ProcessCSI u
ANSI code, corresponding toRCP – Restore Cursor Position
- Throws:
IOException
- if an error occurs
-
processSaveCursorPosition
ProcessCSI s
ANSI code, corresponding toSCP – Save Cursor Position
- Throws:
IOException
- if an error occurs
-
processInsertLine
ProcessCSI s
ANSI code, corresponding toIL – Insert Line
- Parameters:
optionInt
- the option- Throws:
IOException
- if an error occurs
-
processDeleteLine
ProcessCSI s
ANSI code, corresponding toDL – Delete Line
- Parameters:
optionInt
- the option- Throws:
IOException
- if an error occurs
-
processScrollDown
ProcessCSI n T
ANSI code, corresponding toSD – Scroll Down
- Parameters:
optionInt
- the option- Throws:
IOException
- if an error occurs
-
processScrollUp
ProcessCSI n U
ANSI code, corresponding toSU – Scroll Up
- Parameters:
optionInt
- the option- Throws:
IOException
- if an error occurs
-
processEraseScreen
ProcessCSI n J
ANSI code, corresponding toED – Erase in Display
- Parameters:
eraseOption
- the erase option- Throws:
IOException
- if an error occurs
-
processEraseLine
ProcessCSI n K
ANSI code, corresponding toED – Erase in Line
- Parameters:
eraseOption
- the erase option- Throws:
IOException
- if an error occurs
-
processSetAttribute
processSGR
other than0
(reset),30-39
(foreground),40-49
(background),90-97
(foreground high intensity) or100-107
(background high intensity)- Parameters:
attribute
- the attribute to set- Throws:
IOException
- if an error occurs- See Also:
-
processSetForegroundColor
processSGR 30-37
corresponding toSet text color (foreground)
.- Parameters:
color
- the text color- Throws:
IOException
- if an error occurs
-
processSetForegroundColor
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
- if an error occurs
-
processSetForegroundColorExt
processSGR 38
corresponding toextended set text color (foreground)
with a palette of 255 colors.- Parameters:
paletteIndex
- the text color in the palette- Throws:
IOException
- if an error occurs
-
processSetForegroundColorExt
processSGR 38
corresponding toextended set text color (foreground)
with a 24 bits RGB definition of the color.- Parameters:
r
- redg
- greenb
- blue- Throws:
IOException
- if an error occurs
-
processSetBackgroundColor
processSGR 40-47
corresponding toSet background color
.- Parameters:
color
- the background color- Throws:
IOException
- if an error occurs
-
processSetBackgroundColor
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
- if an error occurs
-
processSetBackgroundColorExt
processSGR 48
corresponding toextended set background color
with a palette of 255 colors.- Parameters:
paletteIndex
- the background color in the palette- Throws:
IOException
- if an error occurs
-
processSetBackgroundColorExt
processSGR 48
corresponding toextended set background color
with a 24 bits RGB definition of the color.- Parameters:
r
- redg
- greenb
- blue- Throws:
IOException
- if an error occurs
-
processDefaultTextColor
processSGR 39
corresponding toDefault text color (foreground)
- Throws:
IOException
- if an error occurs
-
processDefaultBackgroundColor
processSGR 49
corresponding toDefault background color
- Throws:
IOException
- if an error occurs
-
processAttributeRest
processSGR 0
corresponding toReset / Normal
- Throws:
IOException
- if an error occurs
-
processCursorTo
processCSI n ; m H
corresponding toCUP – Cursor Position
orCSI n ; m f
corresponding toHVP – Horizontal and Vertical Position
- Parameters:
row
- the rowcol
- the column- Throws:
IOException
- if an error occurs
-
processCursorToColumn
processCSI n G
corresponding toCHA – Cursor Horizontal Absolute
- Parameters:
x
- the column- Throws:
IOException
- if an error occurs
-
processCursorUpLine
processCSI n F
corresponding toCPL – Cursor Previous Line
- Parameters:
count
- line count- Throws:
IOException
- if an error occurs
-
processCursorDownLine
processCSI n E
corresponding toCNL – Cursor Next Line
- Parameters:
count
- line count- Throws:
IOException
- if an error occurs
-
processCursorLeft
processCSI n D
corresponding toCUB – Cursor Back
- Parameters:
count
- the count- Throws:
IOException
- if an error occurs
-
processCursorRight
processCSI n C
corresponding toCUF – Cursor Forward
- Parameters:
count
- the count- Throws:
IOException
- if an error occurs
-
processCursorDown
processCSI n B
corresponding toCUD – Cursor Down
- Parameters:
count
- the count- Throws:
IOException
- if an error occurs
-
processCursorUp
processCSI n A
corresponding toCUU – Cursor Up
- Parameters:
count
- the count- Throws:
IOException
- if an error occurs
-
processUnknownExtension
-
processChangeIconNameAndWindowTitle
processOSC 0;text BEL
corresponding toChange Window and Icon label
- Parameters:
label
- the label
-
processChangeIconName
processOSC 1;text BEL
corresponding toChange Icon label
- Parameters:
name
- the icon name
-
processChangeWindowTitle
processOSC 2;text BEL
corresponding toChange Window title
- Parameters:
title
- the title
-
processUnknownOperatingSystemCommand
Process unknownOSC
command.- Parameters:
command
- the commandparam
- the param
-
processCharsetSelect
protected void processCharsetSelect(int set, char seq) -
write
- Overrides:
write
in classFilterWriter
- Throws:
IOException
-
write
- Overrides:
write
in classFilterWriter
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterWriter
- Throws:
IOException
-