- All Implemented Interfaces:
TextColor
,Serializable
,Comparable<TextColor.ANSI>
,java.lang.constant.Constable
- Enclosing interface:
TextColor
This class represent classic ANSI colors that are likely to be very compatible with most terminal
implementations. It is limited to 8 colors (plus the 'default' color) but as a norm, using bold mode (SGR code)
will slightly alter the color, giving it a bit brighter tone, so in total this will give you 16 (+1) colors.
For more information, see http://en.wikipedia.org/wiki/File:Ansi.png
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
Nested classes/interfaces inherited from interface com.googlecode.lanterna.TextColor
TextColor.ANSI, TextColor.Factory, TextColor.Indexed, TextColor.RGB
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescription -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]
private final int
private final boolean
private final byte[]
private final int
private final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
Returns the byte sequence in between CSI and character 'm' that is used to enable this color as the background color on an ANSI-compatible terminal.int
getBlue()
byte[]
Returns the byte sequence in between CSI and character 'm' that is used to enable this color as the foreground color on an ANSI-compatible terminal.int
getGreen()
int
getRed()
boolean
isBright()
toColor()
Converts this color to an AWT color object, assuming a standard VGA palette.static TextColor.ANSI
Returns the enum constant of this type with the specified name.static TextColor.ANSI[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
BLACK
-
RED
-
GREEN
-
YELLOW
-
BLUE
-
MAGENTA
-
CYAN
-
WHITE
-
DEFAULT
-
BLACK_BRIGHT
-
RED_BRIGHT
-
GREEN_BRIGHT
-
YELLOW_BRIGHT
-
BLUE_BRIGHT
-
MAGENTA_BRIGHT
-
CYAN_BRIGHT
-
WHITE_BRIGHT
-
-
Field Details
-
bright
private final boolean bright -
red
private final int red -
green
private final int green -
blue
private final int blue -
foregroundSGR
private final byte[] foregroundSGR -
backgroundSGR
private final byte[] backgroundSGR
-
-
Constructor Details
-
ANSI
private ANSI(int index, int red, int green, int blue) -
ANSI
private ANSI(int index, boolean bright, int red, int green, int blue)
-
-
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
-
getForegroundSGRSequence
public byte[] getForegroundSGRSequence()Description copied from interface:TextColor
Returns the byte sequence in between CSI and character 'm' that is used to enable this color as the foreground color on an ANSI-compatible terminal.- Specified by:
getForegroundSGRSequence
in interfaceTextColor
- Returns:
- Byte array out data to output in between of CSI and 'm'
-
getBackgroundSGRSequence
public byte[] getBackgroundSGRSequence()Description copied from interface:TextColor
Returns the byte sequence in between CSI and character 'm' that is used to enable this color as the background color on an ANSI-compatible terminal.- Specified by:
getBackgroundSGRSequence
in interfaceTextColor
- Returns:
- Byte array out data to output in between of CSI and 'm'
-
isBright
public boolean isBright() -
getRed
public int getRed() -
getGreen
public int getGreen() -
getBlue
public int getBlue() -
toColor
Description copied from interface:TextColor
Converts this color to an AWT color object, assuming a standard VGA palette.
-