ConsoleForge 0.3.0
Elm-architecture TUI framework for .NET 8
Loading...
Searching...
No Matches
ConsoleForge.Styling.Style Struct Reference

Immutable value type carrying visual style properties. More...

Public Member Functions

Style Align (HorizontalAlign align)
 Returns a new style with horizontal text alignment set to align .
Style Background (IColor color)
 Returns a new style with the background color set to color .
Style Blink (bool value=true)
 Returns a new style with blinking enabled or disabled.
Style Bold (bool value=true)
 Returns a new style with bold enabled or disabled.
Style Border (BorderSpec border)
 Returns a new style with all four border sides enabled using border characters.
Style BorderBackground (IColor color)
 Returns a new style with the border background color set to color .
Style BorderBottom (bool enabled=true)
 Returns a new style with the bottom border side enabled or disabled.
Style BorderForeground (IColor color)
 Returns a new style with the border foreground color set to color .
Style BorderLeft (bool enabled=true)
 Returns a new style with the left border side enabled or disabled.
Style BorderRight (bool enabled=true)
 Returns a new style with the right border side enabled or disabled.
Style BorderTop (bool enabled=true)
 Returns a new style with the top border side enabled or disabled.
override bool Equals (object? obj)
bool Equals (Style other)
 Returns true if this style is value-equal to other .
Style Faint (bool value=true)
 Returns a new style with faint (dim) intensity enabled or disabled.
Style Foreground (IColor color)
 Returns a new style with the foreground color set to color .
override int GetHashCode ()
Style Height (int rows)
 Returns a new style with a fixed height in terminal rows.
Style Inherit (Style parent)
 Copy properties from parent that are set in parent but not yet set in this.
Style Italic (bool value=true)
 Returns a new style with italic enabled or disabled.
Style Margin (int all)
 Returns a new style with equal margin on all four sides.
Style Margin (int top, int right, int bottom, int left)
 Returns a new style with independent margin on each side.
Style Margin (int vertical, int horizontal)
 Returns a new style with symmetric vertical and horizontal margin.
Style Padding (int all)
 Returns a new style with equal padding on all four sides.
Style Padding (int top, int right, int bottom, int left)
 Returns a new style with independent padding on each side.
Style Padding (int vertical, int horizontal)
 Returns a new style with symmetric vertical and horizontal padding.
string Render (string text, ColorProfile colorProfile=ColorProfile.TrueColor)
 Apply all set style properties to text and return the styled ANSI string.
string RenderChar (char ch, ColorProfile colorProfile=ColorProfile.TrueColor)
 Render a single char to a styled cell string.
Style Reverse (bool value=true)
 Returns a new style with foreground/background colors swapped (reverse video) enabled or disabled.
Style Strikethrough (bool value=true)
 Returns a new style with strikethrough enabled or disabled.
Style Underline (bool value=true)
 Returns a new style with underline enabled or disabled.
Style UnsetBackground ()
 Returns a new style with the background color property cleared.
Style UnsetBold ()
 Returns a new style with the bold property cleared.
Style UnsetBorder ()
 Returns a new style with all border properties (sides, colors, spec) cleared.
Style UnsetForeground ()
 Returns a new style with the foreground color property cleared.
Style UnsetItalic ()
 Returns a new style with the italic property cleared.
Style UnsetUnderline ()
 Returns a new style with the underline property cleared.
Style Width (int columns)
 Returns a new style with a fixed width in terminal columns.

Static Public Member Functions

static bool operator!= (Style left, Style right)
 Returns true if left and right differ.
static bool operator== (Style left, Style right)
 Returns true if left and right are value-equal.

Static Public Attributes

static readonly Style Default = default
 The empty style (no properties set). Fast path: Render returns text unchanged.

Properties

IColorBg [get]
 Background colour set on this style, or null if not set.
IColorBorderColor [get]
 Border foreground colour set on this style, or null if not set.
IColorFg [get]
 Foreground colour set on this style, or null if not set.

Detailed Description

Immutable value type carrying visual style properties.

Uses a bitmask to distinguish "unset" from "set to default". All mutating methods return a new Style value (fluent builder pattern).

Member Function Documentation

◆ Inherit()

Style ConsoleForge.Styling.Style.Inherit ( Style parent)

Copy properties from parent that are set in parent but not yet set in this.

Margins and padding are NOT inherited (they are local properties).

◆ Render()

string ConsoleForge.Styling.Style.Render ( string text,
ColorProfile colorProfile = ColorProfile::TrueColor )

Apply all set style properties to text and return the styled ANSI string.

If no properties are set (_props == 0), returns text unchanged (fast path). ANSI open/close sequences are cached per (props, fg, bg, profile) — computed once.

◆ RenderChar()

string ConsoleForge.Styling.Style.RenderChar ( char ch,
ColorProfile colorProfile = ColorProfile::TrueColor )

Render a single char to a styled cell string.

Hot path: result cached per (style, profile, char) — zero alloc on hit. Bypasses padding/width/height transforms (single-char cell has none).


The documentation for this struct was generated from the following file:
  • src/ConsoleForge/Styling/Style.cs