RichStyle
ConsoleMonster.Styling
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.
Returned or exposed by 6
- Method RichStyle.With
- Method RichStyle.WithBackgroundColor
- Method RichStyle.WithColor
- Method RichStyle.WithLink
- Property RichStyle.Plain
- Property RichSegment.Style
Accepted by parameters 14
- Method RichStyle.Equals
- Method RichStyle.op_Equality
- Method RichStyle.op_Equality
- Method RichStyle.op_Inequality
- Method RichStyle.op_Inequality
- Constructor RichSegment.RichSegment
- Method RichText.Append
- Method RichText.FromMarkup
- Method RichText.FromPieces
- Method RichText.Gradient
- Method RichText.Plain
- Method RichText.WithBaseStyle
- Method RichTextBuilder.Append
- Method RichTextBuilder.AppendLink
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
- The foreground colour.
- backgroundColor ConsoleMonster.Styling.RichColor = default
- The background colour.
- decoration ConsoleMonster.Styling.TextDecoration = None
- Decorations.
- link string? = null
- Theme style applied before literal colors and added decorations.
- role ConsoleMonster.Styling.ThemeToken? = null
- A hyperlink target (OSC 8 where supported), or null.
Methods
public bool Equals(RichStyle other) #Indicates whether the current object is equal to another object of the same type.
Parameters
- other ConsoleMonster.Styling.RichStyle
- 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?
- 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
- Left.
- right ConsoleMonster.Styling.RichStyle
- Right.
Returns
bool True when equal.public static bool op_Inequality(RichStyle left, RichStyle right) #Inequality.
Parameters
- left ConsoleMonster.Styling.RichStyle
- Left.
- right ConsoleMonster.Styling.RichStyle
- 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?
- The names.
- decoration ConsoleMonster.Styling.TextDecoration
- 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
- The decorations.
public RichStyle WithBackgroundColor(RichColor color) #Returns a copy with another background.
Parameters
- color ConsoleMonster.Styling.RichColor
- The colour.
public RichStyle WithColor(RichColor color) #Returns a copy with another foreground.
Parameters
- color ConsoleMonster.Styling.RichColor
- The colour.
public RichStyle WithLink(string? link) #Returns a copy with a hyperlink (null removes it).
Parameters
- link string?
- The target.
Inherited Methods
Properties
public ThemeToken? Role { get; } #Theme style applied first; literal colors override its colors and decorations are added.