1 ! Copyright (C) 2011-2012 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
4 USING: kernel fry make math sequences ui.text unicode.categories
11 : word-index ( string -- n/f )
12 dup [ blank? ] find drop [
13 1 + swap [ blank? not ] find-from drop
18 : word-split1 ( string -- before after/f )
19 dup word-index [ cut ] [ f ] if* ;
23 : word-split, ( string -- )
24 [ word-split1 [ , ] [ dup empty? not ] bi* ] loop drop ;
28 : word-split ( string -- seq )
29 [ word-split, ] { } make ;
33 : string>elements ( string font -- elements )
36 [ _ swap text-width ] bi@
42 : visual-wrap ( line font line-width -- lines )
43 [ string>elements ] dip dup wrap [ concat ] map ;