Enum AnsiEscapeCode

  • All Implemented Interfaces:
    org.refcodes.mixin.CodeAccessor<java.lang.Byte>


    public enum AnsiEscapeCode
    extends java.lang.Enum<AnsiEscapeCode>
    implements org.refcodes.mixin.CodeAccessor<java.lang.Byte>
    This enumeration contains ANSI Escape-Codes for modifying the appearance of console output to ANSI enabled terminals. In order to compose your basic ANSI Escape-Code sequences, you may go for toEscapeSequence(AnsiEscapeCode...). Use toEscapedSequence(String) when you wish to print the ANSI Escape-Code sequence without the sequence modifying your terminal output (e.g. helpful in error messages regarding ANSI Escape-Codes).
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.refcodes.mixin.CodeAccessor

        org.refcodes.mixin.CodeAccessor.CodeBuilder<V extends java.lang.Object,B extends org.refcodes.mixin.CodeAccessor.CodeBuilder<V,B>>, org.refcodes.mixin.CodeAccessor.CodeMutator<V extends java.lang.Object>, org.refcodes.mixin.CodeAccessor.CodeProperty<V extends java.lang.Object>
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      BG_BLACK
      Background Black: Set background color.
      BG_BLUE
      Background Blue: Set background color.
      BG_BRIGHT_BLACK
      Background Bright Black: Set bright background color (aixterm (not in standard).
      BG_BRIGHT_BLUE
      Background Bright Blue: Set bright background color (aixterm (not in standard).
      BG_BRIGHT_CYAN
      Background Bright Cyan: Set bright background color (aixterm (not in standard).
      BG_BRIGHT_DEFAULT
      Background Bright Default: Set bright background color (aixterm (not in standard).
      BG_BRIGHT_GREEN
      Background Bright Green: Set bright background color (aixterm (not in standard).
      BG_BRIGHT_MAGENTA
      Background Bright Magenta: Set bright background color (aixterm (not in standard).
      BG_BRIGHT_RED
      Background Bright Red: Set bright background color (aixterm (not in standard).
      BG_BRIGHT_WHITE
      Background Bright White: Set bright background color (aixterm (not in standard).
      BG_BRIGHT_YELLOW
      Background Bright Yellow: Set bright background color (aixterm (not in standard).
      BG_CYAN
      Background Cyan: Set background color.
      BG_GREEN
      Background Green: Set background color.
      BG_MAGENTA
      Background Magenta: Set background color.
      BG_RED
      Background Red: Set background color.
      BG_WHITE
      Background White: Set background color.
      BG_YELLOW
      Background Yellow: Set background color.
      BLINK_OFF
      Blink off:
      BOLD
      Bold or increased intensity:
      CONCEAL
      Conceal: Not widely supported.
      CROSSED_OUT
      Crossed-out: Characters legible but marked for deletion.
      DEFAULT_BACKGROUND_COLOR
      Default background color: implementation defined (according to standard)
      DEFAULT_FONT
      Primary(default) font:
      DEFAULT_FOREGROUND_COLOR
      Default foreground color: implementation defined (according to standard)
      DOUBLY_UNDERLINE_OR_BOLD_OFF
      Doubly underline or Bold off: Double-underline per ECMA-48.
      ENCIRCLED
      Encircled:
      FAINT
      Faint (decreased intensity):
      FG_BLACK
      Foreground Black: Set foreground color.
      FG_BLUE
      Foreground Blue: Set foreground color.
      FG_BRIGHT_BLACK
      Foreground Bright Black: Set bright foreground color (aixterm (not in standard).
      FG_BRIGHT_BLUE
      Foreground Bright Blue: Set bright foreground color (aixterm (not in standard).
      FG_BRIGHT_CYAN
      Foreground Bright Cyan: Set bright foreground color (aixterm (not in standard).
      FG_BRIGHT_DEFAULT
      Foreground Bright Default: Set bright foreground color (aixterm (not in standard).
      FG_BRIGHT_GREEN
      Foreground Bright Green: Set bright foreground color (aixterm (not in standard).
      FG_BRIGHT_MAGENTA
      Foreground Bright Magenta: Set bright foreground color (aixterm (not in standard).
      FG_BRIGHT_RED
      Foreground Bright Red: Set bright foreground color (aixterm (not in standard).
      FG_BRIGHT_WHITE
      Foreground Bright White: Set bright foreground color (aixterm (not in standard).
      FG_BRIGHT_YELLOW
      Foreground Bright Yellow: Set bright foreground color (aixterm (not in standard).
      FG_CYAN
      Foreground Cyan: Set foreground color.
      FG_GREEN
      Foreground Green: Set foreground color.
      FG_MAGENTA
      Foreground Magenta: Set foreground color.
      FG_RED
      Foreground Red: Set foreground color.
      FG_WHITE
      Foreground White: Set foreground color.
      FG_YELLOW
      Foreground Yellow: Set foreground color.
      FONT_1
      Font 1: Select alternative font 1.
      FONT_2
      Font 2: Select alternative font 2.
      FONT_3
      Font 3: Select alternative font 3.
      FONT_4
      Font 4: Select alternative font 4.
      FONT_5
      Font 5: Select alternative font 5.
      FONT_6
      Font 6: Select alternative font 6.
      FONT_7
      Font 7: Select alternative font 7.
      FONT_8
      Font 8: Select alternative font 8.
      FONT_9
      Font 9: Select alternative font 9.
      FRAKTUR
      Fraktur: Rarely supported.
      FRAMED
      Framed:
      IDEOGRAM_ATTRIBUTES_OFF
      ideogram attributes off: Reset the effects of all of 60–64.
      IDEOGRAM_DOUBLE_OVERLINE_OR_DOUBLE_LINE_ON_THE_LEFT_SIDE
      ideogram double overline or double line on the left side : Rarely supported.
      IDEOGRAM_DOUBLE_UNDERLINE_OR_DOUBLE_LINE_ON_THE_RIGHT_SIDE
      ideogram double underline or double line on the right side : Rarely supported.
      IDEOGRAM_OVERLINE_OR_LEFT_SIDE_LINE
      ideogram overline or left side line : Rarely supported.
      IDEOGRAM_STRESS_MARKING
      ideogram stress marking : Rarely supported.
      IDEOGRAM_UNDERLINE_OR_RIGHT_SIDE_LINE
      ideogram underline or right side line: Rarely supported.
      INVERSE_OFF
      Inverse off:
      ITALIC
      Italic: Not widely supported.
      NORMAL_COLOR_OR_INTENSITY
      Normal color or intensity: Neither bold nor faint.
      NOT_CROSSED_OUT
      Not crossed out:
      NOT_FRAMED
      Not framed or encircled:
      NOT_ITALIC_NOT_FRAKTUR
      Not italic: Not Fraktur.
      NOT_OVERLINED
      Not overlined:
      OVERLINED
      Overlined:
      RAPID_BLINK
      Rapid Blink: 150+ per minute.
      RESET
      Reset / Normal: All attributes off (reset).
      REVEAL
      Reveal: Conceal off.
      REVERSE_VIDEO
      reverse video: Swap foreground and background colors.
      SET_BACKGROUND_COLOR
      Set background color: Next arguments are 5;n or 2;r;g;b, see below: ESC[ 48:5:(n) m Select background color ESC[ 48;2;(r);(g);(b) m Select RGB background color (n) represents an index into a predefined 256-color lookup table (r) represents the 8 bit red portion of an RGB color (g) represents the 8 bit green portion of an RGB color (b) represents the 8 bit blue portion of an RGB color
      SET_FOREGROUND_COLOR
      Set foreground color: Next arguments are 5;n or 2;r;g;b, see below: ESC[ 38:5:(n) m Select foreground color ESC[ 38;2;(r);(g);(b) m Select RGB foreground color (n) represents an index into a predefined 256-color lookup table (r) represents the 8 bit red portion of an RGB color (g) represents the 8 bit green portion of an RGB color (b) represents the 8 bit blue portion of an RGB color
      SLOW_BLINK
      Slow Blink: Less than 150 per minute.
      UNDERLINE
      Underline:
      UNDERLINE_OFF
      Underline off: Not singly or doubly underlined.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Byte getCode​()
      java.lang.String toEscaped​()
      Returns the escaped ANSI Escape-Code to be printable without triggering the actual ANSI escape commands.
      static java.lang.String toEscapedSequence​(java.lang.String aEscapeSequence)
      MAkes the provided Escape-Sequence printable by replacing the ESCAPE code with a printable char sequence.
      static java.lang.String toEscapeSequence​(AnsiEscapeCode... aAnsiEscapeCodes)
      Basic functionality to create an ANSI Escape-Code sequence from the provided AnsiEscapeCode elements directly printable to System.out.
      static AnsiEscapeCode valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static AnsiEscapeCode[] 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

      • RESET

        public static final AnsiEscapeCode RESET
        Reset / Normal: All attributes off (reset).
      • BOLD

        public static final AnsiEscapeCode BOLD
        Bold or increased intensity:
      • FAINT

        public static final AnsiEscapeCode FAINT
        Faint (decreased intensity):
      • ITALIC

        public static final AnsiEscapeCode ITALIC
        Italic: Not widely supported. Sometimes treated as inverse.
      • SLOW_BLINK

        public static final AnsiEscapeCode SLOW_BLINK
        Slow Blink: Less than 150 per minute.
      • RAPID_BLINK

        public static final AnsiEscapeCode RAPID_BLINK
        Rapid Blink: 150+ per minute. Not widely supported.
      • REVERSE_VIDEO

        public static final AnsiEscapeCode REVERSE_VIDEO
        reverse video: Swap foreground and background colors.
      • CONCEAL

        public static final AnsiEscapeCode CONCEAL
        Conceal: Not widely supported.
      • CROSSED_OUT

        public static final AnsiEscapeCode CROSSED_OUT
        Crossed-out: Characters legible but marked for deletion.
      • DEFAULT_FONT

        public static final AnsiEscapeCode DEFAULT_FONT
        Primary(default) font:
      • FONT_1

        public static final AnsiEscapeCode FONT_1
        Font 1: Select alternative font 1.
      • FONT_2

        public static final AnsiEscapeCode FONT_2
        Font 2: Select alternative font 2.
      • FONT_3

        public static final AnsiEscapeCode FONT_3
        Font 3: Select alternative font 3.
      • FONT_4

        public static final AnsiEscapeCode FONT_4
        Font 4: Select alternative font 4.
      • FONT_5

        public static final AnsiEscapeCode FONT_5
        Font 5: Select alternative font 5.
      • FONT_6

        public static final AnsiEscapeCode FONT_6
        Font 6: Select alternative font 6.
      • FONT_7

        public static final AnsiEscapeCode FONT_7
        Font 7: Select alternative font 7.
      • FONT_8

        public static final AnsiEscapeCode FONT_8
        Font 8: Select alternative font 8.
      • FONT_9

        public static final AnsiEscapeCode FONT_9
        Font 9: Select alternative font 9.
      • FRAKTUR

        public static final AnsiEscapeCode FRAKTUR
        Fraktur: Rarely supported.
      • DOUBLY_UNDERLINE_OR_BOLD_OFF

        public static final AnsiEscapeCode DOUBLY_UNDERLINE_OR_BOLD_OFF
        Doubly underline or Bold off: Double-underline per ECMA-48.
      • NORMAL_COLOR_OR_INTENSITY

        public static final AnsiEscapeCode NORMAL_COLOR_OR_INTENSITY
        Normal color or intensity: Neither bold nor faint.
      • NOT_ITALIC_NOT_FRAKTUR

        public static final AnsiEscapeCode NOT_ITALIC_NOT_FRAKTUR
        Not italic: Not Fraktur.
      • UNDERLINE_OFF

        public static final AnsiEscapeCode UNDERLINE_OFF
        Underline off: Not singly or doubly underlined.
      • INVERSE_OFF

        public static final AnsiEscapeCode INVERSE_OFF
        Inverse off:
      • REVEAL

        public static final AnsiEscapeCode REVEAL
        Reveal: Conceal off.
      • NOT_CROSSED_OUT

        public static final AnsiEscapeCode NOT_CROSSED_OUT
        Not crossed out:
      • FG_BLACK

        public static final AnsiEscapeCode FG_BLACK
        Foreground Black: Set foreground color.
      • FG_RED

        public static final AnsiEscapeCode FG_RED
        Foreground Red: Set foreground color.
      • FG_GREEN

        public static final AnsiEscapeCode FG_GREEN
        Foreground Green: Set foreground color.
      • FG_YELLOW

        public static final AnsiEscapeCode FG_YELLOW
        Foreground Yellow: Set foreground color.
      • FG_BLUE

        public static final AnsiEscapeCode FG_BLUE
        Foreground Blue: Set foreground color.
      • FG_MAGENTA

        public static final AnsiEscapeCode FG_MAGENTA
        Foreground Magenta: Set foreground color.
      • FG_CYAN

        public static final AnsiEscapeCode FG_CYAN
        Foreground Cyan: Set foreground color.
      • FG_WHITE

        public static final AnsiEscapeCode FG_WHITE
        Foreground White: Set foreground color.
      • SET_FOREGROUND_COLOR

        public static final AnsiEscapeCode SET_FOREGROUND_COLOR
        Set foreground color: Next arguments are 5;n or 2;r;g;b, see below: ESC[ 38:5:(n) m Select foreground color ESC[ 38;2;(r);(g);(b) m Select RGB foreground color (n) represents an index into a predefined 256-color lookup table (r) represents the 8 bit red portion of an RGB color (g) represents the 8 bit green portion of an RGB color (b) represents the 8 bit blue portion of an RGB color
      • DEFAULT_FOREGROUND_COLOR

        public static final AnsiEscapeCode DEFAULT_FOREGROUND_COLOR
        Default foreground color: implementation defined (according to standard)
      • BG_BLACK

        public static final AnsiEscapeCode BG_BLACK
        Background Black: Set background color.
      • BG_RED

        public static final AnsiEscapeCode BG_RED
        Background Red: Set background color.
      • BG_GREEN

        public static final AnsiEscapeCode BG_GREEN
        Background Green: Set background color.
      • BG_YELLOW

        public static final AnsiEscapeCode BG_YELLOW
        Background Yellow: Set background color.
      • BG_BLUE

        public static final AnsiEscapeCode BG_BLUE
        Background Blue: Set background color.
      • BG_MAGENTA

        public static final AnsiEscapeCode BG_MAGENTA
        Background Magenta: Set background color.
      • BG_CYAN

        public static final AnsiEscapeCode BG_CYAN
        Background Cyan: Set background color.
      • BG_WHITE

        public static final AnsiEscapeCode BG_WHITE
        Background White: Set background color.
      • SET_BACKGROUND_COLOR

        public static final AnsiEscapeCode SET_BACKGROUND_COLOR
        Set background color: Next arguments are 5;n or 2;r;g;b, see below: ESC[ 48:5:(n) m Select background color ESC[ 48;2;(r);(g);(b) m Select RGB background color (n) represents an index into a predefined 256-color lookup table (r) represents the 8 bit red portion of an RGB color (g) represents the 8 bit green portion of an RGB color (b) represents the 8 bit blue portion of an RGB color
      • DEFAULT_BACKGROUND_COLOR

        public static final AnsiEscapeCode DEFAULT_BACKGROUND_COLOR
        Default background color: implementation defined (according to standard)
      • NOT_FRAMED

        public static final AnsiEscapeCode NOT_FRAMED
        Not framed or encircled:
      • NOT_OVERLINED

        public static final AnsiEscapeCode NOT_OVERLINED
        Not overlined:
      • IDEOGRAM_UNDERLINE_OR_RIGHT_SIDE_LINE

        public static final AnsiEscapeCode IDEOGRAM_UNDERLINE_OR_RIGHT_SIDE_LINE
        ideogram underline or right side line: Rarely supported.
      • IDEOGRAM_DOUBLE_UNDERLINE_OR_DOUBLE_LINE_ON_THE_RIGHT_SIDE

        public static final AnsiEscapeCode IDEOGRAM_DOUBLE_UNDERLINE_OR_DOUBLE_LINE_ON_THE_RIGHT_SIDE
        ideogram double underline or double line on the right side : Rarely supported.
      • IDEOGRAM_OVERLINE_OR_LEFT_SIDE_LINE

        public static final AnsiEscapeCode IDEOGRAM_OVERLINE_OR_LEFT_SIDE_LINE
        ideogram overline or left side line : Rarely supported.
      • IDEOGRAM_DOUBLE_OVERLINE_OR_DOUBLE_LINE_ON_THE_LEFT_SIDE

        public static final AnsiEscapeCode IDEOGRAM_DOUBLE_OVERLINE_OR_DOUBLE_LINE_ON_THE_LEFT_SIDE
        ideogram double overline or double line on the left side : Rarely supported.
      • IDEOGRAM_STRESS_MARKING

        public static final AnsiEscapeCode IDEOGRAM_STRESS_MARKING
        ideogram stress marking : Rarely supported.
      • IDEOGRAM_ATTRIBUTES_OFF

        public static final AnsiEscapeCode IDEOGRAM_ATTRIBUTES_OFF
        ideogram attributes off: Reset the effects of all of 60–64.
      • FG_BRIGHT_BLACK

        public static final AnsiEscapeCode FG_BRIGHT_BLACK
        Foreground Bright Black: Set bright foreground color (aixterm (not in standard).
      • FG_BRIGHT_RED

        public static final AnsiEscapeCode FG_BRIGHT_RED
        Foreground Bright Red: Set bright foreground color (aixterm (not in standard).
      • FG_BRIGHT_GREEN

        public static final AnsiEscapeCode FG_BRIGHT_GREEN
        Foreground Bright Green: Set bright foreground color (aixterm (not in standard).
      • FG_BRIGHT_YELLOW

        public static final AnsiEscapeCode FG_BRIGHT_YELLOW
        Foreground Bright Yellow: Set bright foreground color (aixterm (not in standard).
      • FG_BRIGHT_BLUE

        public static final AnsiEscapeCode FG_BRIGHT_BLUE
        Foreground Bright Blue: Set bright foreground color (aixterm (not in standard).
      • FG_BRIGHT_MAGENTA

        public static final AnsiEscapeCode FG_BRIGHT_MAGENTA
        Foreground Bright Magenta: Set bright foreground color (aixterm (not in standard).
      • FG_BRIGHT_CYAN

        public static final AnsiEscapeCode FG_BRIGHT_CYAN
        Foreground Bright Cyan: Set bright foreground color (aixterm (not in standard).
      • FG_BRIGHT_WHITE

        public static final AnsiEscapeCode FG_BRIGHT_WHITE
        Foreground Bright White: Set bright foreground color (aixterm (not in standard).
      • FG_BRIGHT_DEFAULT

        public static final AnsiEscapeCode FG_BRIGHT_DEFAULT
        Foreground Bright Default: Set bright foreground color (aixterm (not in standard).
      • BG_BRIGHT_BLACK

        public static final AnsiEscapeCode BG_BRIGHT_BLACK
        Background Bright Black: Set bright background color (aixterm (not in standard).
      • BG_BRIGHT_RED

        public static final AnsiEscapeCode BG_BRIGHT_RED
        Background Bright Red: Set bright background color (aixterm (not in standard).
      • BG_BRIGHT_GREEN

        public static final AnsiEscapeCode BG_BRIGHT_GREEN
        Background Bright Green: Set bright background color (aixterm (not in standard).
      • BG_BRIGHT_YELLOW

        public static final AnsiEscapeCode BG_BRIGHT_YELLOW
        Background Bright Yellow: Set bright background color (aixterm (not in standard).
      • BG_BRIGHT_BLUE

        public static final AnsiEscapeCode BG_BRIGHT_BLUE
        Background Bright Blue: Set bright background color (aixterm (not in standard).
      • BG_BRIGHT_MAGENTA

        public static final AnsiEscapeCode BG_BRIGHT_MAGENTA
        Background Bright Magenta: Set bright background color (aixterm (not in standard).
      • BG_BRIGHT_CYAN

        public static final AnsiEscapeCode BG_BRIGHT_CYAN
        Background Bright Cyan: Set bright background color (aixterm (not in standard).
      • BG_BRIGHT_WHITE

        public static final AnsiEscapeCode BG_BRIGHT_WHITE
        Background Bright White: Set bright background color (aixterm (not in standard).
      • BG_BRIGHT_DEFAULT

        public static final AnsiEscapeCode BG_BRIGHT_DEFAULT
        Background Bright Default: Set bright background color (aixterm (not in standard).
    • Field Detail

      • ESCAPE

        public static char ESCAPE
        The ANSI Escape-Code with which each ANSI escape sequence is commenced.
      • ESCAPE_SUFFIX

        public static char ESCAPE_SUFFIX
        The ANSI Escape-Code with which each ANSI escape sequence is concluded.
      • ESCAPE_PARAMETER_DELIMITER

        public static char ESCAPE_PARAMETER_DELIMITER
        The delimiter used to separate the parameters of an ANSI Escape-Sequence, e.g. the parameters "0", "1" and ""4" of the sequence "<ESC>[0;1;4m".
      • ESCAPE_PREFIX_DELIMITER

        public static char ESCAPE_PREFIX_DELIMITER
        The delimiter used to separate the leading Escape-Code <ESC> of an ANSI Escape-Sequence from the succeeding portion, e.g. "[" separates <ESC> from "[0;1;4m" of the sequence "<ESC>[0;1;4m".
    • Method Detail

      • values

        public static AnsiEscapeCode[] 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 (AnsiEscapeCode c : AnsiEscapeCode.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static AnsiEscapeCode 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
      • getCode

        public java.lang.Byte getCode​()
        Specified by:
        getCode in interface org.refcodes.mixin.CodeAccessor<java.lang.Byte>
      • toEscaped

        public java.lang.String toEscaped​()
        Returns the escaped ANSI Escape-Code to be printable without triggering the actual ANSI escape commands.
        Returns:
        The escaped ANSI Escape-Code.
      • toEscapeSequence

        public static java.lang.String toEscapeSequence​(AnsiEscapeCode... aAnsiEscapeCodes)
        Basic functionality to create an ANSI Escape-Code sequence from the provided AnsiEscapeCode elements directly printable to System.out. This method can only provide placeholder such as ${n0}, ${n1}, ... for elements SET_FOREGROUND_COLOR and SET_BACKGROUND_COLOR (the numbers correspond to the order of their appearance). Consider building your sequence manually in case you want to use a RGB value instead of an index into the ANSI Color-Table.
        Parameters:
        aAnsiEscapeCodes - The Escape-Codes to be included in the Escape-Code sequence.
        Returns:
        The correctly generated Escape-Code sequence directly printable to System.out.
      • toEscapedSequence

        public static java.lang.String toEscapedSequence​(java.lang.String aEscapeSequence)
        MAkes the provided Escape-Sequence printable by replacing the ESCAPE code with a printable char sequence. This means that the Escape-Sequence is disabled so that it will be printed out as plain text.
        Parameters:
        aEscapeSequence - The Escape-Sequence to be printed out as plain text.
        Returns:
        The plain text representation of the given Escape-Sequence.