Skip to content
ConsoleMonster

API Reference

Struct

Style

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

Foreground, background and decorations for a run of text or a cell. Immutable.

Inheritance

  • ValueType
  • Style

Usage

Explore 44 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 27

Constructors

public Style(Color foreground, Color background = default, TextDecoration decoration = None, String? link = null) #

Creates a style.

Parameters

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

Methods

public Style Combine(Style overlay) #
Returns: Style

Layers overlay on top of this style: non-default overlay colours win and decorations are combined.

Parameters

overlay ConsoleMonster.Styling.Style requiredposition: 0
The style on top.

Returns

The combined style.

public Style Downsample(ColorDepth depth) #
Returns: Style

Downsamples both colours to the given depth; decorations are dropped for ColorDepth.None.

Parameters

depth ConsoleMonster.Capabilities.ColorDepth requiredposition: 0
The colour depth.

Returns

The downsampled style.

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

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

Parameters

other ConsoleMonster.Styling.Style 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(Style left, Style right) #
Returns: Boolean

Equality operator.

Parameters

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

Returns

Whether equal.

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

Inequality operator.

Parameters

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

Returns

Whether different.

public override String ToString() #
Returns: String

Returns the fully qualified type name of this instance.

Returns

The fully qualified type name.

public Style With(TextDecoration decoration) #
Returns: Style

Returns a copy with extra decorations added.

Parameters

decoration ConsoleMonster.Styling.TextDecoration requiredposition: 0
Decorations to add.

Returns

A new style.

public Style WithBackground(Color color) #
Returns: Style

Returns a copy with a different background.

Parameters

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

Returns

A new style.

public Style WithForeground(Color color) #
Returns: Style

Returns a copy with a different foreground.

Parameters

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

Returns

A new style.

public Style Without(TextDecoration decoration) #
Returns: Style

Returns a copy with decorations removed.

Parameters

decoration ConsoleMonster.Styling.TextDecoration requiredposition: 0
Decorations to remove.

Returns

A new style.

Properties

public static Style Plain { get; } #

The unstyled default (terminal colours, no decoration).

public Color Foreground { get; } #

Foreground colour.

public Color Background { get; } #

Background colour.

public TextDecoration Decoration { get; } #

Decorations.

public Boolean IsPlain { get; } #

Whether this is the plain style.