View/Edit #8495:wordwrap

Switch to edit mode.

Name(s): wordwrap
1:  "wordwrap(STR text, INT width) => LST lines"
2:  "--"
3:  "default text \"\""
4:  "default width 0"
5:  ""
6:  text = `args[1] ! ANY => ""'
7:  width = `args[2] ! ANY => 79'
8:  lines = {}
9:  text = $string_utils:trimr(text)
10: ll = "[normal]"
11: while (length(text) > width - 1)
12:   col = ll[(e = rmatch(ll, #2170.all_regexp))[1]..e[2]]
13:   ll = this:tansi(text, width)
14:   text = text[length(ll) + 1..length(text)]
15:   sp = ((x = rindex(ll, " ")) ? x | length(ll)) - 1
16:   text = ll[sp + 1..length(ll)] + text
17:   ll = col + ll[1..sp]
18:   lines = {@lines, ll}
19:   text = $string_utils:triml(text)
20: endwhile
21: return {@lines, text}
22: "Last modified by Vladmir (#3936) on Wed Dec 10 19:30:30 2008 EST."

Verb arguments: this none this
Verb perms: Readable eXecutable NOT-Debug
Verb owned by: Ezran (#3936)

You are not logged in.

[home | help | who | search | setup | code]