- All Superinterfaces:
Serializable
- All Known Implementing Classes:
TextColor.ANSI
,TextColor.Indexed
,TextColor.RGB
This is an abstract base class for terminal color definitions. Since there are different ways of specifying terminal
colors, all with a different range of adoptions, this makes it possible to program an API against an implementation-
agnostic color definition. Please remember when using colors that not all terminals and terminal emulators supports
them. The 24-bit color mode is very unsupported, for example, and even the default Linux terminal doesn't support
the 256-color indexed mode.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
This class represent classic ANSI colors that are likely to be very compatible with most terminal implementations.static class
Utility class to instantiate colors from other types and definitionsstatic class
This class represents a color expressed in the indexed XTerm 256 color extension, where each color is defined in a lookup-table.static class
This class can be used to specify a color in 24-bit color space (RGB with 8-bit resolution per color). -
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()
toColor()
Deprecated.This adds a runtime dependency to the java.desktop module which isn't declared in the module descriptor of lanterna.
-
Method Details
-
getForegroundSGRSequence
byte[] getForegroundSGRSequence()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.- Returns:
- Byte array out data to output in between of CSI and 'm'
-
getBackgroundSGRSequence
byte[] getBackgroundSGRSequence()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.- Returns:
- Byte array out data to output in between of CSI and 'm'
-
getRed
int getRed()- Returns:
- Red intensity of this color, from 0 to 255
-
getGreen
int getGreen()- Returns:
- Green intensity of this color, from 0 to 255
-
getBlue
int getBlue()- Returns:
- Blue intensity of this color, from 0 to 255
-
toColor
Deprecated.This adds a runtime dependency to the java.desktop module which isn't declared in the module descriptor of lanterna. If you want to call this method, make sure to add it to your module.Converts this color to an AWT color object, assuming a standard VGA palette.- Returns:
- TextColor as an AWT Color
-