wrap-indented-string ( string width indent -- newstring ) - Factor Documentation

wrap-indented-string ( string width indent -- newstring )
String word wrapping



Vocabulary
wrap .strings

Inputs
string a string
width an integer
indent string or integer


Outputs
newstring a string


Word description
Given a string, alters the whitespace in the string so that each line has no more than width characters, unless there is a word longer than width. Linear whitespace between words is converted to a single space. The indent can be either a string or a number of spaces to prepend to each line.

Definition
USING: kernel math sequences splitting wrap.strings.private ;

IN: wrap.strings

: wrap-indented-string ( string width indent -- newstring )
make-indent [ length - wrap-lines ] keep over empty?
[ nip ] [ [ prepend ] curry map! join-lines ] if ;

AltStyle によって変換されたページ (->オリジナル) /