Go to the first, previous, next, last section, table of contents.


wrapString

Function: wrapString { delim width in-string -> wrapped-string }
file: job.t
package: muf
status: alpha

This function is intended to allow very simple reformatting of a paragraph for viewing on a terminal of specified width in characters.

The delim parameter is an end-of-line delimiter. It will usually be "\n", but may (for instance) be set to "\n " to produce indented text, or perhaps might include padding nuls. The wrapString function treats delim as being of zero length for line-length computation, so you should reduce width accordingly if you are using delim to implement indentation.

The width parameter is a terminal width. Setting it to 80 will use the full width of the terminal. However, many people suggest using line widths of no more than 72 in order to enhance readability.

The in-string parameter is the string to be wrapped, which is presumed to consist of running printable text -- words delimited by whitespace.

The wrapString function converts all existing newlines to blanks, then replaces whitespace sequences by delim where-ever needed in order to ensure that no line is more than width characters long. If any word is more than width characters long, it is chopped into fragments width characters long, with no attempt at hyphenation or finding intelligent points at which to break the word.

Stack:
"Now is the time for all good furries to come ..."
Stack: "Now is the time for all good furries to come ..."
15 "\n        " wrapString
Stack: "Now is the time
        for all good
        furries to come
        ..."


Go to the first, previous, next, last section, table of contents.