Enum ColorDepth

java.lang.Object
java.lang.Enum<ColorDepth>
org.aesh.terminal.utils.ColorDepth
All Implemented Interfaces:
Serializable, Comparable<ColorDepth>, java.lang.constant.Constable

public enum ColorDepth extends Enum<ColorDepth>
Represents the color depth capability of a terminal.

Terminals can support different levels of color:

  • NO_COLOR - No color support (monochrome)
  • COLORS_8 - 8 basic ANSI colors (SGR 30-37, 40-47)
  • COLORS_16 - 16 colors (8 colors + bright variants)
  • COLORS_256 - 256 color palette (SGR 38;5;n)
  • TRUE_COLOR - 24-bit true color support (SGR 38;2;r;g;b)
Author:
Ståle W. Pedersen
  • Enum Constant Details

    • NO_COLOR

      public static final ColorDepth NO_COLOR
      No color support - monochrome terminal
    • COLORS_8

      public static final ColorDepth COLORS_8
      8 basic ANSI colors (black, red, green, yellow, blue, magenta, cyan, white)
    • COLORS_16

      public static final ColorDepth COLORS_16
      16 colors - 8 basic colors plus their bright/bold variants
    • COLORS_256

      public static final ColorDepth COLORS_256
      256 color palette support (xterm-256color)
    • TRUE_COLOR

      public static final ColorDepth TRUE_COLOR
      24-bit true color support (16 million colors)
  • Method Details

    • values

      public static ColorDepth[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static ColorDepth valueOf(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:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • getColorCount

      public int getColorCount()
      Get the maximum number of colors supported at this depth.
      Returns:
      the maximum number of colors supported at this depth
    • supports256Colors

      public boolean supports256Colors()
      Check if this color depth supports at least 256 colors
      Returns:
      true if 256 colors or more are supported
    • supportsTrueColor

      public boolean supportsTrueColor()
      Check if this color depth supports true color (24-bit)
      Returns:
      true if true color is supported
    • supports16Colors

      public boolean supports16Colors()
      Check if this color depth supports at least 16 colors
      Returns:
      true if 16 colors or more are supported
    • supportsColor

      public boolean supportsColor()
      Check if this color depth supports any color
      Returns:
      true if any color is supported
    • fromColorCount

      public static ColorDepth fromColorCount(int colors)
      Determine the color depth from the number of supported colors.
      Parameters:
      colors - the number of colors reported by the terminal
      Returns:
      the corresponding ColorDepth