home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Professional
/
OS2PRO194.ISO
/
os2
/
editor
/
e2
/
e_pc
< prev
next >
Wrap
Text File
|
1994-01-30
|
6KB
|
210 lines
USING E ON THE PC
Mike O'Carroll
Microsystems Unit
University of Leeds
1. INTRODUCTION
This note describes some of the features and limitations involved when run-
ning e2 on the PC. The overall intention has been to make the functional-
ity (ugh) as similar as possible to the *ix version, but restrictions
imposed by DOS inevitably cause problems in certain areas.
It will be assumed that you are familiar with the general operation of e;
if not, consult e_ref (D) and experiment.
2. SETTING UP
First get a copy of E2.EXE into your local \BIN directory which should be
somewhere in the execution search PATH. If you want the centering and jus-
tifying filters, get copies of ECENTER.EXE and EFILL.EXE also.
All the other files should be placed in a suitable library directory such
as \ELIB. If you get the programs by downloading from the *ix system, make
sure you use raw mode.
Next, set the TERM environment variable to ibmpc2. This requires the
ANSI.SYS driver; although this slows things down, it makes it easy to
drive other terminals via the comms port. Set the ELIB environment vari-
able to your library pathname. Set the TMP variable to a temporary direc-
tory and create the subdirectory ETMP in it.
All the above variables should incorporate the drive ID.
3. BACKUPS AND TEMPORARY FILES
Each time you change a file, a copy of the last version will be saved under
the name %filename. This corresponds to the "comma" file on the *ix ver-
sion. If the file name is already 8 characters (plus extension), e2 will
warn you that the name is being truncated. This warning is intended to
prevent you from editing, say, longnam1.c and longnam2.c in the same ses-
sion. The results will not be pleasing!
Temporary files are called &*.tmp. Most are removed on exit, unless there
is a crash, though a "state" file will remain and is used to restart an
edit exactly as it was left; simply type e2 without any arguments.
- 2 -
4. FILTERS
The feed and run commands, and by implication, fill, just and center,
mostly work under DOS. There can be problems with large files, and with
external filters that are not "well behaved". These should be implemented
by fork() and exec(), but have to be hacked under DOS.
If anything does appear to go wrong (screen gets scrambled, etc), do not
panic! Exit from the editor and take a copy of your backup file (%*). You
may find that the file is still OK (it seems that just the screen gets
scrambled). If not, simply copy the backup over the original and carry on
from there.
If you do encounter problems with this, please inform the author. Try to
give as full details as possible to aid bug hunting.
5. CARRIAGE RETURNS
End of line conventions differ from one system to another. In particular,
DOS normally expects text files to have the sequence CR-LF rather than just
LF; owing to its origins, e2 uses the latter convention internally.
The default mode of e2 suppresses the display of CRs on the screen*. A CR
flag at the bottom of the screen indicates this mode.
In its LF mode (no CR flag), e2 regards CRs as any other control character,
and will show them as *M (the * is actually a square block, but I can't do
one on this terminal!).
You can of course get rid of them using rep:
<ESC>rep /*M//<CR>
You enter control-chars by hitting control-\ (most PC keyboards), control-~
or control-` (some ATs and PS/2s), followed by the character or its
representation. e.g. To enter a carriage return, type
<control-\><CR>
or
<control-\>M
You can put CRs on the end of every line using $ in RE (regular expression)
mode. e.g.
<ESC>re<CR>
<ESC>rep /$/*M/<CR>
To switch from one mode to the other, use the command
<ESC>cr<CR>
or
<ESC>-cr<CR>
* This is the reverse of the earlier version, e.
- 3 -
as appropriate. On the command line, you can use the the -lf flag to turn
off the default CR mode.
Remember that if you use the default mode to edit a file which initially
contains no CRs, e2 will insert them on exit.
6. FLOPPIES
Many people have come to grief when trying to use e2 (or one of its ances-
tors, v or e) to copy files from one diskette to another. The procedure
enter the editor
change the disk
save the file
seems a reasonable possibility*. In fact, it is an almost, but not quite,
totally reliable method of scrambling both disks.
Why? Well here in brief is how this type of editor works:
a) First, it reads through the file and builds a linked list of "file
segment descriptors" which essentially define blocks of N lines in
the file. Amongst other things, each descriptor contains pointers to
the byte offset of each file segment.
b) When you enter editing commands, e2 modifies the linked list by mov-
ing pointers and changing the links, as you insert, move or delete
text. If you add text, it builds a keyboard file and inserts
descriptors which point to blocks in this. If you window into other
files and pick out text blocks, again the list is modified.
c) Note that the contents of the file are never "loaded into memory" at
all, except for the local section on the screen|-. Nothing happens to
the original files until you hit ^Z. Then, e2 "simply" runs through
the linked list and constructs a new file. The original file is
renamed to form the backup.
The bottom line is that changing disks in the middle of all this completely
invalidates all the information held in the data structures, but of course
e2 is none the wiser. It simply reads what it thinks are the correct bits
and pieces and writes them to what it thinks is the correct destination.
This could be anywhere on the diskette.
* Though why it should be more obvious than "copy" is beyond my comprehension.
|- In fact, \fIe2\fR does a lot of caching for efficiency reasons, but this
does not affect the general argument.