lib-edit

Stack Based String Range Editing Routines

Below: "start", "end", "pos", and "dest" are all with reference to the start of the range that is towards the bottom of the stack. A 1 means the first item of the range; the item deepest in the stack. "offset" is the number of stack items between the top of the string range and the bottom parameter.

"
EDITsearch{rng} ... offset string start -- {rng} ... pos Searches a range of strings for the first occurence of a substring. This is case sensitive, and returns the line number of the first occurence.
EDITreplace{rng} ... offset oldstr newstr start end -- {rng'} ... Searches the range of strings for all occurences of a case sensitive substring, and replaces them with new text.
EDITmove{rng} ... offset dest start end -- {rng'} ... Moves text within a string range from one line to another location, deleting the original.
EDITcopy{rng} ... offset dest start end -- {rng'} ... Copies text within a string range from one line to another, inserting it in the new location.
EDITlist{rng} ... offset nums? start end -- {rng} ... Lists the given set of lines within a string range, with an int telling it to prepending each line with a number and a colon. Ie: "8: line eight."
EDITansi_list{rng} ... offset nums? start end -- {rng} ... Same as EDITlist, but displays in color.
EDITleft{rng} ... offset start end -- {rng'} ... Left justify all the given lines within a string range.
EDITcenter{rng} ... offset cols start end -- {rng'} ... Center justify all the given lines within a string range.
EDITright{rng} ... offset cols start end -- {rng'} ... Right justify all the given lines within a string range.
EDITcolor{rng} ... offset cols start end colorstr -- {rng'} ... Changes the initial color of each line to colorstr.
EDITindent{rng} ... offset cols start end -- {rng'} ... Indents all the given lines in a string range by COLS spaces. if COLS is a negative integer, it undents by that many spaces. It will never undent past left justification.
EDITfmt_rng{rng} ... offset cols start end -- {rng'} ... Formats the given subrange in the string range to COLS columns. This is similar to the UNIX fmt command, in that it splits long lines and joins short lines. A line that contains only spaces is considered a paragraph delimiter, and is not joined.
EDITjoin_rng{rng} ... offset start end -- {rng'} ... Joins all the given lines in the string range together, and returns the string range that results.
EDITshuffle{rng} -- {rng'} Take a range of items on the stack and randomize their order.
EDITsort{rng} ascending? CaseSensitive? -- {rng'} Alphabetically sorts strings with integers telling it whether to sort in ascending or decending order, and if it should be case sensitive.
EDITjoin{rng} -- stringJoin a range of strings on the stack into one string.
EDITdisplay{rng} --displays the range of strings on the stack to the user.
EDITansi_display{rng} --Same as EDITdisplay, but displays in color.
EDITsplitstring splitchars rmargin wrapmargin -- {rng} splits a string up into several lines in a range. The criterion for where to split each line are as follows: It splits at the last split character it can find between the rmargin and the wrapmargin. If it cannot find one, then it splits at the rmargin.
EDITformat{rng} splitchars rmargin wrapmargin -- {rng'} Takes a range and formats it similarly to the way that the UNIX fmt command would, splitting long lines, and joining short ones.

feaelin@kemenel.org
lib-edit / Revised 2004 March 31 22:11 (Wednesday)
© 2004 Iain E. Davis

Green Web Hosting! This site hosted by DreamHost. Standards Now! Valid XHTML 1.1! Valid CSS! We rated with ICRA!