API Reference
Theme
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 6 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.
Returned or exposed by 6
- Method Theme.FromName
- Method Theme.Rename
- Method Theme.With
- Property Theme.Dark
- Property Theme.HighContrast
- Property Theme.Light
Constructors
public Theme(String name, IReadOnlyDictionary<ThemeToken, ThemeStyle> styles) #Creates a theme from a complete token table.
Parameters
- name System.String
- The theme name.
- styles System.Collections.Generic.IReadOnlyDictionary<ConsoleMonster.Styling.ThemeToken, ConsoleMonster.Styling.ThemeStyle>
- Styles per token; tokens without an entry render with the terminal default.
Methods
public static Theme FromName(String? name) #ThemeReturns the theme matching a name (dark, light, highcontrast), or Theme.Dark.
Parameters
- name System.String?
- The name.
Returns
The theme.
public ThemeStyle Get(ThemeToken token) #ThemeStyleReturns the definition of a token.
Parameters
- token ConsoleMonster.Styling.ThemeToken
- The token.
Returns
Its theme style.
public Theme Rename(String name) #ThemeReturns a copy of the theme under a new name.
Parameters
- name System.String
- The name.
Returns
A new theme.
public Style Resolve(ThemeToken token, ColorDepth depth) #StyleResolves a token to a concrete style for a colour depth.
Parameters
- token ConsoleMonster.Styling.ThemeToken
- The token.
- depth ConsoleMonster.Capabilities.ColorDepth
- The colour depth being rendered.
Returns
The style.
public static Boolean TryParseToken(String name, out ThemeToken token) #BooleanParses a token name case-insensitively (pass, Muted, series3).
Parameters
- name System.String
- The name.
- token ConsoleMonster.Styling.ThemeToken
- The token.
Returns
Whether the name is a known token.
public Boolean TryResolve(String name, ColorDepth depth, out Style style) #BooleanResolves a token by name (case-insensitive), as used in markup such as [pass].
Parameters
- name System.String
- Token name, for example pass or muted.
- depth ConsoleMonster.Capabilities.ColorDepth
- The colour depth being rendered.
- style ConsoleMonster.Styling.Style
- The resolved style.
Returns
Whether the name is a token of this theme.
public Theme With(ThemeToken token, ThemeStyle style) #ThemeReturns a copy of the theme with one token replaced.
Parameters
- token ConsoleMonster.Styling.ThemeToken
- The token.
- style ConsoleMonster.Styling.ThemeStyle
- The new definition.
Returns
A new theme.
Inherited Methods
public virtual Boolean Equals(Object? obj) #BooleanParameters
- obj Object?