Skip to content
ConsoleMonster
Class

Theme

ConsoleMonster.Styling

Namespace
ConsoleMonster.Styling
Assembly
ConsoleMonster
Implements
ITheme
Modifiers
sealed

The built-in ITheme implementation: a table of ThemeStyle per token. Themes are immutable; Theme.With returns a modified copy.

Inheritance

  • object
  • Theme

Usage

Explore 12 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Constructors

Theme 2 overloads
public Theme(string name, IReadOnlyDictionary<ThemeToken, ThemeStyle> styles) #

Creates a theme from a complete token table.

Parameters

name string required
The theme name.
styles System.Collections.Generic.IReadOnlyDictionary<ConsoleMonster.Styling.ThemeToken, ConsoleMonster.Styling.ThemeStyle> required
Styles per token; tokens without an entry render with the terminal default.
public Theme(string name, IReadOnlyDictionary<ThemeToken, ThemeStyle> styles, ThemeAppearance? appearance) #

Creates a theme from a complete token table and a style.

Parameters

name string required
The theme name.
styles System.Collections.Generic.IReadOnlyDictionary<ConsoleMonster.Styling.ThemeToken, ConsoleMonster.Styling.ThemeStyle> required
Styles per token; tokens without an entry render with the terminal default.
appearance ConsoleMonster.Styling.ThemeAppearance? required
Frames, status markers and background; null uses ThemeAppearance.Default.

Methods

public static Theme FromName(string? name) #

Returns a built-in theme, catalogue scheme or paired family by name, or Theme.Dark for an unknown name.

Parameters

name string? required
The name.

Returns

Theme The theme.
public static Theme FromScheme(TerminalScheme scheme, bool accessible = false) #

Derives semantic roles from one scheme. Faithful colours are chosen without adjustment; accessibility uses ThemeCheck's measurements.

Parameters

scheme ConsoleMonster.Styling.TerminalScheme required
accessible bool = false optional

Returns

Theme
public ThemeStyle Get(ThemeToken token) #

Returns the definition of a token.

Parameters

token ConsoleMonster.Styling.ThemeToken required
The token.

Returns

ThemeStyle Its theme style.
public Theme Rename(string name) #

Returns a copy of the theme under a new name.

Parameters

name string required
The name.

Returns

Theme A new theme.
public Style Resolve(ThemeToken token, ColorDepth depth) #

Resolves a token to a concrete style for a colour depth.

Parameters

token ConsoleMonster.Styling.ThemeToken required
The token.
depth ConsoleMonster.Capabilities.ColorDepth required
The colour depth being rendered.

Returns

Style The style.
public static bool TryParseToken(string name, out ThemeToken token) #

Parses a token name case-insensitively (pass, Muted, series3).

Parameters

name string required
The name.
token ConsoleMonster.Styling.ThemeToken required
The token.

Returns

bool Whether the name is a known token.
public bool TryResolve(string name, ColorDepth depth, out Style style) #

Resolves a token by name (case-insensitive), as used in markup such as [pass].

Parameters

name string required
Token name, for example pass or muted.
depth ConsoleMonster.Capabilities.ColorDepth required
The colour depth being rendered.
style ConsoleMonster.Styling.Style required
The resolved style.

Returns

bool Whether the name is a token of this theme.
public Theme With(ThemeToken token, ThemeStyle style) #

Returns a copy of the theme with one token replaced.

Parameters

token ConsoleMonster.Styling.ThemeToken required
The token.
style ConsoleMonster.Styling.ThemeStyle required
The new definition.

Returns

Theme A new theme.
public Theme WithAppearance(ThemeAppearance appearance) #

Returns a copy of the theme with another style.

Parameters

appearance ConsoleMonster.Styling.ThemeAppearance required
The style.

Returns

Theme A new theme.

Properties

public static Theme Dark { get; } #

The default theme, tuned for dark terminal backgrounds (Windows Terminal, conhost, VS Code dark).

public static Theme Light { get; } #

A theme for light terminal backgrounds.

public static Theme HighContrast { get; } #

A high-contrast theme: saturated primaries, bold status, white borders.

public static Theme ColorBlindSafe { get; } #

A dark-background preset for red-green colour blindness: blue pass, rose fail, yellow warning, explicit low-colour fallbacks and bold/underlined emphasis. Widgets retain their status labels and glyphs in every colour tier.

public static Theme ColorBlindSafeLight { get; } #

The light-background counterpart of Theme.ColorBlindSafe: blue pass, magenta fail, dark gold warning.

public static IReadOnlyList<ThemeScheme> Schemes { get; } #

The shipped colour schemes, with explicit names, family, background variant and display labels.

public string Name { get; } #

The theme name.

public ThemeAppearance Appearance { get; } #

The style beside the colours: frames, status markers and the background the theme is made for.

public TerminalScheme? Scheme { get; private set; } #

The source scheme, when this theme was derived from a terminal scheme.

public bool IsAccessible { get; private set; } #

Whether the source scheme uses the accessible derivation.

public IReadOnlyList<ThemeToken> AdjustedTokens { get; private set; } #

Tokens whose colours were moved in OKLCH to meet contrast or colour-vision requirements.

public bool FollowsTerminal { get; private set; } #

Whether this theme follows live terminal palette indexes.

public static Theme Terminal { get; } #

Follows the terminal's sixteen palette colours at every colour depth, including true colour.