Enum TerminalColor
- java.lang.Object
-
- java.lang.Enum<TerminalColor>
-
- com.github.oowekyala.ooxml.messages.TerminalColor
-
- All Implemented Interfaces:
Serializable,Comparable<TerminalColor>
public enum TerminalColor extends Enum<TerminalColor>
ANSI escape sequences for colors, to style text in terminal environments.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description COL_BLACKCOL_BLUECOL_CYANCOL_GREENCOL_MAGENTACOL_REDCOL_WHITECOL_YELLOW
-
Field Summary
Fields Modifier and Type Field Description static StringANSI_RESETReset all attributes.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringapply(String text, boolean bright, boolean background, boolean bold)Style the given string with this color.static Stringstyle(String text, TerminalColor foreground, TerminalColor background, boolean brightFg, boolean brightBg, boolean boldText)Style both foreground and background.static TerminalColorvalueOf(String name)Returns the enum constant of this type with the specified name.static TerminalColor[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
COL_BLACK
public static final TerminalColor COL_BLACK
-
COL_RED
public static final TerminalColor COL_RED
-
COL_GREEN
public static final TerminalColor COL_GREEN
-
COL_YELLOW
public static final TerminalColor COL_YELLOW
-
COL_BLUE
public static final TerminalColor COL_BLUE
-
COL_MAGENTA
public static final TerminalColor COL_MAGENTA
-
COL_CYAN
public static final TerminalColor COL_CYAN
-
COL_WHITE
public static final TerminalColor COL_WHITE
-
-
Field Detail
-
ANSI_RESET
public static final String ANSI_RESET
Reset all attributes.- See Also:
- Constant Field Values
-
-
Method Detail
-
values
public static TerminalColor[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (TerminalColor c : TerminalColor.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static TerminalColor valueOf(String name)
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
-
apply
public String apply(String text, boolean bright, boolean background, boolean bold)
Style the given string with this color. All text attributes are reset at the end.- Parameters:
text- Text to colorbright- Whether to use a bright version of this colorbackground- Whether to set the color on the text background rather than on the colorbold- Whether to set the text as bold- Returns:
- A string surrounded by escape sequences
-
style
public static String style(String text, TerminalColor foreground, TerminalColor background, boolean brightFg, boolean brightBg, boolean boldText)
Style both foreground and background. Returns a new string containing the parameter, which uses this ANSI code at the beginning, and resets all text attributes at the end.- Parameters:
text- Text to colorforeground- Text colorbackground- Background colorbrightFg- Whether text color is brightbrightBg- Whether background color is brightboldText- Whether to set the text as bold- Returns:
- A string surrounded by escape sequences
-
-