Table of Contents

Class AnsiParser

Namespace
SharpConsoleUI.Layout
Assembly
SharpConsoleUI.dll

Parses ANSI escape sequences and converts them to cells. Used to bridge Spectre.Console markup output to the character buffer.

public static class AnsiParser
Inheritance
AnsiParser
Inherited Members

Methods

Parse(string)

Parses an ANSI-formatted string using default colors.

public static IEnumerable<Cell> Parse(string ansiString)

Parameters

ansiString string

Returns

IEnumerable<Cell>

Parse(string, Color, Color)

Parses an ANSI-formatted string and yields cells with color information.

public static IEnumerable<Cell> Parse(string ansiString, Color defaultForeground, Color defaultBackground)

Parameters

ansiString string
defaultForeground Color
defaultBackground Color

Returns

IEnumerable<Cell>

ParseLines(IReadOnlyList<string>, int, int, Color, Color)

Converts a list of lines with ANSI codes to a 2D array of cells.

public static Cell[,] ParseLines(IReadOnlyList<string> lines, int width, int height, Color defaultForeground, Color defaultBackground)

Parameters

lines IReadOnlyList<string>
width int
height int
defaultForeground Color
defaultBackground Color

Returns

Cell[,]

StripAnsi(string)

Strips ANSI escape sequences from a string, returning only visible text.

public static string StripAnsi(string ansiString)

Parameters

ansiString string

Returns

string

TruncateVisible(string, int)

Truncates an ANSI string to the specified visible length, preserving color codes.

public static string TruncateVisible(string ansiString, int maxVisibleLength)

Parameters

ansiString string
maxVisibleLength int

Returns

string

VisibleLength(string)

Returns the visible length of an ANSI string (excluding escape sequences).

public static int VisibleLength(string ansiString)

Parameters

ansiString string

Returns

int