-
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
TextColor.ANSI,TextColor.Indexed,TextColor.RGB
public interface TextColor extends java.io.SerializableThis 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 Classes Modifier and Type Interface Description static classTextColor.ANSIThis class represent classic ANSI colors that are likely to be very compatible with most terminal implementations.static classTextColor.FactoryUtility class to instantiate colors from other types and definitionsstatic classTextColor.IndexedThis class represents a color expressed in the indexed XTerm 256 color extension, where each color is defined in a lookup-table.static classTextColor.RGBThis class can be used to specify a color in 24-bit color space (RGB with 8-bit resolution per color).
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description 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.intgetBlue()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.intgetGreen()intgetRed()java.awt.ColortoColor()Deprecated.This adds a runtime dependency to the java.desktop module which isn't declared in the module descriptor of lanterna.
-
-
-
Method Detail
-
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 java.awt.Color 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
-
-