Skip to content
ConsoleMonster

API Reference

Struct

RichStyle

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 foreground = default, RichColor background = default, TextDecoration decoration = None, String? link = null) #

Creates a style.

Parameters

foreground ConsoleMonster.Styling.RichColor = default optionalposition: 0
The foreground colour.
background ConsoleMonster.Styling.RichColor = default optionalposition: 1
The background colour.
decoration ConsoleMonster.Styling.TextDecoration = None optionalposition: 2
Decorations.
link System.String? = null optionalposition: 3
A hyperlink target (OSC 8 where supported), or null.

Methods

Equals 2 overloads
public Boolean Equals(RichStyle other) #
Returns: Boolean

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

Parameters

other ConsoleMonster.Styling.RichStyle requiredposition: 0
An object to compare with this object.

Returns

true if the current object is equal to the other parameter; otherwise, false.

public override Boolean Equals(Object? obj) #
Returns: Boolean

Indicates whether this instance and a specified object are equal.

Parameters

obj System.Object? requiredposition: 0
The object to compare with the current instance.

Returns

true if obj and this instance are the same type and represent the same value; otherwise, false.

public override Int32 GetHashCode() #
Returns: Int32

Returns the hash code for this instance.

Returns

A 32-bit signed integer that is the hash code for this instance.

public static Boolean op_Equality(RichStyle left, RichStyle right) #
Returns: Boolean

Equality.

Parameters

left ConsoleMonster.Styling.RichStyle requiredposition: 0
Left.
right ConsoleMonster.Styling.RichStyle requiredposition: 1
Right.

Returns

True when equal.

public static Boolean op_Inequality(RichStyle left, RichStyle right) #
Returns: Boolean

Inequality.

Parameters

left ConsoleMonster.Styling.RichStyle requiredposition: 0
Left.
right ConsoleMonster.Styling.RichStyle requiredposition: 1
Right.

Returns

True when different.

public String ToMarkup() #
Returns: String

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

Returns

The specification.

public override String ToString() #
Returns: String

Returns the fully qualified type name of this instance.

Returns

The fully qualified type name.

public static Boolean TryParseDecoration(String? text, out TextDecoration decoration) #
Returns: Boolean

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

Parameters

text System.String? requiredposition: 0
The names.
decoration ConsoleMonster.Styling.TextDecoration requiredposition: 1
The decorations.

Returns

True when every name is known.

public RichStyle With(TextDecoration decoration) #
Returns: RichStyle

Returns a copy with added decorations.

Parameters

decoration ConsoleMonster.Styling.TextDecoration requiredposition: 0
The decorations.

Returns

The copy.

public RichStyle WithBackground(RichColor color) #
Returns: RichStyle

Returns a copy with another background.

Parameters

color ConsoleMonster.Styling.RichColor requiredposition: 0
The colour.

Returns

The copy.

public RichStyle WithForeground(RichColor color) #
Returns: RichStyle

Returns a copy with another foreground.

Parameters

color ConsoleMonster.Styling.RichColor requiredposition: 0
The colour.

Returns

The copy.

Properties

public static RichStyle Plain { get; } #

No styling.

public RichColor Foreground { get; } #

The foreground colour.

public RichColor Background { get; } #

The background colour.

public TextDecoration Decoration { get; } #

Decorations.

public Boolean IsPlain { get; } #

Whether the style changes nothing.