pub fn truncate_to_width(s: &str, max_cols: usize) -> StringExpand description
Truncate s to at most max_cols visible columns,
appending an ellipsis when truncation actually elides
content. Skips ANSI SGR escape sequences (\x1b[...m) when
counting visible width — they consume characters in the
string but no terminal columns. The truncation point is
always at a character boundary that’s NOT inside an escape
sequence, so we never emit a half-broken \x1b[3 to the
terminal.