Package nl.colorize.util.cli
Enum Class AnsiColor
- All Implemented Interfaces:
Serializable
,Comparable<AnsiColor>
,Constable
ANSI escape codes
to format command line output in a more human-readable way. This class
intentionally does not support white or black, since both black-on-white
and white-on-black terminals are widely used, so this avoids formatting
that would make the text unreadable.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescription -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Removes all ANSI escape codes from a string.Formats the specified text using this color and styling.void
Formats the specified text using this color and styling, then prints the result tostdout
.void
Formats the specified text using this color and styling, then prints the result tostdout
.static AnsiColor
Returns the enum constant of this class with the specified name.static AnsiColor[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
RED
-
GREEN
-
YELLOW
-
BLUE
-
MAGENTA
-
CYAN
-
RED_BOLD
-
GREEN_BOLD
-
YELLOW_BOLD
-
BLUE_BOLD
-
MAGENTA_BOLD
-
CYAN_BOLD
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException
- if the argument is null
-
format
Formats the specified text using this color and styling. Returns the formatting string including ANSI escape codes. -
print
Formats the specified text using this color and styling, then prints the result tostdout
. Using this method is a shorthand/convenience version ofSystem.out.print(format(text))
. -
println
Formats the specified text using this color and styling, then prints the result tostdout
. Using this method is a shorthand/convenience version ofSystem.out.println(format(text))
. -
clean
Removes all ANSI escape codes from a string. This method can be used to reverse the effects offormat(String)
, or to remove ANSI escape codes generated by other means.
-