Package com.diogonunes.jcolor
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 Stringstatic Stringcolorize(String text, AnsiFormat attributes) static Stringstatic Stringstatic StringgenerateCode(AnsiFormat attributes) static StringgenerateCode(Attribute... attributes) static StringgenerateCode(Command command) static StringmakeItFabulous(String text, Attribute... attributes) Easter egg.
-
Field Details
-
PREFIX
Every Ansi escape code begins with this PREFIX.- See Also:
-
SEPARATOR
Two options must be separated by this SEPARATOR.- See Also:
-
POSTFIX
Every Ansi escape code must end with this POSTFIX.- See Also:
-
RESET
Shorthand for the Ansi code that resets to the terminal's default format.
-
-
Constructor Details
-
Ansi
public Ansi()
-
-
Method Details
-
generateCode
- Parameters:
attributes- ANSI attributes to format a text.- Returns:
- The ANSI code that describes all those attributes together.
-
generateCode
- Parameters:
attributes- Object containing format attributes.- Returns:
- The ANSI code that describes all those attributes together.
-
generateCode
- Parameters:
command- ANSI command to apply to terminal.- Returns:
- The ANSI code that describes that command.
-
colorize
- Parameters:
command- Ansi command to apply to terminal.- Returns:
- The formatted string, ready to be printed.
-
colorize
- Parameters:
text- String to format.ansiCode- Ansi code to format each message's lines.- Returns:
- The formatted string, ready to be printed.
-
colorize
- Parameters:
text- String to format.attributes- ANSI attributes to format a text.- Returns:
- The formatted string, ready to be printed.
-
colorize
- Parameters:
text- String to format.attributes- Object containing format attributes.- Returns:
- The formatted string, ready to be printed.
-
makeItFabulous
Easter egg. Just an alias of method "colorize".- Parameters:
text- String to format.attributes- ANSI attributes to format a text.- Returns:
- The formatted string, ready to be printed.
-