Line Editor Reference

StrongForth comes with a very simple line editor, whose source code is stored in blocks 167 to 174 of the default block file FORTH.BLK. It actually is a port of the old FIG line editor. To make the line editor commands available, the source code has to be compiled into the dictionary by entering

167 174 THRU

at the StrongForth command prompt. Note that the line editor interprets each block as a screen with 16 lines of 64 characters each. Since a screen does normally not contain control characters like carriage return, line feed and tab, lines have to be filled up with trailing spaces in order to contain exactly 64 characters.

The line editor frequently uses PAD to store character strings or complete lines. PAD can thus be used to copy one line to another line within the same screen or between two different screen. The length of the string in PAD is stored in the variable COUNT. Another variable, R#, contains the position of the editing cursor as an offset to the start of the current screen.

The following is a short description of all line editor commands. A few of these commands are already contained in the StrongForth Block and Block extension word sets.

Screen commands

n LIST List screen n and select it for editing.
n CLEAR Clear screen n with blanks and select it for editing.
n1 n2 COPY Copy the contents of screen n1 to screen n2.
FLUSH Write all modified screens to the block file.
n1 n2 INDEX Display the first line of each screen from n1 to n2.
L List the current screen. Then display the current line, marking the cursor position with an underscore character.

Line Editing Commands

n D Delete line n by moving all following lines one line up. Hold the original contents of line n in PAD.
n E Erase line n with spaces.
n H Hold line n in PAD.
n I Insert the contents of PAD in line n and move the original line n and all following lines one line down. Line 15 is lost.
n P text    Put text into line n, overwriting the original contents.
n R Replace line n with the contents of PAD.
n S Spread line n by moving it and all following lines one line down. Line n is erased with spaces. Line 15 is lost.

Cursor movement commands

B Used after F to move the cursor back to the start of the found text. Then display the current line, marking the cursor position with an underscore character.
n M Move the editing cursor by the signed amount integer. Then display the current line, marking the cursor position with an underscore character.
n T Type line n and copy it's contents in PAD. Move the editing cursor to the start of line n.
TOP         Move the cursor to the start of line 0 of the screen.

String editing commands

C text Copy text to the current line at the cursor position and move the rest of the line to the right. Then display the current line, marking the cursor position with an underscore character.
F text Find text starting at the cursor position. If text is found, move the editing cursor to the end of the found text. Then display the current line, marking the cursor position with an underscore character. Otherwise move the cursor to the start of line 0 of the screen.
N Used after F to find the next occurance of the found text.
TILL text   Find text starting at the cursor position until the end of the current line. If text is found, delete all characters from the cursor position up to and including text by moving the remaining characters to the left and filling the line up with spaces. Then display the current line, marking the cursor position with an underscore character.
X text Find text starting at the cursor position. If text is found, delete it by moving the remaining characters to the left and filling the line up with spaces. Move the cursor to the position where text was found. Then display the current line, marking the cursor position with an underscore character. Otherwise move the cursor to the start of line 0 of the screen.

Dr. Stephan Becher - August 23rd, 2007