home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
forth
/
compiler
/
fpc
/
doc
/
chapter5.txt
< prev
next >
Wrap
Text File
|
1989-10-29
|
32KB
|
691 lines
CHAPTER 5. SED, THE EDITOR
SED is a sequential file text editor implemented in F-PC by Tom Zimmer.
It is an extremely powerful text editor optimized for user convenience
and to support the F-PC programming environment. The editor is somewhat
WordStar compatible using the WordStar "Star" for cursor movement. The
keypad is also fully supported. Search, replace, and global replace are
provided, along with copy and paste of lines within a file as well as
between files. There are many other interesting features like hypertext
help system, character graphics, line alignment, paragraph sorting, and
keystroke macros.
SED was developed to provide an easy way to create and modify source and
documentation files for building applications in F-PC. You can return
the editor from F-PC and return to F-PC with very few key strokes so that
programs can be modified and tested quickly. It has the convenience of
the block based F83 source loading mechanism, but is not limited by the
small block size. SED uses the standard sequential text file format
common to most DOS editors and word processors. It can read files
generated by other word processors. It generates text files which can be
used by most word processors.
SED allocates as much memory as needed to store text file in RAM. The
file is edited in RAM and saved back to disk when returning to F-PC. The
maximum file size is limited only by available memory, 120K in a 640K
bytes machine or 64K in an 512K byte machine. It can also be used for
simple note or letter writing. It provides word wrap, paragraph
reformat, with margin control and simple printer control for boldface and
underline. Its formatted printer output is suitable for professional
program listing as it contains well laidout headers and footers.
SED provides pull-down menus for ease of operation, with on-line help for
most functions. Press ESC to pop up the menu bar, then type the first
letter of the menu name to see the menu. Press the first capitalized
letter of a menu item to pick that item, or use the arrow keys to step
over and down to the desired function and press <return>. Press ESC
again to clear the menu bar if you don't want to perform a command. Many
menu selections also have shortcut keystrokes which can be invoked
quickly without going through the menus.
The on-line hypertext help is brought to the screen by pressing F1, after
which you can use the arrow keys, PgUp, PgDn, and the TAB keys to select
a highlighted title of a topic, and link to that topic using F9 or
<return>. All the SED utilities are linked as topics and can be accessed
easily.
SED SPECIFICATIONS
640 KB System 512 KB System
Maximum Characters in a File 120K 64K
Maximum Lines in a File 8000 lines 6000 lines
Maximum # of Deleted Lines Saved 100 lines 20 lines
(48K buf) (<48K Buf)
Maximum Characters in a Line 132
Screen display Format 23 lines of 79 characters
Printed # of Lines on a Page 55
5.1. INVOKING SED EDITOR
There are several ways to start editing a file in SED. Perhaps the
easiest to get started with is NEWFILE. It is used as follows:
NEWFILE <filespec> <return>
NEWFILE will look to see if <filespec> is an existing file. If the file
already exists, then it will be opened and SED will begin to edit that
file. If the file does NOT exist, then it will be created and SED will
start editing the new file. When the edit is complete, changes are saved,
the file is closed and re-opened, and remains open when you return to the
Forth command level. If you type NEWFILE without specifying a <filespec>,
then you will be prompted for a file to edit. If you then simply press
<return> without giving a <filespec>, no edit will be performed.
Other ways to start the editor require that a file be open before
starting an edit. Ways to open a file are:
FILE <filespec> <return>
OPEN <filespec> <return> Alias for FILE FL <filespec> <return>
Alias for FILE
If you return one of the above words without giving a <filespec>, you
will see a popup file selection window from which you can pick an
existing file to open. Once a file is open, you can start editing with
one of the following words:
ED <return>
ED <wordname> <return>
<linenumber> EDIT <return>
If you are just starting to edit a file, ED will begin editing at line
one. After editing a file, if you re- return with ED, you will return to
the line where you were when you left the editor. If ED is followed by a
word name, the source file where the word was defined will be opened, and
the word definitions is displayed for editing. This way you don't have
to remember where the word was defined. EDIT will start editing the
current file at the line number specified.
A very fancy file selection mechanism has been added in F-PC. If you
type in a file open word, and you press <return> without returning a
filename, a window display will popup allowing you to select a file from
the directory. You can use the Up/Down cursor keys and PgUp/PgDn keys to
select a file for editing. You can also press a letter key to step
through the files starting with the letter you press.
If you are in a sub-directory and the filespec string is set to *.* when
the window appears, then a file named "." and a file named ".." will
appear at the top of the file list. These files, along with any
directories below the current directory, will display a graphic
"infinity" symbol "░" to the right of the filename. If you press
<return> while positioned on the "." name you will select the root
directory. The ".." name will pop up one level of directory, and any
other name with the "infinity" symbol next to it will step you down one
level to that directory. You can move between files in the window, with
the keypad arrow keys, and select a file by pressing <return>. Escape
can be used to abort file selection.
The path and the current drive is displayed in a window to the lower
right. The path can be changed by pressing the "\" key, then editing the
new path followed by the return key.
When you want to edit a word which was already compiled into the
dictionary, you can simply type:
VIEW <wordname> <return>
BROWSE <wordname> <return>
VIEW, V, and B are all aliases of BROWSE which opens the file which
contains the definition of the word, enters SED, and displays its source
definition.
When you select the AUTOEDITON option in your configuration file, SED
will be invoked when there is an error in loading or compiling a file.
SED will display the text containing the source text where error
occurred. The editing cursor will point to the word following the word
which caused the error. This auto-editing mode is very convenient in
writing and testing programs. It can be turned off by executing
AUTOEDITOFF.
5.2. USING SED
SED shows 23 lines of text in a window surrounded by a frame of single
line. The top line of the display frame shows the current edit status,
starting with INSERT/OVERWRITE status, which is also shown in reverse
video for insert mode. The current line and column number are then
displayed, followed by the page number, total lines in file and total
characters in file. The directory path and the name of the current file
being edited appear at the bottom of the screen. The editing cursor is
placed at the top left corner of the window if the file was just opened.
Otherwise, the cursor will be put at the position you last left the
editor, or where a compilation error occurred.
Text is entered into the file by typing on the keyboard. In the INSERT
mode, existing text is pushed to the right. In the OVERTYPE mode,
existing text is overwritten by the new text. The INS key toggles
between the INSERT and the OVERTYPE modes. DEL key deletes the character
under the cursor. The BackSpace key deletes the character to the left of
the cursor. The arrow keys in the keypad allow you to position the
cursor anywhere in the window to enter new text. Pushing the <enter> or
<return> key starts a new line.
When the cursor is moved next to an edge of the window, text beyond the
window boarder, if there is any, will be scrolled into the window. PgUp
key will scroll the file down to display the previous page of the file,
and PgDn does the opposite. HOME key moves the cursor to the beginning
of a line and END key moves it to the end of a line. The use of these
keys in the keypad is intuitive and very easy to get used to.
Pressing F1 function key will invoke the hypertext help system, showing
various features of F-PC and editing functions in SED. Hypertext topics
are highlighted in reversed video. You can select a topic by moving the
cursor over the name of the topic, using the arrow keys, TAB, and Shift-
TAB. TAB jumps from one topic word to the next. Shift-TAB jumps to the
previous topic word. Press F9 or <return> links to the selected topic and
displays the text of this topic. You can select another topic and press
F9 to investigate even deeper. F10 allows you to unlink one level and
float up to the prior topic. Press F10 repeatedly will lead you back to
SED to continuing editing work.
SED is designed to use WordStar control keys to move the cursor.
However, on an IBM-PC, it is most convenient to use the cursor keys in
the keypad to position the cursor and then insert new text or type over
old text. It is very easy to master this editor without much effort.
The F1 help system and the menu bar are always ready for consultation.
For more sophisticated operations, refer to the following sections for
detailed descriptions on all the control/alternate/shift/function key
functions.
Pressing ESC key leads you into a menu help system. The top status line
is replaced by a menu bar, somewhat resembling that in a Macintosh. One
of the menu items is highlighted. You can select other menu items by
pushing the left or right arrow key. Pushing the <return> key or down
arrow selects the menu and its items are pulled down under. The first
menu item is highlighted. Pushing up and down arrows followed by <return>
selects the highlighted menu option and performs the function. Each menu
option has a title with a single capitalized character on the left, and
possibly a alt-ctrl-shift-function key specification to the right. When
the menu is visible, you can type the capitalized character to execute
the corresponding function. When you are in editing mode, the
alt-ctrl-shift-function key can be used to invoke the function without
having to step through the menu bar.
Pushing ESC-Q-S or F10 terminates the editing session and returns to
F-PC, after saving the modified text to disk. A backup copy with .BAK
extension is saved of the previous edit. This automatic file backup
feature can be selected as an configuration option BACKUPON when you
install F-PC. Unless you are operating F-PC from a floppy disk drive, it
is always recommended that you choose this option. In using the block
file system in F83, you might lose four blocks of recently edited text if
you crash the system. With that experience, you will appreciate this
file backup feature. However, if you definitely do not want to save the
newly edited file, type ESC-Q- D or Alt F10 to exit without changing the
original file.
SED is intuitive, very friendly, and convenient. Using the keypad you
can accomplish 90% of the text selection functions. Only rarely do you
have to consult the help texts for advanced features, which are only one
F1 stroke away. The menu help system brings help functions even closer
to you.
5.3. MENU & MOUSE CONTROL
SED uses Pull Down menus with fairly complete mouse support to make many
functions available while editing. Press the ESC key and the menubar
appears at the top of the screen.
If you have pressed the ESC key, then you are looking at a list of menu
titles starting with "File" which should be shown in reverse video,
through "Help" on the right:
File Edit Select Layout hYper Advanced Help
Use the keypad right arrow key to walk along the menubar. As you press
right arrow, the highlighting moves along the menubar. Continue to press
right arrow until "File" is again the highlighted menu. Press the down
arrow key to pull the menu down. Notice the last two items of the
"File" menu, Exit and Quit. To the right of these menu items, are
displayed the short cut keys F10 and Alt-F10. Any menu function can be
performed with the short cut key rather than moving through the menu and
pressing Return. If you press right arrow while the "File" menu is
pulled down, you will walk along the menu bar with each menu "open", so
you can see what menu items are available. You can also press the first
capitalized letter of a menu item to perform the function.
The menu selection by keystroke sequence is thus:
ESC <menu-select-key> <function-select-key>
Pressing ESC instead of the <menu-select-key> or <function-select-key>
aborts the menu key sequence, and you will return to the main editor
window.
To use a mouse in SED you must have a compatible mouse driver (like
MOUSE.COM) already installed in your AUTOEXEC.BAT. When F-PC starts up,
it looks for the presence of a mouse driver, and activates the mouse if
the driver is present.
As you are looking at the editor screen you will see arrows to the right
and lower right of the screen. These arrows can be used to scroll the
screen, showing more text from the direction the arrow is pointing by
clicking the left mouse button. The F10 or +1 etc. in the upper right
corner can be used like the F10 key by positioning the moue and clicking
the left button. You can also change the INSERT/OVERWRITE mode by
clicking at the top left of the screen on INSERT. Help can be obtained by
pressing HELP at the lower left. The cursor can be positioned by clicking
within the edit window with the left mouse button. The right mouse
button is the same as the ESC key.
5.4. FUNCTION KEYS
SED supports a subset of the WordStar control keys used to move the
editing cursor around in a document. The keypad is also supported, as
can be seen in the following diagrams. The functions of various keys are
annotated in the diagrams. More elaborate descriptions are presented in
the next few sections. The cursor movement keys, Control
A,S,D,F,E,X,C,R,W and Z have been maintained, as have the delete keys
Control G,T,Y, and Del.
CONTROL KEYS
KEYPAD KEYS
FUNCTION KEY ASSIGNMENTS
5.5. SELECTING ANOTHER FILE TO EDIT
Ctrl-O allows you to open or create a file. When you are being asked to
return a new filename, if you press <return> without returning a
filename, a window will pop up allowing you to select a file from the
directory.
If you are in a sub-directory when the window appears, then a file named
"." and a file named ".." will appear at the top of the file list. These
files, along with any directories below the current directory, will
display a graphic "infinity" symbol "░" to the right of the filename. If
you press <return> while positioned on the "." name you will select the
root directory. The ".." name will pop up one level of directory, and
any other name with the "infinity" symbol next to it will step you down
one level to that directory. You can move between files in the list,
with the keypad arrow keys, and select a file by pressing <return>. ESC
can be used to abort file selection.
While in the pop up file selection mode, you can also set the current
drive by pressing a letter key between A and G. This drive must exist
and have a disk in it, or a system error will result. The path and the
current drive is displayed in the lower right. The path can be changed
by pressing the "\" key, then typing the new path followed by the return
key.
Ctrl-U saves the current contents in the editor buffer to the file and
continues on with editing. Alt- W allows you to write the contents to a
different file. F-10 will save and close the current file. However, a
message will be displayed on the screen asking you to type in a new file
name to continue the editing. If you press ESC, editing will terminate
and you will return to F-PC. This extra level of prompting given you
better control over the editing process. Alt-F10 will discard the
changes and leaves the file unmodified. SED will prompt you for another
file before returning to F-PC.
FILE SELECTION
Alt-O Save changes and continue
Ctrl-O Open or create a file for editing.
Ctrl-U Save changes and continue editing.
Alt-W Write the file in memory to a new file
Alt-F1 Rotate to the next file opened.
Shift-Alt-F1 Rotate to the previous file.
F10 Save changes and leave SED, with a prompt
Alt-F10 Discard changes and leave SED, with a prompt
Through the File Open command Ctrl-O you can open up to 20 files while
in the F-PC editor. When you open more than one file F-PC keeps track of
where you were in each file, but only really edits one file at a time.
Files get swapped in and out of memory as required. This is slower than
keeping all of the file in memory, but on a hard disk system the
performance is still acceptable. Alt-F1 can be used to rotate through the
file that have been opened. Its reverse command is Shift-Alt-F1 which
will rotate through the open files in the opposite direction. Shift- F1
will popup a window for you to select a particular file directly,
avoiding the time required to rotate through several files to get to the
one you want.
To leave the editor, and close all files, use the File menu command
ESC-F-X.
The F10 key "unlinks" or leaves one edit/browse level. If you were
editing, your changes are saved, and you will return to the previous file
you were editing or browsing. If you were at the first level of editing,
F10 will leave the editor.
The Shift-F10 key will take you to edit/browse level one. This saves you
from having to unlink through many levels with F10, and takes you
directly to level one. If you were already on level one, Shift-F10 will
leave the editor.
If you are using a mouse, clicking the left mouse button on the F10, +1
or +2 at the upper right hand corner will do the same as pressing the F10
key.
5.6. SEARCH AND REPLACE
You can look for any sequence of characters in SED with the Search-F6
key. When F6 is pressed, you are asked to return a text string to look
for. SED will look for that string of characters when you press
<return>. When SED searches for text, it ignores the case of the
letters. If you want SED to look at the case of the text it searches,
hold down SHIFT while pressing <return>. This search is much faster. To
search for another occurrence of the same text string, press Alt-F6 (or
SHIFT Alt-F6 if you want only an exact match). See also the earlier
section on Replacing Text.
Having already done a search using F6 above, you can also search
backwards with Shift-F6, which searches backwards from the cursor with a
case sensitive search.
After a Search has been done, you can replace the text found. Press F8.
You will be asked for a replacement string, which will be used to replace
the found text, when return is pressed. To search for the next
occurrence of the same text, press Alt-F6, and to replace the next found
occurrence with the same replacement text, press Alt-F8.
Having already performed a Search F6 and Replace F8 once, you can replace
all occurrences of search text with replacement text by pressing
Shift-F8.
SEARCH AND REPLACE COMMANDS
F6 Search the first time (prompts for text)
Alt-F6 Search for same again, case insensitive
Shift-F6 Search for same again BACKWARDS
Shift-Alt-F6 Search again, case sensitive
F8 Replace the first time (prompts for text)
Alt-F8 Replace same again and search same again
Shift-Alt-F8 Same as Alt-F8, but case sensitive
Shift-F8 Replace All occurrences
5.7. CUT, COPY AND PASTE
SED can cut lines of text to another file. With Alt-X, first go to the
first line of text you want to cut, and press F3 mark to mark the start
of the block cut. Then move to the last line of text you want to cut,
and press Alt-X. This will cause all of the lines between and including
the start and end line to be written out to the file TEMP.SEQ. The lines
will also be deleted from the current file. To specify a different
filename to cut to, press Shift-Alt-X, instead of Alt-X, and you will be
prompted for a name to write to. See also "Pasting from a File", and
"Copying from a File".
SED can copy lines of text to another file. With Alt-C, first go to the
first line of text you want to copy, and press F3 mark to mark the start
of the block copy. Then move to the last line of text you want to cut,
and press Alt-C. This will cause all of the lines between and including
the start and end line to be written out to the file TEMP.SEQ. To
specify a different filename to copy to, press Shift-Alt-C, instead of
Alt-C and you will be prompted for a name to write to. See also "Cutting
text to a File", and "Copying from a File".
Text which has been cut with the Alt-X (cut) command to the TEMP.SEQ file
can be pasted back with Alt-V, the paste command. If you want to paste a
file other than TEMP.SEQ, you can press Shift-Alt-V, and a window will
pop-up for you to select a file from. If you press ESC during the paste,
or while in the file selection window, the import operation will be
aborted. See also "Cutting text to a File".
CUT, COPY, PASTE AND APPEND WITH DISK
F3 Mark first line of copy or cut
Alt-X Cut from Mark through cursor line to TEMP.SEQ
Alt-C Copy from Mark through cursor line to TEMP.SEQ
Alt-V Paste Cut/Copied text at cursor line from TEMP.SEQ
Alt-A Append from Mark through cursor line to TEMP.SEQ
Alt-O-P Paste the current date and time into text at cursor.
Use Shift-Alt to specify the file to Cut, Copy, Paste or Append with.
5.8. LINE AND WORD COMMANDS
Lines can be deleted with Ctrl-Y, and un-deleted with Alt-Y. Any lines
which are deleted are saved in a line delete buffer which has room for 25
lines. This is also the number of lines deleted which can be un-deleted.
Lines can be copied from one place in a file to another, with the
Mark-F3, and Copy Line-F5 commands. Move to the first line of the block
of text you wish to copy, and Mark the start of the copy with Mark-F3.
Now move to the place where you want to copy the text to, and press Copy-
F5 once for each line you want to copy.
LINE AND WORD DELETE/UNDELETE
Ctrl-Y Delete this line and save in delete buffer
Alt-Y Undelete a deleted line from the delete buffer
F5 Copy a line from Mark to cursor line
Ctrl-N Split this line at the cursor
Alt-N Join this line with next line
Ctrl-T Word delete and save
Alt-U Word Undelete *
5.9. MARGIN CONTROL
The left margin on the screen defaults to column zero, but when printing,
defaults to 2 spaces, so it is not normally necessary to insert a left
margin. However, when TAB is pressed, the left margin on screen is
expanded by 8 characters. Any subsequent lines typed in will maintain
this margin. The left margin can be set at any column position. Move the
cursor to the column where you want the left margin set and press Ctrl-L.
Alt-T sets the TAB key to tab to the current column, if you are on column
4, TABS will occur at column 4, 8, 12, 16, etc.
Alt-L moves all of the lines of a column of data to the right by a number
of characters from 1 to 9. The specified number of spaces are inserted at
the column of all lines from the current line until a blank line is
encountered.
Shift-Alt-L moves all lines of the current paragraph left such that all
leading blanks of all lines of the current paragraph from the cursor to
the right are removed.
MARGIN CONTROL COMMANDS
Ctrl-L Set left margin to current column.
Alt-L Prompt for the number of spaces to insert before
all lines of the current paragraph. Table move right.
Shift-Alt-L Remove all space from the current paragraph to the
right of the current cursor column. Table move left.
Alt-S-R Prompt for value to set Right Margin.
Alt-T Set tab increment to current column value.
Alt-O-X eXpand all TABs to spaces in the file in memory.
Home Set cursor to column 0 and reset Left Margin to 0.
The left margin is also set at the new cursor position after pressing TAB
when there are only spaces to the left of the cursor. This is useful for
maintaining or setting an indent while editing source.
5.10. CASE CONVERSION
To convert the case of the current character under the cursor, press
Alt-O-C, the case of the letter under the cursor will be tested, and it
will be converted to upper or lower case respectively. This is a toggle,
and will do nothing if performed on a non letter character.
To convert the current line to upper case, press Alt-O (option), followed
by U. All upper case characters in the current line will be converted to
upper case.
To convert the case of the current word starting at the cursor, press
Alt-O-W, the case of the letter under the cursor will be tested, and the
word will be converted to upper or lower case respectively. This is a
toggle, and will do nothing if performed on a non letter character.
CASE CONVERSIONS
Alt-O-U Convert the current cursor line to upper case.
Alt-O-L Convert the current cursor line to lowercase.
Alt-O-W Toggle case of word under cursor, starting at cursor.
Alt-O-C Toggle case of the character under the cursor.
5.11. LINE DRAWING
SED provides this line drawing feature to implement some of the simple
graphics used in the help system. It allows you to design character
graphics to draw attention from the user. You can draw single lines and
double lines with corners and branches as you move the drawing cursor
around the screen. The graphics can be save to a file and re-displayed
when the file is displayed on the screen. You will need an IBM
compatible printer to print the graphics on paper.
LINE DRAWING COMMANDS
F7 Start/Stop drawing lines
Ins Pen up/down command
- Select single width lines (minus)
= Select double width lines (equal)
Del Clear char under cursor
Arrows Move and draw a line
5.12. PARAGRAPH SORTING
An interesting although relatively slow function in SED is the Alt-F7 key
that will sort the lines of the current paragraph starting on the cursor
line and continuing until a blank line is encountered. A paragraph is a
group of lines separated from other paragraphs by one blank line. The
sort starts at the current column, and tests the next 10 characters to
perform the sort. It is possible to create simple databases or phone
lists, by placing different pieces if information at specific columns,
and using Alt-F7 to sort according to these columns as needed.
SORTING THE LINES OF A PARAGRAPH
Alt-F7 Sort paragraph lines starting at current
line and column. This sort is case sensitive.
Shift-Alt-F7 Sort paragraph non-case sensitive.
5.13. KEYSTROKE MACROS
SED does not have macros built into it, but a file is provided called
MACROS.SEQ, which implements macros in Forth that can be used in SED.
These macros work exactly the same as they work in ZED. That is, you use
Alt-M to start defining a macro, followed by one of the Alt-1 to Alt-5
keys for the macro you are defining. Next you return any keys you want
included in the macro, and finally press Alt-M again to complete the
macro definition. To perform a macro, simply press one of the Alt-1
through Alt-5 keys by it self, and the keys saved will be performed.
MACROS
Alt-M Start and terminate a Macro.
Alt-1...8 User defined macros.
Alt-R Repeat a macro.
Macros are powerful editing tools as you might want to make global
changes to a file. A macros can encapsulate many editing functions so
that they can be executed repeatedly to reformat the entire file.
5.14. PRINT A FILE
While in SED editor, you can print the current file by pressing Alt-P to
return into a printing selection screen. In this screen, you can select
various options such as the left margin, starting page number, and the
number of copies to be printed. After you are satisfied with the options
you selected, press 'P' and the file will be printed on the printer
connected to the PRN port on your PC. SED now also supports print
redirection to a file. Press S to set the file to print into. A cursor
will appear on the bottom menu line next to the message "Currently
printing to". Just type in a filename to print to. Be sure to use a
different name than the file you are editing. Press <return> to set the
new file, or press ESC to cancel print redirection and revert to the PRN
device.
Pages printed are formatted with a header above and a footer below. The
text line in the header is taken from the first line of text in the
current file. You can design the header by putting appropriate text in
the first line of a file. In the footer, important information about the
file is printed, including the page number, the file and path names, and
the date of printing. A similar print format is used when you use FPRINT
to print a file outside the editor.
You can insert special printing control features into the file so that
selected text can be bold and/or with underline.
USER DEFINED PRINT CONTROL
%B This line will be printed BOLD %B
%U This line will be printed UNDERLINED %U
%B%U This line will be both BOLD and UNDERLINED %U%B
%1, %2 & %3 User defined printer attributes.
See an example in the file PROPRINT.SEQ.
5.15. OTHER HELP
Alt-G Goto specified page/line or next/prev paragraph
Alt-B Browse a word under the cursor.
Alt-E Edit the source code of the word under cursor.
Alt-H Shows help on the word under the cursor while editing.
Ctrl-<return> Spawn a DOS shell.
F9 Link one level down,
Alt-F9 Link deferred word.
Shift-F9 Toggle Browse/Edit mode.
Alt-F3 Define source link.
Alt-F5 Define destination link.