Skip to content
ConsoleMonster
Class

TerminalBackground

ConsoleMonster.Output

Namespace
ConsoleMonster.Output
Assembly
ConsoleMonster
Modifiers
static

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 required
green byte required
blue byte required

Returns

double
public static int GetAttributeIndex(ushort attributes) #

Extracts the background palette index from console attributes.

Parameters

attributes ushort required

Returns

int
public 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 required
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? required
A semicolon-separated foreground and background index.
isLight bool required
Whether the valid background index denotes a light colour.

Returns

bool True when the background index was valid.