From 330d8e234010488805df8087b8bf688a5f3b7b2d Mon Sep 17 00:00:00 2001 From: crc Date: Tue, 6 Aug 2019 13:40:53 +0000 Subject: [PATCH] new example: wordwrap.retro FossilOrigin-Name: c40696930a3373d90ef709357fee4cd5a6cce02770702132a4ecea92ebeba0ad --- example/wordwrap.retro | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 example/wordwrap.retro diff --git a/example/wordwrap.retro b/example/wordwrap.retro new file mode 100644 index 0000000..40b2745 --- /dev/null +++ b/example/wordwrap.retro @@ -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 + +{{ + 'Displayed var + :wrap? dup @Displayed + @WrapAt gt? ; + :display [ nl !Displayed ] [ &Displayed v:inc-by ] choose s:put sp ; +---reveal--- + :s:put (s-) + #0 !WrapAt + &Heap [ ASCII:SPACE s:tokenize [ dup s:length wrap? display ] a:for-each ] v:preserve ; +}} +~~~