Class Ansi
java.lang.Object
com.diogonunes.jcolor.Ansi
Provides a fluent API to generate
ANSI escape sequences
by specifying
Attributes of your format.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringEvery Ansi escape code must end with this POSTFIX.static final StringEvery Ansi escape code begins with this PREFIX.static final StringShorthand for the Ansi code that resets to the terminal's default format.static final StringTwo options must be separated by this SEPARATOR. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringApplies a terminal command (e.g. clear screen).static Stringcolorize(String text, AnsiFormat attributes) Wraps the text with the ANSI code defined by the given format.static StringWraps the text with the ANSI code that applies the given attributes.static StringWraps each line of the text with the given raw ANSI code and a trailing reset, so the format does not spill into subsequent prints.static StringgenerateCode(AnsiFormat attributes) Generates the ANSI code that applies the attributes contained in the given format.static StringgenerateCode(Attribute... attributes) Generates the ANSI code that applies the given attributes.static StringgenerateCode(Command command) Generates the ANSI code for a terminal command.static StringmakeItFabulous(String text, Attribute... attributes) Easter egg.
-
Field Details
-
PREFIX
-
SEPARATOR
-
POSTFIX
-
RESET
Shorthand for the Ansi code that resets to the terminal's default format.
-
-
Constructor Details
-
Ansi
public Ansi()Default constructor. Ansi is a static-utility class and is not meant to be instantiated.
-
-
Method Details
-
generateCode
-
generateCode
Generates the ANSI code that applies the attributes contained in the given format.- Parameters:
attributes- Object containing format attributes.- Returns:
- The ANSI code that describes all those attributes together.
-
generateCode
-
colorize
-
colorize
Wraps each line of the text with the given raw ANSI code and a trailing reset, so the format does not spill into subsequent prints.- Parameters:
text- String to format.ansiCode- Ansi code to format each message's lines.- Returns:
- The formatted string, ready to be printed.
-
colorize
-
colorize
Wraps the text with the ANSI code defined by the given format.- Parameters:
text- String to format.attributes- Object containing format attributes.- Returns:
- The formatted string, ready to be printed.
-
makeItFabulous
-