pub fn word_wrap(text: &str, width: usize, widths: &CellWidths) -> Vec<String>Expand description
Splits text into lines of at most width cells (a character
widths has wide takes two, text_width).
Latin text breaks at spaces; a word is never split unless it alone is
wider than width, and then it is cut into width-wide pieces. Runs
of spaces count as one break. Text without spaces (Japanese) breaks
between any two characters with a wide or Japanese one among them,
except before closing punctuation or a small kana (。, 、, 」,
っ, ,, 》) and after an opening bracket (「, 《); where widths
has them wide, also before ” ’ … — (so …… and —— stay whole)
and after “ ‘. A run of Latin letters or
digits inside it is kept whole, as is anything joined by a
NO_BREAK_SPACE. Where those rules leave no break that fits, the
text is cut anyway: a line never runs past width, unless width is
1 and the line is one wide character.
Empty (or all-space) text gives no lines. A width of 0 is treated as
1.