Skip to content
ConsoleMonster
Struct

Style

ConsoleMonster.Styling

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 43 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 25

Constructors

public Style(Color color, Color backgroundColor = default, TextDecoration decoration = None, string? link = null) #

Creates a style.

Parameters

color ConsoleMonster.Styling.Color required
Foreground colour.
backgroundColor ConsoleMonster.Styling.Color = default optional
Background colour.
decoration ConsoleMonster.Styling.TextDecoration = None optional
Decorations.
link string? = null optional
A hyperlink target (OSC 8), or null.

Methods

public Style Combine(Style overlay) #

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

Parameters

overlay ConsoleMonster.Styling.Style required
The style on top.

Returns

Style The combined style.
public Style Downsample(ColorDepth depth) #

Downsamples both colours to the given depth; colours and decorations are dropped for ColorDepth.None, while a hyperlink target is kept, so plain output can still show it.

Parameters

depth ConsoleMonster.Capabilities.ColorDepth required
The colour depth.

Returns

Style The downsampled style.
Equals 2 overloads
public bool Equals(Style other) #

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

Parameters

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

Equality operator.

Parameters

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

Returns

bool Whether equal.
public static bool op_Inequality(Style left, Style right) #

Inequality operator.

Parameters

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

Returns

bool Whether different.
public override string ToString() #

Returns the fully qualified type name of this instance.

Returns

string The fully qualified type name.
public Style With(TextDecoration decoration) #

Returns a copy with extra decorations added.

Parameters

decoration ConsoleMonster.Styling.TextDecoration required
Decorations to add.

Returns

Style A new style.
public Style WithBackgroundColor(Color color) #

Returns a copy with a different background.

Parameters

color ConsoleMonster.Styling.Color required
The colour.

Returns

Style A new style.
public Style WithColor(Color color) #

Returns a copy with a different foreground.

Parameters

color ConsoleMonster.Styling.Color required
The colour.

Returns

Style A new style.
public Style Without(TextDecoration decoration) #

Returns a copy with decorations removed.

Parameters

decoration ConsoleMonster.Styling.TextDecoration required
Decorations to remove.

Returns

Style A new style.

Properties

public static Style Plain { get; } #

The unstyled default (terminal colours, no decoration).

public Color Color { get; } #

Foreground colour.

public Color BackgroundColor { get; } #

Background colour.

public TextDecoration Decoration { get; } #

Decorations.

public bool IsPlain { get; } #

Whether this is the plain style.