Class
TerminalBackground
ConsoleMonster.Output
Detects terminal background appearance using console, startup VT query and environment information.
Inheritance
- object
- TerminalBackground
Methods
public static double CalculateLuminance(byte red, byte green, byte blue) #Calculates WCAG relative luminance from 8-bit sRGB channels.
Parameters
- red byte
- green byte
- blue byte
Returns
doublepublic static int GetAttributeIndex(ushort attributes) #Extracts the background palette index from console attributes.
Parameters
- attributes ushort
Returns
intpublic static bool TryDetect(out TerminalBackgroundInfo info) #Detects the background from console attributes, a cached input-startup query or the environment without reading input.
Parameters
- info ConsoleMonster.Output.TerminalBackgroundInfo
- The detected background or an unknown result.
Returns
bool True when a background classification was available.public static bool TryParseColorFgbg(string? value, out bool isLight) #Parses a COLORFGBG foreground/background value.
Parameters
- value string?
- A semicolon-separated foreground and background index.
- isLight bool
- Whether the valid background index denotes a light colour.
Returns
bool True when the background index was valid.