text string to be wrapped
maximum number of columns in the paragraph
string used to indent first line of the paragraph
string to use to indent following lines of the paragraph
column spacing of tabs in firstindent[] and indent[]
resulting paragraph as an allocated string
assert(wrap("a short string", 7) == "a short\nstring\n"); // wrap will not break inside of a word, but at the next space assert(wrap("a short string", 4) == "a\nshort\nstring\n"); assert(wrap("a short string", 7, "\t") == "\ta\nshort\nstring\n"); assert(wrap("a short string", 7, "\t", " ") == "\ta\n short\n string\n");
Wrap text into a paragraph.
The input text string s is formed into a paragraph by breaking it up into a sequence of lines, delineated by \n, such that the number of columns is not exceeded on each line. The last line is terminated with a \n.