Package org.aesh.terminal.utils
Enum TerminalTheme
- All Implemented Interfaces:
Serializable,Comparable<TerminalTheme>,java.lang.constant.Constable
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
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic TerminalThemefromGrayscale(int gray) Determine theme from a grayscale value.static TerminalThemefromRGB(int red, int green, int blue) Determine theme from RGB background color values.booleanisDark()Check if this is a dark theme.booleanisLight()Check if this is a light theme.static TerminalThemeReturns the enum constant of this type with the specified name.static TerminalTheme[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
DARK
Dark background theme (e.g., black, dark gray, dark blue background). Light foreground colors work best with this theme. -
LIGHT
Light background theme (e.g., white, light gray background). Dark foreground colors work best with this theme. -
UNKNOWN
Theme could not be determined. Applications should fall back to a safe default (typically assuming dark theme).
-
-
Method Details
-
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
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 nameNullPointerException- 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
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
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
-