Class AnsiColor

java.lang.Object
nl.colorize.util.cli.AnsiColor

public class AnsiColor extends Object
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.
  • Field 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

    • 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)).