- All Implemented Interfaces:
Serializable,Comparable<AnsiEscapeCode>,java.lang.constant.Constable,org.refcodes.mixin.CodeAccessor<Byte>
public enum AnsiEscapeCode extends Enum<AnsiEscapeCode> implements org.refcodes.mixin.CodeAccessor<Byte>
This enumeration contains ANSI Escape-Codes for modifying the appearance of
console output to ANSI enabled terminals. In order to compose your basic ANSI
Escape-Code sequences, you may go for
toEscapeSequence(AnsiEscapeCode...). Use
toEscapedSequence(String) when you wish to print the ANSI
Escape-Code sequence without the sequence modifying your terminal output
(e.g. helpful in error messages regarding ANSI Escape-Codes).-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>Nested classes/interfaces inherited from interface org.refcodes.mixin.CodeAccessor
org.refcodes.mixin.CodeAccessor.CodeBuilder<T extends Object,B extends org.refcodes.mixin.CodeAccessor.CodeBuilder<T,B>>, org.refcodes.mixin.CodeAccessor.CodeMutator<T extends Object>, org.refcodes.mixin.CodeAccessor.CodeProperty<T extends Object> -
Enum Constant Summary
Enum Constants Enum Constant Description BG_BLACKBackground Black: Set background color.BG_BLUEBackground Blue: Set background color.BG_BRIGHT_BLACKBackground Bright Black: Set bright background color (aixterm (not in standard)).BG_BRIGHT_BLUEBackground Bright Blue: Set bright background color (aixterm (not in standard)).BG_BRIGHT_CYANBackground Bright Cyan: Set bright background color (aixterm (not in standard)).BG_BRIGHT_DEFAULTBackground Bright Default: Set bright background color (aixterm (not in standard)).BG_BRIGHT_GREENBackground Bright Green: Set bright background color (aixterm (not in standard)).BG_BRIGHT_MAGENTABackground Bright Magenta: Set bright background color (aixterm (not in standard)).BG_BRIGHT_REDBackground Bright Red: Set bright background color (aixterm (not in standard)).BG_BRIGHT_WHITEBackground Bright White: Set bright background color (aixterm (not in standard)).BG_BRIGHT_YELLOWBackground Bright Yellow: Set bright background color (aixterm (not in standard)).BG_CYANBackground Cyan: Set background color.BG_GREENBackground Green: Set background color.BG_MAGENTABackground Magenta: Set background color.BG_REDBackground Red: Set background color.BG_WHITEBackground White: Set background color.BG_YELLOWBackground Yellow: Set background color.BLINK_OFFBlink offBOLDBold or increased intensity:CONCEALConceal: Not widely supported.CROSSED_OUTCrossed-out: Characters legible but marked for deletion.DEFAULT_BACKGROUND_COLORDefault background color: implementation defined (according to standard)DEFAULT_FONTPrimary(default) fontDEFAULT_FOREGROUND_COLORDefault foreground color: implementation defined (according to standard)DOUBLY_UNDERLINE_OR_BOLD_OFFDoubly underline or Bold off: Double-underline per ECMA-48.ENCIRCLEDEncircledFAINTFaint (decreased intensity):FG_BLACKForeground Black: Set foreground color.FG_BLUEForeground Blue: Set foreground color.FG_BRIGHT_BLACKForeground Bright Black: Set bright foreground color (aixterm (not in standard)).FG_BRIGHT_BLUEForeground Bright Blue: Set bright foreground color (aixterm (not in standard)).FG_BRIGHT_CYANForeground Bright Cyan: Set bright foreground color (aixterm (not in standard)).FG_BRIGHT_DEFAULTForeground Bright Default: Set bright foreground color (aixterm (not in standard)).FG_BRIGHT_GREENForeground Bright Green: Set bright foreground color (aixterm (not in standard)).FG_BRIGHT_MAGENTAForeground Bright Magenta: Set bright foreground color (aixterm (not in standard)).FG_BRIGHT_REDForeground Bright Red: Set bright foreground color (aixterm (not in standard)).FG_BRIGHT_WHITEForeground Bright White: Set bright foreground color (aixterm (not in standard)).FG_BRIGHT_YELLOWForeground Bright Yellow: Set bright foreground color (aixterm (not in standard)).FG_CYANForeground Cyan: Set foreground color.FG_GREENForeground Green: Set foreground color.FG_MAGENTAForeground Magenta: Set foreground color.FG_REDForeground Red: Set foreground color.FG_WHITEForeground White: Set foreground color.FG_YELLOWForeground Yellow: Set foreground color.FONT_1Font 1: Select alternative font 1.FONT_2Font 2: Select alternative font 2.FONT_3Font 3: Select alternative font 3.FONT_4Font 4: Select alternative font 4.FONT_5Font 5: Select alternative font 5.FONT_6Font 6: Select alternative font 6.FONT_7Font 7: Select alternative font 7.FONT_8Font 8: Select alternative font 8.FONT_9Font 9: Select alternative font 9.FRAKTURFraktur: Rarely supported.FRAMEDFramedIDEOGRAM_ATTRIBUTES_OFFIdeogram attributes off: Reset the effects of all of 60–64.IDEOGRAM_DOUBLE_OVERLINE_OR_DOUBLE_LINE_ON_THE_LEFT_SIDEIdeogram double overline or double line on the left side : Rarely supported.IDEOGRAM_DOUBLE_UNDERLINE_OR_DOUBLE_LINE_ON_THE_RIGHT_SIDEIdeogram double underline or double line on the right side : Rarely supported.IDEOGRAM_OVERLINE_OR_LEFT_SIDE_LINEIdeogram overline or left side line : Rarely supported.IDEOGRAM_STRESS_MARKINGIdeogram stress marking : Rarely supported.IDEOGRAM_UNDERLINE_OR_RIGHT_SIDE_LINEIdeogram underline or right side line: Rarely supported.INVERSE_OFFInverse offITALICItalic: Not widely supported.NORMAL_COLOR_OR_INTENSITYNormal color or intensity: Neither bold nor faint.NOT_CROSSED_OUTNot crossed outNOT_FRAMEDNot framed or encircledNOT_ITALIC_NOT_FRAKTURNot italic: Not Fraktur.NOT_OVERLINEDNot overlinedOVERLINEDOverlinedRAPID_BLINKRapid Blink: 150+ per minute.RESETReset / Normal: All attributes off (reset).REVEALReveal: Conceal off.REVERSE_VIDEOReverse Video: Swap foreground and background colors.SET_BACKGROUND_COLORSet background color: Next arguments are5;nor2;r;g;b, see below:ESC[48:5:(n)m; Select background color, (n) represents an index into a predefined 256-color lookup tableESC[48;2;(r);(g);(b)m: Select RGB background color, (r) represents the 8 bit red portion of an RGB color, (g) represents the 8 bit green portion of an RGB color, (b) represents the 8 bit blue portion of an RGB colorSET_FOREGROUND_COLORSet foreground color: Next arguments are5;nor2;r;g;b, see below:ESC[38:5:(n)m: Select foreground color, (n) represents an index into a predefined 256-color lookup tableESC[38;2;(r);(g);(b)m: Select RGB foreground color, (r) represents the 8 bit red portion of an RGB color, (g) represents the 8 bit green portion of an RGB color, (b) represents the 8 bit blue portion of an RGB colorSLOW_BLINKSlow Blink: Less than 150 per minute.UNDERLINEUnderlineUNDERLINE_OFFUnderline off: Not singly or doubly underlined. -
Field Summary
Fields Modifier and Type Field Description static charCOLOR_TABLE_SELECTOR_PARAMETERIn case ofSET_FOREGROUND_COLORorSET_BACKGROUND_COLOR, theCOLOR_TABLE_SELECTOR_PARAMETERspecifies that the succeeding parameter represents an index into the ANSI Color-Table.static charESCAPEThe ANSI Escape-Code with which each ANSI escape sequence is commenced.static charESCAPE_PARAMETER_DELIMITERThe delimiter used to separate the parameters of an ANSI Escape-Sequence, e.g. the parameters "0", "1" and ""4" of the sequence "<ESC>[0;1;4m".static charESCAPE_PREFIX_DELIMITERThe delimiter used to separate the leading Escape-Code <ESC> of an ANSI Escape-Sequence from the succeeding portion, e.g. "[" separates <ESC> from "[0;1;4m" of the sequence "<ESC>[0;1;4m".static charESCAPE_SUFFIXThe ANSI Escape-Code with which each ANSI escape sequence is concluded.static charRGB_COLOR_SELECTOR_PARAMETERIn case ofSET_FOREGROUND_COLORorSET_BACKGROUND_COLOR, theRGB_COLOR_SELECTOR_PARAMETERspecifies that the succeeding parameters represent RGB values. -
Method Summary
Modifier and Type Method Description BytegetCode()StringtoEscaped()Returns the escaped ANSI Escape-Code to be printable without triggering the actual ANSI escape commands.static StringtoEscapedSequence(String aEscapeSequence)Makes the provided Escape-Sequence printable by replacing theESCAPEcode with a printable char sequence.static Region[]toEscapedSequenceRegions(String aEscapedString)Retrieves a list of regions (begin index, end index ) with ANSI escape codes.static StringtoEscapeSequence(AnsiEscapeCode... aAnsiEscapeCodes)Basic functionality to create an ANSI Escape-Code sequence from the providedAnsiEscapeCodeelements directly printable toSystem.out.static inttoUnescapedLength(String aEscapedString)static StringtoUnescapedString(String aEscapedString)Removes any ANSI escape codes from the providedString.static AnsiEscapeCodevalueOf(String name)Returns the enum constant of this type with the specified name.static AnsiEscapeCode[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
RESET
Reset / Normal: All attributes off (reset). -
BOLD
Bold or increased intensity: -
FAINT
Faint (decreased intensity): -
ITALIC
Italic: Not widely supported. Sometimes treated as inverse. -
UNDERLINE
Underline -
SLOW_BLINK
Slow Blink: Less than 150 per minute. -
RAPID_BLINK
Rapid Blink: 150+ per minute. Not widely supported. -
REVERSE_VIDEO
Reverse Video: Swap foreground and background colors. -
CONCEAL
Conceal: Not widely supported. -
CROSSED_OUT
Crossed-out: Characters legible but marked for deletion. -
DEFAULT_FONT
Primary(default) font -
FONT_1
Font 1: Select alternative font 1. -
FONT_2
Font 2: Select alternative font 2. -
FONT_3
Font 3: Select alternative font 3. -
FONT_4
Font 4: Select alternative font 4. -
FONT_5
Font 5: Select alternative font 5. -
FONT_6
Font 6: Select alternative font 6. -
FONT_7
Font 7: Select alternative font 7. -
FONT_8
Font 8: Select alternative font 8. -
FONT_9
Font 9: Select alternative font 9. -
FRAKTUR
Fraktur: Rarely supported. -
DOUBLY_UNDERLINE_OR_BOLD_OFF
Doubly underline or Bold off: Double-underline per ECMA-48. -
NORMAL_COLOR_OR_INTENSITY
Normal color or intensity: Neither bold nor faint. -
NOT_ITALIC_NOT_FRAKTUR
Not italic: Not Fraktur. -
UNDERLINE_OFF
Underline off: Not singly or doubly underlined. -
BLINK_OFF
Blink off -
INVERSE_OFF
Inverse off -
REVEAL
Reveal: Conceal off. -
NOT_CROSSED_OUT
Not crossed out -
FG_BLACK
Foreground Black: Set foreground color. -
FG_RED
Foreground Red: Set foreground color. -
FG_GREEN
Foreground Green: Set foreground color. -
FG_YELLOW
Foreground Yellow: Set foreground color. -
FG_BLUE
Foreground Blue: Set foreground color. -
FG_MAGENTA
Foreground Magenta: Set foreground color. -
FG_CYAN
Foreground Cyan: Set foreground color. -
FG_WHITE
Foreground White: Set foreground color. -
SET_FOREGROUND_COLOR
Set foreground color: Next arguments are5;nor2;r;g;b, see below:ESC[38:5:(n)m: Select foreground color, (n) represents an index into a predefined 256-color lookup tableESC[38;2;(r);(g);(b)m: Select RGB foreground color, (r) represents the 8 bit red portion of an RGB color, (g) represents the 8 bit green portion of an RGB color, (b) represents the 8 bit blue portion of an RGB color
-
DEFAULT_FOREGROUND_COLOR
Default foreground color: implementation defined (according to standard) -
BG_BLACK
Background Black: Set background color. -
BG_RED
Background Red: Set background color. -
BG_GREEN
Background Green: Set background color. -
BG_YELLOW
Background Yellow: Set background color. -
BG_BLUE
Background Blue: Set background color. -
BG_MAGENTA
Background Magenta: Set background color. -
BG_CYAN
Background Cyan: Set background color. -
BG_WHITE
Background White: Set background color. -
SET_BACKGROUND_COLOR
Set background color: Next arguments are5;nor2;r;g;b, see below:ESC[48:5:(n)m; Select background color, (n) represents an index into a predefined 256-color lookup tableESC[48;2;(r);(g);(b)m: Select RGB background color, (r) represents the 8 bit red portion of an RGB color, (g) represents the 8 bit green portion of an RGB color, (b) represents the 8 bit blue portion of an RGB color
-
DEFAULT_BACKGROUND_COLOR
Default background color: implementation defined (according to standard) -
FRAMED
Framed -
ENCIRCLED
Encircled -
OVERLINED
Overlined -
NOT_FRAMED
Not framed or encircled -
NOT_OVERLINED
Not overlined -
IDEOGRAM_UNDERLINE_OR_RIGHT_SIDE_LINE
Ideogram underline or right side line: Rarely supported. -
IDEOGRAM_DOUBLE_UNDERLINE_OR_DOUBLE_LINE_ON_THE_RIGHT_SIDE
Ideogram double underline or double line on the right side : Rarely supported. -
IDEOGRAM_OVERLINE_OR_LEFT_SIDE_LINE
Ideogram overline or left side line : Rarely supported. -
IDEOGRAM_DOUBLE_OVERLINE_OR_DOUBLE_LINE_ON_THE_LEFT_SIDE
Ideogram double overline or double line on the left side : Rarely supported. -
IDEOGRAM_STRESS_MARKING
Ideogram stress marking : Rarely supported. -
IDEOGRAM_ATTRIBUTES_OFF
Ideogram attributes off: Reset the effects of all of 60–64. -
FG_BRIGHT_BLACK
Foreground Bright Black: Set bright foreground color (aixterm (not in standard)). -
FG_BRIGHT_RED
Foreground Bright Red: Set bright foreground color (aixterm (not in standard)). -
FG_BRIGHT_GREEN
Foreground Bright Green: Set bright foreground color (aixterm (not in standard)). -
FG_BRIGHT_YELLOW
Foreground Bright Yellow: Set bright foreground color (aixterm (not in standard)). -
FG_BRIGHT_BLUE
Foreground Bright Blue: Set bright foreground color (aixterm (not in standard)). -
FG_BRIGHT_MAGENTA
Foreground Bright Magenta: Set bright foreground color (aixterm (not in standard)). -
FG_BRIGHT_CYAN
Foreground Bright Cyan: Set bright foreground color (aixterm (not in standard)). -
FG_BRIGHT_WHITE
Foreground Bright White: Set bright foreground color (aixterm (not in standard)). -
FG_BRIGHT_DEFAULT
Foreground Bright Default: Set bright foreground color (aixterm (not in standard)). -
BG_BRIGHT_BLACK
Background Bright Black: Set bright background color (aixterm (not in standard)). -
BG_BRIGHT_RED
Background Bright Red: Set bright background color (aixterm (not in standard)). -
BG_BRIGHT_GREEN
Background Bright Green: Set bright background color (aixterm (not in standard)). -
BG_BRIGHT_YELLOW
Background Bright Yellow: Set bright background color (aixterm (not in standard)). -
BG_BRIGHT_BLUE
Background Bright Blue: Set bright background color (aixterm (not in standard)). -
BG_BRIGHT_MAGENTA
Background Bright Magenta: Set bright background color (aixterm (not in standard)). -
BG_BRIGHT_CYAN
Background Bright Cyan: Set bright background color (aixterm (not in standard)). -
BG_BRIGHT_WHITE
Background Bright White: Set bright background color (aixterm (not in standard)). -
BG_BRIGHT_DEFAULT
Background Bright Default: Set bright background color (aixterm (not in standard)).
-
-
Field Details
-
ESCAPE
public static char ESCAPEThe ANSI Escape-Code with which each ANSI escape sequence is commenced. -
ESCAPE_SUFFIX
public static char ESCAPE_SUFFIXThe ANSI Escape-Code with which each ANSI escape sequence is concluded. -
ESCAPE_PARAMETER_DELIMITER
public static char ESCAPE_PARAMETER_DELIMITERThe delimiter used to separate the parameters of an ANSI Escape-Sequence, e.g. the parameters "0", "1" and ""4" of the sequence "<ESC>[0;1;4m". -
ESCAPE_PREFIX_DELIMITER
public static char ESCAPE_PREFIX_DELIMITERThe delimiter used to separate the leading Escape-Code <ESC> of an ANSI Escape-Sequence from the succeeding portion, e.g. "[" separates <ESC> from "[0;1;4m" of the sequence "<ESC>[0;1;4m". -
RGB_COLOR_SELECTOR_PARAMETER
public static char RGB_COLOR_SELECTOR_PARAMETERIn case ofSET_FOREGROUND_COLORorSET_BACKGROUND_COLOR, theRGB_COLOR_SELECTOR_PARAMETERspecifies that the succeeding parameters represent RGB values. -
COLOR_TABLE_SELECTOR_PARAMETER
public static char COLOR_TABLE_SELECTOR_PARAMETERIn case ofSET_FOREGROUND_COLORorSET_BACKGROUND_COLOR, theCOLOR_TABLE_SELECTOR_PARAMETERspecifies that the succeeding parameter represents an index into the ANSI Color-Table.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
getCode
- Specified by:
getCodein interfaceorg.refcodes.mixin.CodeAccessor<Byte>
-
toEscapeSequence
Basic functionality to create an ANSI Escape-Code sequence from the providedAnsiEscapeCodeelements directly printable toSystem.out. This method can only provide placeholder such as ${n0}, ${n1}, ... for elementsSET_FOREGROUND_COLORandSET_BACKGROUND_COLOR(the numbers correspond to the order of their appearance). Consider building your sequence manually in case you want to use a RGB value instead of an index into the ANSI Color-Table.- Parameters:
aAnsiEscapeCodes- The Escape-Codes to be included in the Escape-Code sequence.- Returns:
- The correctly generated Escape-Code sequence directly printable
to
System.out.
-
toEscapedSequence
Makes the provided Escape-Sequence printable by replacing theESCAPEcode with a printable char sequence. This means that the Escape-Sequence is disabled so that it will be printed out as plain text.- Parameters:
aEscapeSequence- The Escape-Sequence to be printed out as plain text.- Returns:
- The plain text representation of the given Escape-Sequence.
-
toEscapedSequenceRegions
Retrieves a list of regions (begin index, end index ) with ANSI escape codes. The begin index is being included and the end index is being excluded by the returned regions. -
toUnescapedString
Removes any ANSI escape codes from the providedString. -
toUnescapedLength
-
toEscaped
Returns the escaped ANSI Escape-Code to be printable without triggering the actual ANSI escape commands.- Returns:
- The escaped ANSI Escape-Code.
-