Bug fix in word wrap
parent
36bed1faab
commit
7cd7af7bd1
|
@ -12,15 +12,17 @@ SYMBOL: width
|
||||||
|
|
||||||
: (split-chunk) ( words -- )
|
: (split-chunk) ( words -- )
|
||||||
-1 over [ length + 1+ dup width get > ] find drop nip
|
-1 over [ length + 1+ dup width get > ] find drop nip
|
||||||
[ cut-slice swap , (split-chunk) ] [ , ] if* ;
|
[ 1 max cut-slice swap , (split-chunk) ] [ , ] if* ;
|
||||||
|
|
||||||
: split-chunk ( words -- lines )
|
: split-chunk ( words -- lines )
|
||||||
[ (split-chunk) ] { } make ;
|
[ (split-chunk) ] { } make ;
|
||||||
|
|
||||||
|
: join-spaces ( words-seqs -- lines )
|
||||||
|
[ [ " " join ] map ] map concat ;
|
||||||
|
|
||||||
: broken-lines ( string width -- lines )
|
: broken-lines ( string width -- lines )
|
||||||
width [
|
width [
|
||||||
line-chunks
|
line-chunks [ split-chunk ] map join-spaces
|
||||||
[ split-chunk [ " " join ] map ] map concat
|
|
||||||
] with-variable ;
|
] with-variable ;
|
||||||
|
|
||||||
: line-break ( string width -- newstring )
|
: line-break ( string width -- newstring )
|
||||||
|
|
Loading…
Reference in New Issue