Skip to content
ConsoleMonster
Struct

RichStyle

ConsoleMonster.Styling

Namespace
ConsoleMonster.Styling
Assembly
ConsoleMonster
Base
ValueType
Implements
IEquatable<RichStyle>
Modifiers
sealed

The style of a rich-text span: foreground and background (RichColor: explicit colours, PowerShell ConsoleColors or theme roles), decorations (bold, dim, italic, underline, strikethrough, invert) and an optional hyperlink. Colours are resolved and down-mapped per colour tier when the text is rendered.

Inheritance

  • ValueType
  • RichStyle

Usage

Explore 20 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.

Accepted by parameters 14

Constructors

public RichStyle(RichColor color = default, RichColor backgroundColor = default, TextDecoration decoration = None, string? link = null, ThemeToken? role = null) #

Creates a style.

Parameters

color ConsoleMonster.Styling.RichColor = default optional
The foreground colour.
backgroundColor ConsoleMonster.Styling.RichColor = default optional
The background colour.
decoration ConsoleMonster.Styling.TextDecoration = None optional
Decorations.
link string? = null optional
Theme style applied before literal colors and added decorations.
role ConsoleMonster.Styling.ThemeToken? = null optional
A hyperlink target (OSC 8 where supported), or null.

Methods

Equals 2 overloads
public bool Equals(RichStyle other) #

Indicates whether the current object is equal to another object of the same type.

Parameters

other ConsoleMonster.Styling.RichStyle required
An object to compare with this object.

Returns

bool true if the current object is equal to the other parameter; otherwise, false.
public override bool Equals(object? obj) #

Indicates whether this instance and a specified object are equal.

Parameters

obj object? required
The object to compare with the current instance.

Returns

bool true if obj and this instance are the same type and represent the same value; otherwise, false.
public override int GetHashCode() #

Returns the hash code for this instance.

Returns

int A 32-bit signed integer that is the hash code for this instance.
public static bool op_Equality(RichStyle left, RichStyle right) #

Equality.

Parameters

left ConsoleMonster.Styling.RichStyle required
Left.
right ConsoleMonster.Styling.RichStyle required
Right.

Returns

bool True when equal.
public static bool op_Inequality(RichStyle left, RichStyle right) #

Inequality.

Parameters

left ConsoleMonster.Styling.RichStyle required
Left.
right ConsoleMonster.Styling.RichStyle required
Right.

Returns

bool True when different.
public string ToMarkup() #

The style as a markup tag body (bold lime on navy link=https://...), or empty when plain.

Returns

string The specification.
public override string ToString() #

Returns the fully qualified type name of this instance.

Returns

string The fully qualified type name.
public static bool TryParseDecoration(string? text, out TextDecoration decoration) #

Parses decorations from names separated by commas or spaces: Bold, Dim, Italic, Underline, Strikethrough (Strike), Invert (Reverse), and None.

Parameters

text string? required
The names.
decoration ConsoleMonster.Styling.TextDecoration required
The decorations.

Returns

bool True when every name is known.
public RichStyle With(TextDecoration decoration) #

Returns a copy with added decorations.

Parameters

decoration ConsoleMonster.Styling.TextDecoration required
The decorations.

Returns

RichStyle The copy.
public RichStyle WithBackgroundColor(RichColor color) #

Returns a copy with another background.

Parameters

color ConsoleMonster.Styling.RichColor required
The colour.

Returns

RichStyle The copy.
public RichStyle WithColor(RichColor color) #

Returns a copy with another foreground.

Parameters

color ConsoleMonster.Styling.RichColor required
The colour.

Returns

RichStyle The copy.

Properties

public static RichStyle Plain { get; } #

No styling.

public ThemeToken? Role { get; } #

Theme style applied first; literal colors override its colors and decorations are added.

public RichColor Color { get; } #

The foreground colour.

public RichColor BackgroundColor { get; } #

The background colour.

public TextDecoration Decoration { get; } #

Decorations.

public bool IsPlain { get; } #

Whether the style changes nothing.