Enum AnsiEscape

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<AnsiEscape>

    public enum AnsiEscape
    extends java.lang.Enum<AnsiEscape>
    Converts text into ANSI escape sequences.

    The names for colors and attributes are standard, but the exact shade/hue/value of colors are not, and depend on the device used to display them.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String code  
      private static java.lang.String DEFAULT_STYLE  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private AnsiEscape​(java.lang.String code)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Map<java.lang.String,​java.lang.String> createMap​(java.lang.String[] values, java.lang.String[] dontEscapeKeys)
      Creates a Map from a source array where values are ANSI escape sequences.
      static java.util.Map<java.lang.String,​java.lang.String> createMap​(java.lang.String values, java.lang.String[] dontEscapeKeys)
      Creates a Map from a source array where values are ANSI escape sequences.
      static java.lang.String createSequence​(java.lang.String... names)
      Creates an ANSI escape sequence from the given AnsiEscape names.
      java.lang.String getCode()
      Gets the escape code.
      static java.lang.String getDefaultStyle()
      Gets the default style.
      static AnsiEscape valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static AnsiEscape[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • CSI

        public static final AnsiEscape CSI
        The Control Sequence Introducer (or Control Sequence Initiator).

        Most sequences are more than two characters and start with the characters ESC and [ (the left bracket).

      • SUFFIX

        public static final AnsiEscape SUFFIX
        Escape suffix.
      • SEPARATOR

        public static final AnsiEscape SEPARATOR
        Escape separator.
      • NORMAL

        public static final AnsiEscape NORMAL
        Normal general attribute.
      • BRIGHT

        public static final AnsiEscape BRIGHT
        Deprecated.
        This attribute sets font-weight as "bold" and doesn't set color brightness. Use BOLD if you need to change font-weight and BRIGHT_* to use a bright color.
        Bright general attribute.
      • BOLD

        public static final AnsiEscape BOLD
        Bold general attribute.
      • DIM

        public static final AnsiEscape DIM
        Dim general attribute.
      • UNDERLINE

        public static final AnsiEscape UNDERLINE
        Underline general attribute.
      • BLINK

        public static final AnsiEscape BLINK
        Blink general attribute.
      • REVERSE

        public static final AnsiEscape REVERSE
        Reverse general attribute.
      • HIDDEN

        public static final AnsiEscape HIDDEN
        Normal general attribute.
      • BLACK

        public static final AnsiEscape BLACK
        Black foreground color.
      • FG_BLACK

        public static final AnsiEscape FG_BLACK
        Black foreground color.
      • RED

        public static final AnsiEscape RED
        Red foreground color.
      • FG_RED

        public static final AnsiEscape FG_RED
        Red foreground color.
      • GREEN

        public static final AnsiEscape GREEN
        Green foreground color.
      • FG_GREEN

        public static final AnsiEscape FG_GREEN
        Green foreground color.
      • YELLOW

        public static final AnsiEscape YELLOW
        Yellow foreground color.
      • FG_YELLOW

        public static final AnsiEscape FG_YELLOW
        Yellow foreground color.
      • BLUE

        public static final AnsiEscape BLUE
        Blue foreground color.
      • FG_BLUE

        public static final AnsiEscape FG_BLUE
        Blue foreground color.
      • MAGENTA

        public static final AnsiEscape MAGENTA
        Magenta foreground color.
      • FG_MAGENTA

        public static final AnsiEscape FG_MAGENTA
        Magenta foreground color.
      • CYAN

        public static final AnsiEscape CYAN
        Cyan foreground color.
      • FG_CYAN

        public static final AnsiEscape FG_CYAN
        Cyan foreground color.
      • WHITE

        public static final AnsiEscape WHITE
        White foreground color.
      • FG_WHITE

        public static final AnsiEscape FG_WHITE
        White foreground color.
      • DEFAULT

        public static final AnsiEscape DEFAULT
        Default foreground color.
      • FG_DEFAULT

        public static final AnsiEscape FG_DEFAULT
        Default foreground color.
      • BG_BLACK

        public static final AnsiEscape BG_BLACK
        Black background color.
      • BG_RED

        public static final AnsiEscape BG_RED
        Red background color.
      • BG_GREEN

        public static final AnsiEscape BG_GREEN
        Green background color.
      • BG_YELLOW

        public static final AnsiEscape BG_YELLOW
        Yellow background color.
      • BG_BLUE

        public static final AnsiEscape BG_BLUE
        Blue background color.
      • BG_MAGENTA

        public static final AnsiEscape BG_MAGENTA
        Magenta background color.
      • BG_CYAN

        public static final AnsiEscape BG_CYAN
        Cyan background color.
      • BG_WHITE

        public static final AnsiEscape BG_WHITE
        White background color.
      • BRIGHT_BLACK

        public static final AnsiEscape BRIGHT_BLACK
        Bright black foreground color.
      • FG_BRIGHT_BLACK

        public static final AnsiEscape FG_BRIGHT_BLACK
        Bright black foreground color.
      • BRIGHT_RED

        public static final AnsiEscape BRIGHT_RED
        Bright red foreground color.
      • FG_BRIGHT_RED

        public static final AnsiEscape FG_BRIGHT_RED
        Bright red foreground color.
      • BRIGHT_GREEN

        public static final AnsiEscape BRIGHT_GREEN
        Bright green foreground color.
      • FG_BRIGHT_GREEN

        public static final AnsiEscape FG_BRIGHT_GREEN
        Bright green foreground color.
      • BRIGHT_YELLOW

        public static final AnsiEscape BRIGHT_YELLOW
        Bright yellow foreground color.
      • FG_BRIGHT_YELLOW

        public static final AnsiEscape FG_BRIGHT_YELLOW
        Bright yellow foreground color.
      • BRIGHT_BLUE

        public static final AnsiEscape BRIGHT_BLUE
        Bright blue foreground color.
      • FG_BRIGHT_BLUE

        public static final AnsiEscape FG_BRIGHT_BLUE
        Bright blue foreground color.
      • BRIGHT_MAGENTA

        public static final AnsiEscape BRIGHT_MAGENTA
        Bright magenta foreground color.
      • FG_BRIGHT_MAGENTA

        public static final AnsiEscape FG_BRIGHT_MAGENTA
        Bright magenta foreground color.
      • BRIGHT_CYAN

        public static final AnsiEscape BRIGHT_CYAN
        Bright cyan foreground color.
      • FG_BRIGHT_CYAN

        public static final AnsiEscape FG_BRIGHT_CYAN
        Bright cyan foreground color.
      • BRIGHT_WHITE

        public static final AnsiEscape BRIGHT_WHITE
        Bright white foreground color.
      • FG_BRIGHT_WHITE

        public static final AnsiEscape FG_BRIGHT_WHITE
        Bright white foreground color.
      • BG_BRIGHT_BLACK

        public static final AnsiEscape BG_BRIGHT_BLACK
        Bright black background color.
      • BG_BRIGHT_RED

        public static final AnsiEscape BG_BRIGHT_RED
        Bright red background color.
      • BG_BRIGHT_GREEN

        public static final AnsiEscape BG_BRIGHT_GREEN
        Bright green background color.
      • BG_BRIGHT_YELLOW

        public static final AnsiEscape BG_BRIGHT_YELLOW
        Bright yellow background color.
      • BG_BRIGHT_BLUE

        public static final AnsiEscape BG_BRIGHT_BLUE
        Bright blue background color.
      • BG_BRIGHT_MAGENTA

        public static final AnsiEscape BG_BRIGHT_MAGENTA
        Bright magenta background color.
      • BG_BRIGHT_CYAN

        public static final AnsiEscape BG_BRIGHT_CYAN
        Bright cyan background color.
      • BG_BRIGHT_WHITE

        public static final AnsiEscape BG_BRIGHT_WHITE
        Bright white background color.
    • Field Detail

      • DEFAULT_STYLE

        private static final java.lang.String DEFAULT_STYLE
      • code

        private final java.lang.String code
    • Constructor Detail

      • AnsiEscape

        private AnsiEscape​(java.lang.String code)
    • Method Detail

      • values

        public static AnsiEscape[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (AnsiEscape c : AnsiEscape.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static AnsiEscape valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • getDefaultStyle

        public static java.lang.String getDefaultStyle()
        Gets the default style.
        Returns:
        the default style
      • getCode

        public java.lang.String getCode()
        Gets the escape code.
        Returns:
        the escape code.
      • createMap

        public static java.util.Map<java.lang.String,​java.lang.String> createMap​(java.lang.String values,
                                                                                       java.lang.String[] dontEscapeKeys)
        Creates a Map from a source array where values are ANSI escape sequences. The format is:
         Key1=Value, Key2=Value, ...
         
        For example:
         ERROR=red bold, WARN=yellow bold, INFO=green, ...
         
        You can use whitespace around the comma and equal sign. The names in values MUST come from the AnsiEscape enum, case is normalized to upper-case internally.
        Parameters:
        values - the source string to parse.
        dontEscapeKeys - do not escape these keys, leave the values as is in the map
        Returns:
        a new map
      • createMap

        public static java.util.Map<java.lang.String,​java.lang.String> createMap​(java.lang.String[] values,
                                                                                       java.lang.String[] dontEscapeKeys)
        Creates a Map from a source array where values are ANSI escape sequences. Each array entry must be in the format:
         Key1 = Value
         
        For example:
         ERROR=red bold
         
        You can use whitespace around the equal sign and between the value elements. The names in values MUST come from the AnsiEscape enum, case is normalized to upper-case internally.
        Parameters:
        values - the source array to parse.
        dontEscapeKeys - do not escape these keys, leave the values as is in the map
        Returns:
        a new map
      • createSequence

        public static java.lang.String createSequence​(java.lang.String... names)
        Creates an ANSI escape sequence from the given AnsiEscape names.
        Parameters:
        names - AnsiEscape names.
        Returns:
        An ANSI escape sequence.