pub fn fold_ansi(line: &str, width: usize, indent: usize) -> Vec<String>Expand description
Cuts a possibly styled line into rows of at most width visible columns.
Styles that are open at a cut are closed at the end of the row and re-opened at the start of
the next one, so every row is self-contained. Continuation rows are indented by indent
spaces (clamped so that every row can hold at least one column of content). A line that fits
is returned as a single, unchanged row; an empty line yields one empty row.
use shellgame::ui::text::fold_ansi;
let rows = fold_ansi("\x1b[36mabcdef\x1b[0m", 4, 0);
assert_eq!(rows, ["\x1b[36mabcd\x1b[0m", "\x1b[36mef\x1b[0m"]);