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
ansiStringstring
Returns
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
ansiStringstringdefaultForegroundColordefaultBackgroundColor
Returns
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
linesIReadOnlyList<string>widthintheightintdefaultForegroundColordefaultBackgroundColor
Returns
- Cell[,]
StripAnsi(string)
Strips ANSI escape sequences from a string, returning only visible text.
public static string StripAnsi(string ansiString)
Parameters
ansiStringstring
Returns
TruncateVisible(string, int)
Truncates an ANSI string to the specified visible length, preserving color codes.
public static string TruncateVisible(string ansiString, int maxVisibleLength)
Parameters
Returns
VisibleLength(string)
Returns the visible length of an ANSI string (excluding escape sequences).
public static int VisibleLength(string ansiString)
Parameters
ansiStringstring