Enum ColorLevel

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

    public enum ColorLevel
    extends java.lang.Enum<ColorLevel>
    Supported color levels.
    Since:
    1.0.0
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static @NotNull ColorLevel compute()
      Attempt to estimate the supported color level of the current terminal using the active environment.
      abstract @NotNull java.lang.String determineEscape​(int rgbColor)
      Provide an ANSI escape sequence for the provided color.
      static ColorLevel valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static ColorLevel[] 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

      • NONE

        public static final ColorLevel NONE
        No color at all.

        Sometimes referred to as a "dumb" terminal. This option may be useful when the output is not a terminal, but, for example, a file.

        Since:
        1.0.0
      • TRUE_COLOR

        public static final ColorLevel TRUE_COLOR
        Full RGB color.

        Not supported by some terminals

        Since:
        1.0.0
      • INDEXED_256

        public static final ColorLevel INDEXED_256
        256 color.
        Since:
        1.0.0
      • INDEXED_16

        public static final ColorLevel INDEXED_16
        16 color.

        This should be supported most everywhere.

        Since:
        1.0.0
    • Field Detail

      • COLOR_LEVEL_PROPERTY

        public static final java.lang.String COLOR_LEVEL_PROPERTY
        See Also:
        Constant Field Values
      • TERMINAL_ANSI_OVERRIDE_PROPERTY

        public static final java.lang.String TERMINAL_ANSI_OVERRIDE_PROPERTY
        See Also:
        Constant Field Values
    • Method Detail

      • values

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

        public static ColorLevel 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
      • compute

        @NotNull
        public static @NotNull ColorLevel compute()
        Attempt to estimate the supported color level of the current terminal using the active environment.

        Use the system property "net.kyori.ansi.colorLevel" to override the result of this function

        Returns:
        the estimated color level
        Since:
        1.0.0
      • determineEscape

        @NotNull
        public abstract @NotNull java.lang.String determineEscape​(int rgbColor)
        Provide an ANSI escape sequence for the provided color.

        The leading \e[ and trailing m should not be provided. Those will be added by the renderer.

        Parameters:
        rgbColor - the packed RGB value of the color
        Returns:
        an appropriate escape sequence for the color
        Since:
        1.0.0