new example: wordwrap.retro
FossilOrigin-Name: c40696930a3373d90ef709357fee4cd5a6cce02770702132a4ecea92ebeba0ad
This commit is contained in:
parent
9b8400fd02
commit
330d8e2340
1 changed files with 16 additions and 0 deletions
16
example/wordwrap.retro
Normal file
16
example/wordwrap.retro
Normal file
|
@ -0,0 +1,16 @@
|
|||
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 ;
|
||||
}}
|
||||
~~~
|
Loading…
Reference in a new issue