1 ! Copyright (C) 2009 Daniel Ehrenberg
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: wrap kernel sequences fry splitting math ;
8 : split-lines ( string -- elements-lines )
11 [ dup length 1 <element> ] map
14 : join-elements ( wrapped-lines -- lines )
17 : join-lines ( strings -- string )
22 : wrap-lines ( lines width -- newlines )
23 [ split-lines ] dip '[ _ dup wrap join-elements ] map concat ;
25 : wrap-string ( string width -- newstring )
26 wrap-lines join-lines ;
28 : wrap-indented-string ( string width indent -- newstring )
29 [ length - wrap-lines ] keep '[ _ prepend ] map join-lines ;