Class Ansi

java.lang.Object
com.diogonunes.jcolor.Ansi

public class Ansi extends Object
Provides a fluent API to generate ANSI escape sequences by specifying Attributes of your format.
  • Field Details

    • PREFIX

      public static final String PREFIX
      Every Ansi escape code begins with this PREFIX.
      See Also:
    • SEPARATOR

      public static final String SEPARATOR
      Two options must be separated by this SEPARATOR.
      See Also:
    • POSTFIX

      public static final String POSTFIX
      Every Ansi escape code must end with this POSTFIX.
      See Also:
    • RESET

      public static final String RESET
      Shorthand for the Ansi code that resets to the terminal's default format.
  • Constructor Details

    • Ansi

      public Ansi()
  • Method Details

    • generateCode

      public static String generateCode(Attribute... attributes)
      Parameters:
      attributes - ANSI attributes to format a text.
      Returns:
      The ANSI code that describes all those attributes together.
    • generateCode

      public static String generateCode(AnsiFormat attributes)
      Parameters:
      attributes - Object containing format attributes.
      Returns:
      The ANSI code that describes all those attributes together.
    • generateCode

      public static String generateCode(Command command)
      Parameters:
      command - ANSI command to apply to terminal.
      Returns:
      The ANSI code that describes that command.
    • colorize

      public static String colorize(Command command)
      Parameters:
      command - Ansi command to apply to terminal.
      Returns:
      The formatted string, ready to be printed.
    • colorize

      public static String colorize(String text, String ansiCode)
      Parameters:
      text - String to format.
      ansiCode - Ansi code to format each message's lines.
      Returns:
      The formatted string, ready to be printed.
    • colorize

      public static String colorize(String text, Attribute... attributes)
      Parameters:
      text - String to format.
      attributes - ANSI attributes to format a text.
      Returns:
      The formatted string, ready to be printed.
    • colorize

      public static String colorize(String text, AnsiFormat attributes)
      Parameters:
      text - String to format.
      attributes - Object containing format attributes.
      Returns:
      The formatted string, ready to be printed.
    • makeItFabulous

      public static String makeItFabulous(String text, Attribute... attributes)
      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.