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)
The input text.
Maximum visible width in terminal cells.
Text appended when truncation occurs.
true to preserve styles/hyperlinks while truncating; false to return plain text.
Width, in cells, to count for tab characters.