mirror of
https://git.sr.ht/~crc_/retroforth
synced 2024-11-16 19:48:56 +01:00
02bd140c4b
FossilOrigin-Name: 6e7d888e88b952d156f9eb4c905e756a085648cdc94f15f7b2bb31643c570164
16 lines
402 B
Text
16 lines
402 B
Text
This implements a variation of `s:put` which wraps text based
|
|
on a maximum width set by the user.
|
|
|
|
~~~
|
|
#80 'WrapAt var-n
|
|
|
|
{{
|
|
'Displayed var
|
|
:wrap? dup @Displayed + @WrapAt gt? ;
|
|
:display [ nl !Displayed ] [ &Displayed v:inc-by ] choose s:put sp ;
|
|
---reveal---
|
|
:s:put-wrapped (s-)
|
|
#0 !WrapAt
|
|
&Heap [ ASCII:SPACE s:tokenize [ dup s:length wrap? display ] a:for-each ] v:preserve ;
|
|
}}
|
|
~~~
|