Enum Class AnsiColor

java.lang.Object
java.lang.Enum<AnsiColor>
nl.colorize.util.cli.AnsiColor
All Implemented Interfaces:
Serializable, Comparable<AnsiColor>, Constable

public enum AnsiColor extends Enum<AnsiColor>
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.
  • Enum Constant Details

    • RED

      public static final AnsiColor RED
    • GREEN

      public static final AnsiColor GREEN
    • YELLOW

      public static final AnsiColor YELLOW
    • BLUE

      public static final AnsiColor BLUE
    • MAGENTA

      public static final AnsiColor MAGENTA
    • CYAN

      public static final AnsiColor CYAN
    • RED_BOLD

      public static final AnsiColor RED_BOLD
    • GREEN_BOLD

      public static final AnsiColor GREEN_BOLD
    • YELLOW_BOLD

      public static final AnsiColor YELLOW_BOLD
    • BLUE_BOLD

      public static final AnsiColor BLUE_BOLD
    • MAGENTA_BOLD

      public static final AnsiColor MAGENTA_BOLD
    • CYAN_BOLD

      public static final AnsiColor CYAN_BOLD
  • Method Details

    • values

      public static AnsiColor[] 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

      public static AnsiColor valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • format

      public String format(String text)
      Formats the specified text using this color and styling. Returns the formatting string including ANSI escape codes.
    • print

      public void print(String text)
      Formats the specified text using this color and styling, then prints the result to stdout. Using this method is a shorthand/convenience version of System.out.print(format(text)).
    • println

      public void println(String text)
      Formats the specified text using this color and styling, then prints the result to stdout. Using this method is a shorthand/convenience version of System.out.println(format(text)).
    • clean

      public static String clean(String text)
      Removes all ANSI escape codes from a string. This method can be used to reverse the effects of format(String), or to remove ANSI escape codes generated by other means.