Truncate(String, Int32, String?, Boolean, Int32) Method

Definition

Namespace XenoAtom.Ansi
Assembly XenoAtom.Ansi.dll

Truncates text to the specified visible width, optionally preserving ANSI styling.

[NullableContext((byte)1)]
public static string Truncate(string text, int width, [Nullable((byte)2)] string? ellipsis = "…", bool preserveAnsi = true, int tabWidth = 4)

Parameters

text
String

The input text.

width
Int32

Maximum visible width in terminal cells.

ellipsis
String

Text appended when truncation occurs.

preserveAnsi
Boolean

true to preserve styles/hyperlinks while truncating; false to return plain text.

tabWidth
Int32

Width, in cells, to count for tab characters.

Returns