Enum TerminalTheme

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

public enum TerminalTheme extends Enum<TerminalTheme>
Represents the detected terminal background theme (light or dark).

This is useful for selecting appropriate foreground colors that will be readable against the terminal's background color.

Author:
Ståle W. Pedersen
  • Enum Constant Details

    • DARK

      public static final TerminalTheme DARK
      Dark background theme (e.g., black, dark gray, dark blue background). Light foreground colors work best with this theme.
    • LIGHT

      public static final TerminalTheme LIGHT
      Light background theme (e.g., white, light gray background). Dark foreground colors work best with this theme.
    • UNKNOWN

      public static final TerminalTheme UNKNOWN
      Theme could not be determined. Applications should fall back to a safe default (typically assuming dark theme).
  • Method Details

    • values

      public static TerminalTheme[] 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 TerminalTheme 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
    • isDark

      public boolean isDark()
      Check if this is a dark theme.
      Returns:
      true if the theme is dark or unknown (safe default)
    • isLight

      public boolean isLight()
      Check if this is a light theme.
      Returns:
      true if the theme is explicitly light
    • fromRGB

      public static TerminalTheme fromRGB(int red, int green, int blue)
      Determine theme from RGB background color values. Uses the perceived luminance formula to determine if the background is light or dark.
      Parameters:
      red - red component (0-255)
      green - green component (0-255)
      blue - blue component (0-255)
      Returns:
      LIGHT if luminance > 128, DARK otherwise
    • fromGrayscale

      public static TerminalTheme fromGrayscale(int gray)
      Determine theme from a grayscale value.
      Parameters:
      gray - grayscale value (0-255, where 0 is black and 255 is white)
      Returns:
      LIGHT if gray > 128, DARK otherwise