home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
vol_100
/
199_01
/
ged.doc
< prev
next >
Wrap
Text File
|
1987-12-17
|
28KB
|
556 lines
GED 2.00
I. Introduction ( goto Changes and Additions if you already use ged )
Ged, a.k.a. "go edit", is an adaptation of J.W.Haefner's MS-DOS QED text
editor to COMPAQ/IBM-PC hardware, making extensive use of DeSmet C's pcio
video routines.
Since this is only an adaptation I have left in all references to previous
authorship. I have also retained most of Mr. Haefner's documentation -
as much of it still applies to Ged.
Why GED?
Initially my goal was to produce an editor to replace what I've used for
almost two years, ( Turbo Pascal's editor ), and to one day port it to a
UNIX/XENIX environment. At this point in time I feel I've made some good
progress towards that end and have decided to pass on the fruits of my
research.
I started this project back in January '86, and spent a good deal of
time trying to make GED work using ansi.sys. It eventually did run, but
not much faster than what I can do in BBx, Business Basic. Ansi.sys
should be used sparingly. Around Spring '86, I started over again, this
time playing with interrupts and feverishly re-reading my Norton's. It
then dawned on me - "why re-invent the wheel", and I opted to use the
video routines that were supplied with DeSmet C's compiler package.
( My reluctance to using pcio was motivated by not wanting to learn assembly
language - there's no way around it. At least with gedio.a you've got some
good working examples. )
II. Changes and Additions
Function Key Definitions:
─────────────────────────
F1 = help menu
F2 = update time
F3 = move cursor left one word to change
F4 = move cursor right one word ""
F5 = save the current file and resume editing
F6 = execute ls see getenv()
F7 = execute more ditto
F8 = execute grep ditto
F9 = turn on graphics editor - display IBM extended ASCII tables
F10 = reset run-time variables and options.
Cursor Control Keys:
────────────────────
Home = cursor to left edge of screen
End = cursor to end of line
PgUp = move cursor up to beginning of file
text scrolls down
PgDn = move cursor down to end of file
text scrolls up
Del = delete character under cursor
if end of line then pull from line below
Caps = displays caps lock status
Lock
Ins = turns overtype/insert on/off ( ged is in insert mode normally )
Arrows = as expected
Alt = if IBM chars table on - then get character from 10-key pad.
GreyMinus = move cursor word left
GreyPlus = move cursor word right
Version:
────────
v2.00 Converting Ged to MicroSoft 5.0 and Qic C.
Added Gedio.asm, ged low level screen routines which compile
under MASM.
v1.15 Added IBM extended graphics chars( box parts, etc. ).
Added grey-minus and grey-plus key detection.
v1.11 Added getenv() - DeSmet 3.0 specific.
Cleaned up screen I/O, it all begins with scr_, except for putstr.
All scr_ functions are located in gedio.a
All scr_ co-ordinates are set for ( col, row ).
All interrupt coded functions are in ged11.c.
Added overtype mode and capslock indicator.
Speeded up cursor movement.
Some additional fixes as suggested by Andrew Binstock.
v1.10 Annoying delete to end of line problem cleaned up.
Delete routine did not have actual cursor location.
Only showed up if deleting at postion greater than
screen width.
Changed inject function to writ_txb - easier to relate to.
Cleaned up putline and rewrite functions.
Added execute function to run other people's programs.
Added J.W.Haefner's reform routine. This is for letter
writing and not programming. Reset right margin using F10.
( Routine still needs some work )
v1.05 Added printer error recovery routine. Printer routine covers
trying to write to non-existent printer, meaning - you forgot
to plug it in. Further success of routine appears to be somewhat
printer dependent. You plugged the printer in then turned it off.
Added undo routine from N. Gilbert's 'e' 4.8 CP/M editor.
( Undo replays the last 100 line changes, including deletes,
moves, etc. It's very handy. )
New Functions:
──────────────
1. undo() Undo will undo the last change(s) - up to one hundred.
To use, enter ^_.
2. reform() Use to reformat blocks of text.
Current Default is 72 characters. To change, use F10 Key to
call file Context Menu. To use, place cursor at beginning of
text block and enter ^QR. Will work with undo. You must
move the cursor off the line before reforming.
3. execute() Must use elink.bat and elink.dat. See function key assignments
in ged.c, and execute() and show_fkeys() in ged1.c. Execute
will clean up after itself depending on how the last argument
is set.
4. getenv() It is now possible to locate ls.exe and more.exe using environ-
mental variables which you can set in your autoexec.bat file.
SET LS=c:\exe\ls.exe
SET MORE=c:\exe\more.exe
SET GREP=c:\exe\grep.exe
( I store my more useful executables in a subdirectory named \exe.
You must set LS, or whatever you call it, in the function key
assignment section of ged.c as well. See ged.c for examples. )
Make sure to set ansi.sys in your config.sys file as ls and
more use the reverse display drivers.
Books:
──────
I recommend the following books for the serious enthusiast:
"Crafting 'C' Tools for the IBM PCs", Joe Campbell, Prentice-Hall.
"Advanced MS-DOS", Ray Duncan, MicroSoft Press.
Bugs:
─────
As of GED 1.10 I became aware of a potentially troublesome bug.
Make sure that readall in ged.c is always set to YES - else you may end
up zapping some random disk sectors. ( Especially if attempting to save
a file before completely reading it in. )
There's a bug in displaying tabs properly - I wish someone would fix
it. I don't use tabs.
Printer error routines could work better.
Other:
──────
Also, please report anything you feel is a bug or that needs improvement.
Fixes and constructive criticism are welcomed.
╓─────────────────────────────────────────────────────────────────────────────╖
║ Graphics: ║
╟─────────────────────────────────────────────────────────────────────────────╢
║ What won't work. The following Ascii characters will cause you problems. ║
║ ║
║ 009 or '\t'. I don't use tabs, but for those those who do, '\t' makes for ║
║ some funny looking displays if not converted to blanks. ║
║ ║
║ 010 or '\n'. Will do as expected. Ged is still a text editor. ║
║ ║
║ 026 or ^Z. Stops your read dead in it's tracks. ║
║ ║
║ Of the three, only ^Z is useful as graphics character - Paul Mace may argue ║
║ otherwise. If you really need to use these forbidden characters it's best ║
║ to write them rather than store them. ║
║ ║
║ What will work. F9 turns on the extended graphics mode and puts up the ║
║ first table. Alt + the number of the char entered with the 10-key pad will ║
║ write the character at the cursor location. Control L, ^L, will repeat it ║
║ till it is changed or you do a search/replace function. ║
║ ║
║ There's nothing magic here - it's just a fact of life for P.C. users. ║
╙─────────────────────────────────────────────────────────────────────────────╜
╓─────────────────────────────────────────────────────────────────────────────╖
║ In the Works: ║
╟─────────────────────────────────────────────────────────────────────────────╢
║ Conversion to TurboC. ( Needs to be debugged ) ║
║ ║
║ Conversion to MicroSoft 5.0 and Qic C. ║
╙─────────────────────────────────────────────────────────────────────────────╜
III.1 DOCUMENTATION FOR QE AND QED/GED (J.W.Haefner - 7 August 1985)
This is documentation for the programs QE and QED: two modifications of
'e' version 4.6b. QE is the modification for BDS-C and QED is the
modification for DeSmet-C (hence the "D") under MSDOS version 2.x. Since
the basic structure of these modifications is still that of e, that
documentation is relevant and I indicate here only the differences.
'e' is a fine program, carefully written with good logical structure;
however, editors are a personal matter and many features that I thought
desirable were either missing, or awkwardly implemented. Consequently, QE
and QED is the result of an attempt to incorporate different and additional
functions. Most of these derive from WordStar, my favorite word
processor. Since the modifications are basically superficial and (at one
level) "cosmetic", I have retained all references to Nigel Gilbert as the
author and copyright holder. Each file indicates that it is a modification
of the original e (ver. 4.6). On the other hand, my modifications conflict
to some degree with the philosophy detailed in the documentation to the
original 'e'. Therefore, as indication of this possible conflict, I have
given new names to these modifications. The "Q" was originally to mean
"quick", as my initial goal was to produce a smaller, faster version of 'e',
as I thought it terribly long and slow. I did not achieve this goal and
instead came away with the perception that virtural memory editors must be
this large and slow. Mr. Gilbert has done an admirable job.
I. QE and QED
A. WordStar functions
1. SCROLLING: ^W scrolls the screen down (i.e. UP through the text)
and leaves the cursor on the line and column prior to scroll. ^Z scrolls
the screen up in the same manner.
2. Delete to End of Line: ^QY deletes all text from the cursor to the
end of the line.
3. Delete Line: ^\ now deletes the current line (this makes it
difficult to err, identical to my version of WordStar). In 'e' v 4.6 and QE
and QED lines deleted can be recovered if the cursor has not left its
vertical sceen postion by typing ^N^_ (i.e. insert new empty line (^N), and
recover (^_)). A more elaborate UNDO function is implemented in 'e' ver
4.8, but I don't feel a need for it.
4. Block manipulation: all of these are done through ^K as in WordStar.
These functions are: quit (Q, as in 'e'), save and exit (X, as in WordStar),
file read (R), repeat a jump to the last jump line (J), and the block moves of
'e' (B).
5. Exit with Save: ^KX saves the file being edited and exits directly
to the operating system.
6. BACKSPACE == LEFTKEY in all applications except find/replace
editing.
7. QUICK functions; analogous to WordStar, ^Q switches to other
functions (i.e. environment (K), delete to end of line (Y), find (F), alter
(A).
8. Top and Bottom o Screen: ^Y moves cursor to top of screen, ^V
moves to bottom of screen.
9. KEYS: wherever possible, I have used WordStar mnemonics for
control characters. This is almost exact for the left hand; the right hand
uses my own choices (e.g. move to left end of line = ^O, to right end of
line = ^P, etc. These are documented with a revised HELP display obtained
via ^^ (difficult to type but the interface is so obvious that I rarely, if
ever, use HELP). Below I give a map of the keys used in QE and QED.
10. READ ALL ON INITIAL LOAD: As a matter of preference, the initial
reading of a file from disk reads the entire file or as much as possible to
fill memory before displaying the first page. Alteration of this feature
currently requires re-compilation, but it could easily be implemented as a
command line option.
B. Fixes to "bugs"
2. JUMP: Use of "-Jn" on the command line where n is an integer
causes the initial program load to jump to line number n, or the bottom of
the file if n is greater than the number of lines in the file. This is
similar to 'e' ver 4.8. I have further modified the jump command to permit
relative (+/-) jumps of any length (unlike page up or down; alas, not as
useful as I had hoped). Moreover, use of "^J,<CR>" or "^J,ESC" sets the
"jumpto" variable to the current line. Use of ^KJ repeats the last jump.
Thus, a very simple "jump marker" is implemented as the following example
illustrates:
^J,<CR> (mark this line),
...some editing...,
^U (top of file),
... more editing,
^KJ (back to line number marked earlier).
I find this feature very useful. If editing following jump line marking
adds or deletes lines, then ^KJ will not return to the identical text
orginally marked (since that text now has a different line number). This
could be fixed in later versions. More than one "jump marker" would be
desirable.
3. REPEAT PAGING: In repeated use of page up or page down, 'e' ver
4.6 causes all pages to be completely rewritten. To speed up movement
through a file, I allow the rewriting of a page to be interrupted if the
next comand in the buffer is either "pageup" or "pagedown". On the files
QE2A and QE3A for terminals such as ADDS Viewpoint that do not have line
insert functions, scrolling down (^W) requires re-writing the entire page,
this is also enhanced by looking at the type-ahead buffer to interupt page
re-writing if the next character is also for "scroll down".
4. CONTROL CHARACTERS: Use of the sequence "ESC,char" to embed control
characters into the text did not work properly on my 'e' ver. 4.6. This has
been fixed.
5. PRINTING CONTROL CHARACTERS: 'e' transmits only a few (none?)
control characters to the printer. QE and QED send most control characters
so that dot matrix printers can be manipulated within the editor (e.g. set
margins, condensed print, etc).
6. FAST DISPLAY 1: Most screen I/O replaced with direct video
writes.
7. FAST DISPLAY 2: I allow characters to be inserted into the type-
ahead buffer only after a line has been written except when inserting text.
'e' ver 4.6 checks for more input to buffer after every character is
written. This slows down the display. Checking at the end of each line
seems to cause no problems. Moreover, 'e' ver 4.6 does not check for type-
ahead buffer overflow; this is a problem on fast terminals with repeat keys.
Text insertion is checked after each character inserted so that fast typists
do not lose characters.
8. HIGH-LIGHT CURRENT LINE: The use of all text displayed in normal
attributes or dimmed with current line normal as in verson 4.6 is controlled
by a conditional compile statement. 'e' ver 4.8 uses an internal global
variable permitting switching within sessions. Since I never want that
feature and since the fewer "if-checks" the better, I opted for the re-
compilation solution.
9. FIND/ALTER STRINGS: 'e' ver 4.6 allowed most control characters
to be embedded in the string to find or alter, but escape (0x1b) was used to
terminate the string and thus could not be searched for. I implemented a
kludge to work around this. ^] is translated to 0x1b and embedded in the
string. A reminder of this is presented when the find/alter function is
selected. Also several other control characters can now be embedded that
could not have been in 'e'. Other changes to this function allow the
"retrieve" function to replay the last previous string to find and alter
from the current positon of the cursor in the string to the end. Thus, if
the previous search string is non-empty, then the retrieve function prints
the previous string from the current position to the end. If the previous
search string is empty or the cursor is at the end of the non-empty previous
search string, then use of the retrieve function will embed the key code for
the retrieve function into the search string. For the file of terminal
characteristics currently used, this is ^L, which is also form feed. The
current implementation allows primitive editing of the search string without
re-typing the entire line. Assume the previous search string is non-empty;
the retrieve function (^L) will display to end; backspace and replace
character to be edited; ^L will re-display the remainder of the string. To
re-initialize a search string to be empty, simply backspace to the
beginnning and hit ESC or <cr>.
---------------------------------------------------------------------------
2. HINTS TO FUTURE MODIFICATIONS: For others that wish to modify
the program for their own purposes: (1) The file "GEDFUNCS.DOC" lists
the functions used in GED. (2) Debugging messages can be displayed within
the editor by using the statements:
/* debug */
gotoxy(0,24); printf("var1 = %d var2 = %d ", var1, var2 );
If numeric output is required, the function uspr" in GED3.c can be used.
mt - 10/05/86
---------------------------------------------------------------------------
III.2 QED SPECIFIC MODIFICATIONS
QE has been tranlated to DeSmet-C under MSDOS 2.x and called QED.
Because of difference in the compiler and the operating system, several
additional changes have been made.
1. MSDOS Ver 2.0: QED requires generic MSDOS version 2.0 or higher
and checks with a BDOS call that the system uses this version. No IBM-PC etc
specific BIOS calls are used. I.e. no software interrupts below 20 hex are
used, nor are any port or memory specific references made.
2. DIRECTORY: QED function replaced with exec to ls.
3. NO BDOS ERROR RECOVERY: I don't know how to trap BDOS errors in
MSDOS, therefore Mr. Gilbert's elegant CP/M BDOS traps have been eliminated.
I would, of course, be interested in knowing how to do this.
4. PATHS: Specification of paths is supported for files. A
function to display and alter the path is implemented (via the file context
function: ^QKF). Since full path names can be almost arbitrarily long, the
status line will display the last 32 chars of the file name.
5. MODIFICATION CHECK: If the user attempts to discard a modified
file without saving it, a query is presented to ensure this was intentional.
6. DEFAULT EXTENSION: The extension of the file called on the
command line is saved in a default file extension string. Future file
requests (performed within a given QED session) do not require a file
extension to be given. If no extension is given, the directory is first
searched for a file as typed. If this fails, the default extension is
appended to the input file name and the search repeated. The default
extension is overridden by using an explicit extension. The desirable
modification of not having to give the file extenson on the command line is
not necessary in MSDOS by using batch files to invoke QED. For example, if
a series of editing sessions is to be undertaken using assembly language
programming, then the following .BAT file is useful:
QED %1.ASM -T8 -J%2
If this batch file is called, say, "e" then the command line "e myprog 150"
will invoke QED to load MYPROG.ASM, set the tabs to 8 spaces, and jump to
line 150. This could also be done with CP/M, but SUBMIT is slower than
typing in the entire command line.
7. DeSmet SPECIFIC MODIFICATONS: The DeSmet compiler is adequate and
a good buy. Several changes were made from QE (using BDS-C) to accomodate
the different compiler and operating system. (a) The function "uspr" was
altered to take 2 arguments to print either a short or long integer. Long
integers are necessary to display disk space on my 8" disks. (b) The
following functions were renamed to avoid collision with functions loaded by
the DeSmet BINDer: "putc" to "eputc", "getc" to "egetc", "puts" to "eputs".
This renaming might not be necessary, but the manual suggests it is.
IV. MAP OF KEYS AS DEFINED IN TERM.C AND GEDIO.A - Revised June, 1987
^A Word Left - F3
^B End of File
^C Scroll Page Down - PgDn
^D Cursor Left - Right Arrow
^E Cursor Up - Arrow Up
^F Word Right - F4
^G Delete Character Uuder Cursor - Del
^H Non-Destructive Backspace - Backspace
^I Tab Right - ( Rarely Used - Somewhat Buggy )
^J Jump to Line
^K Block Operations and Standard ^K Functions
Q Quit
W = Write File
A = Abandon Altered File
X Write File and Exit
J Repeat Jump to Last Marked Line Number - ( Never Used )
B Block Moves
R Read File
^L Repeat Last Find/Alter
^M Carriage Return
^N New Line
^O Move to Leftmost Character on Line - Home
^P Move to Rightmost Character on Line - End
^Q 'Quick' Functions
A Find and Replace
F Find
S Services ( Tab Set, Files, etc.) - F10
R Reform Block of text - For Letter Writing, needs work
Y Delete to End of Line
^R Scroll Page Up - PgUp
^S Character Left - Arrow Left
^T Delete Word Right of Cursor
^U Move to Top of File
^V Move to Bottom of Screen
^W Scroll Page Down (Cursor Position Constant)
^X Move Cursor Down One Line - Arrow Down
^Y Move Cursor to Top of Screen
^Z Scroll Page Up (Cursor Position Constant)
^[ Same as ESCAPE
^\ Delete Line
^] Not Used
^^ Help - F1
^_ Undo the Last Command - Up to 100 Changes
DEL Delete Character Under the Cursor
INS Turn on Overtype Function - Default Insert
V. The Last Word:
This project couldn't have been undertaken without the use of DeSmet's
'c' compiler. 3.03 is very fast.
╓─────────────────────────────────────────────────────────────────────────────╖
║ A. Compile and Link times. ║
╟─────────────────────────────────────────────────────────────────────────────╢
║ Standard Compaq and XT-Clone ( both with Seagate ST225 HD and 640K Ram ) ║
║ vs. Compaq II Model IV. ║
║ ║
║ 128 RAM Cache using PCGS Lighting on Standard Compaq only. ║
║ ║
║ Program Computer Compiler Times ║
╟─────────────────────────────────────────────────────────────────────────────╢
║ Raku Standard DeSmet 2.51 19 secs ║
║ Compaq II 11-7 secs* ║
║ ║
║ Standard MicroSoft 4.0 1 min 24 secs ║
║ Compaq II 25 secs ║
║ ║
║ Ged Standard DeSmet 2.51 6 min 05 secs* ║
║ XT-Turbo Clone 4 min 45 secs ║
║ Compaq II 1 min 47 secs ║
╟─────────────────────────────────────────────────────────────────────────────╢
║ *PCIO not compiled - 128K Ram Cache ║
║ 256K Ram Disk, 80K Ram Cache - includes compiling PCIO ( see all.bat ) ║
╙─────────────────────────────────────────────────────────────────────────────╜
╓─────────────────────────────────────────────────────────────────────────────╖
║ B. Compile times only. ║
╟─────────────────────────────────────────────────────────────────────────────╢
║ Using 96K Ram Cache - No Ram Disk. ║
╟─────────────────────────────────────────────────────────────────────────────╢
║ Program Computer Compiler Times ║
╟─────────────────────────────────────────────────────────────────────────────╢
║ Ged 2.00 Compaq II DeSmet 3.03 1 min 26 secs ║
║ DeSmet 2.51 2 min 03 secs ║
║ MSC 4.0 7 min 14 secs ║
║ MSC 5.0 6 min 33 secs ║
║ Qic C 1.0 2 min 42 secs ║
║ TurboC 1.0 2 min 19 secs ║
╙─────────────────────────────────────────────────────────────────────────────╜
╓─────────────────────────────────────────────────────────────────────────────╖
║ C. Compile and Link times. ║
╟─────────────────────────────────────────────────────────────────────────────╢
║ Using 96K Ram Cache and a 256K Ram Disk for temp files. ║
║ Includes ASM88 assembly times. ║
╟─────────────────────────────────────────────────────────────────────────────╢
║ Program Computer Compiler Times ║
╟─────────────────────────────────────────────────────────────────────────────╢
║ Ged 2.00 Compaq II DeSmet 3.03 59 sec. - 1 min 12 sec ║
║ ║
╟─────────────────────────────────────────────────────────────────────────────╢
║ Varies with condition of disk. ║
╙─────────────────────────────────────────────────────────────────────────────╜
Learning 'c' is sometimes a difficult process - I view GED as miniature
laboratory in which I carry out my little experiments in self-education.
Mel Tearle
1108 E. Georgia
Phoenix, Az. 85014
Phone: (602) 279-1576
Last revised: Novemeber 29, 1987