To: Tony Rizzo 72241,156 From: James E. Galbraith (via Chris Adamo 73500,2077) 1201 Chase St, Novato CA, 94945. **NOTE : This file, and the TED2 files in TED2_PC.ZIP, were given to me by J. Galbraith so that I might upload them to PCMagnet for him. It is not clear to me how I might go about uploading the program files archived in TED2_PC.ZIP. Please contact me via EasyPlex if you would like the TED2 program uploaded and, if so, how I can do that. Thanks, Chris Adamo 73500,2077 TED was originally presented as "TED The tiniest editor you'll ever need" by Tom Kihlken, in the November 15, 1988 issue of PC Magazine. The source listing was entered directly from that article. I altered it, as appropriate, to add comments or change or improve the program. When I recently obtained a program called TEDPLUS from a bulletin board, I went over its code to see what (if anything) might be of value. It had a character search and search again that I immediately incorporated into my version of TED (that was when I started to call my version TED2). It eliminated the CPM style as an end-of-file marker, allowing the creation of zero-length files. It also allowed entering any key code (it says), but I didn't like the implementation. While I was at it, I added a number of new features, constantly keeping in mind the program's small size and its intended use. TED2.COM occupies just 4096 bytes, four clusters on a 360K floppy disk. I have given copies of TED2.COM to friends (both novices and experienced users). Some of them have remarked that TED2 is easy and even fun to use. Even with all the changes, TED2 is remarkably similar to the original TED. TED follows normal text conventions: pressing the key actually adds two characters, Carriage-return and Line-feed , also known as a "hard carriage return". The key inserts the ASCII 9 tab character, and advances the screen cursor to the next column that is an even multiple of eight. The key deletes the character to its immediate left ("destructive" delete) and combines two lines if it is pressed while in the first column. The Backspace code may be entered in the file as a control code. A TED2 enhancement allows the ASCII codes for Carriage-Return and Line-feed to independently be entered into the file as control codes. Because of this, TED2 rigidly enforces a convention that once the pair is formed it becomes an End-of-line marker, and may not be separated again. Like DOS, TED allows entering any character (except , value 00) by holding down the key, typing the decimal value of its ASCII code on the numeric keypad, then releasing . This allows access to both the nonprinting codes below ASCII 32 and to the upper-order (ASCII 128 to 255) characters in the extended IBM set. A TED2 enhancement allows the code to be entered by pressing the key. TED2 has a character string search and search again function, that were borrowed from a program called TEDPLUS. The function key assignments for TED2 have been changed from those of TED (and TEDPLUS). The HELP screen is called by . EXIT was moved to and QUIT was moved to . PRINT is still , and PRINT a "Form-Feed" was added as . MARK is still and CUT is still , but PASTE was moved to . SEARCH was added as and SEARCH AGAIN as for compatibility with the usage in another editor that I use. UNDO was moved to when EXIT was moved to . DEL EOL , DEL L and UDEL L are unchanged (for now). DEL L is also assigned to for compatibility with another editor. EXIT and QUIT have been changed in a significant way. If an existing file has been opened for editing, but no changes have been made to it, there is no prompt and the user is immediately returned to the system prompt. This keeps files from being "updated" if they have not been changed. QUIT has also been changed to allow the key, in addition to the or key, as an affirmative reply. The program code was massively reorganized for improved structuring and to reduce the program size. JMPs have been used in place of CALL-RETurn constructs in a number of places to save code, but they have been commented as such. Some modules have been rearranged to allow using JMP SHORT, or no jumps at all. All assembly NOPs have been removed. The DISPATCH table has been corrected and cleaned up. It is now like a PASCAL style CASE statement. Screen update has been revamped. If there is a key waiting while the screen is being redrawn, the update is aborted to allow quicker response to the key. SEGment register usage has been cleaned up to minimize the number of segment override characters in the code. A DOS version check was added because TED won't run under DOS versions below 2.0. A program check sum test was added to check for program file corruption. Any unnecessary code was removed to make room for added functionality and for the HELP screen. NOTE: Unassigned keyboard codes are treated as no-operations. The TED Keypad commands are: Key Description Up Arrow Moves cursor up one row Down Arrow Moves cursor down one row Left Arrow Moves cursor left one column Right Arrow Moves cursor right one column PgUp Moves text window up one page PgDn Moves text window down one page Home Moves cursor to start of row (if at home, next up) End Moves cursor to end of row (if at end, next end down) Ins Toggles insert/overstrike mode Del Deletes character under cursor, to right (saved in UnDo) Backspace Deletes character to left of cursor (not saved in UnDo) Ctrl-PgUp Moves to top of file Ctrl-Home Moves to top of file (alias) Ctrl-PgDn Moves to bottom of file Ctrl-End Moves to bottom of file (alias) Ctrl-Right Arrow Moves text window right eight columns Ctrl-Left Arrow Moves text window left eight columns Alt-S Search Search for (case insensitive) character string Alt-A Search Again Search again for string Alt-D Del EOL Deletes from cursor to the end of line The TED Editing Functions are: Key Function Operation F1 Help Help screen ShftF1 Enters the code (value 00) in the file F2 Exit Save changes and exit (creates a .BAK file) ShftF2 Quit Exit without saving changes F3 Print Prints the marked text ShftF3 Form-Feed Prints a "Form-Feed" character F4 Mark Toggles mark state on/off F5 Cut Moves marked text to paste buffer ShftF5 Paste Inserts contents of paste buffer (64K char's max) F6 Search Search for (case insensitive) character string ShftF6 Search Again Search again for string F7 UnDo Replaces recently DELeted characters (256 char's max) F8 Del EOL Deletes from cursor to the end of line ShftF8 Del L Deletes the current line (MultiEdit) F9 Del L Deletes the current line F10 Udel L Inserts the last deleted line (256 char's max) In addition to the 64K Text buffer (where the edit file is maintained), there are three other important buffers, as indicated above. 1.) The paste buffer is a 64K character buffer used for MARK/CUT/PASTE of sections of the file. 2.) The line buffer is a 256 character buffer used to save the last deleted line of text (used with F8, F9 and F10). 3.) The UnDo buffer is a 256 character buffer used to save the just deleted characters at the current cursor location. It works with the "DEL" key, but only the last character with the "Backspace" key. It also saves overwritten characters in the Overstrike mode. Deletions are restored with "F7" UnDo. NOTE: There is a severe subroutine nesting violation in the TED key scan routine. BAD_KEY from within the keyboard scanning loop is a junp to read next key. The BAD_KEY subroutine calls through the DISPATCH_TABLE do not have a corresponding return to equalize the stack. This was partially compensated for by making the stack humongous. TED 1.0 as published in PC Magazine could eventually overflow the stack and crash the system. TED2 has corrected this problem by making a stub subroutine for the DISPATCH_TABLE BAD_KEY subroutine CALLs. TED was modified by James E. Galbraith, Dec 18, 1988. The changes are of several types. Compatability with other editors. Correction of errors and questionable code. Reordering of program modules to make it easier to follow the listing. Addition of meaningful comments. These modifications include: Change F2 "UnDo" to "Exit" (for BSE compatibility). Change F7 "Exit" to "UnDo". Make CTRL-HOME alias to CTRL-PGUP, to home the cursor (for BSE). Make CTRL-END alias to CTRL-PGDN, cursor to end of file (for BSE). JMP instructions outside modules instead of CALL/RETurn are commentd. Assignment of DS was sometimes ambiguous. Modified by James E. Galbraith, June 1989. The changes are in two groups. Those taken from TEDPLUS (apparently also written by Tom Kihlken), which was acquired from a bulletin board service, and my own changes. Add SEARCH and SEARCH AGAIN as F6 and Shft-F6, from TEDPLUS. Delete CPM style Ctrl-Z End-of-file code, from TEDPLUS. "Enter any key code" from TEDPLUS was included, but not like TEDPLUS End-of-line was changed to CR-LF as in TEDPLUS. CR or LF codes may be entered separately. My own changes are: Close the source file if it has been opened. This was not done by TED. Add a HELP screen as , move QUIT to . Fix the SEARCH inverse video to turn off when any key is pressed. Add DOS version check, needs version 2.0 or higher to run. Add a program checksum test for verification of file integrity. Add as alias for SEARCH (usage in BSE editor). Add as alias for SEARCH AGAIN (usage in BSE editor). Add as alias for , Delete to end of line. Add as alias for , Delete Line (for future expansion). If the file has not been altered, don't prompt for save or quit. On QUIT, accept a CR as confirmation of intention to abandon file. Add as key to enter the character, 00. If a CR and LF code are made to be ajacent, they become an EOL marker, and may not then be separated. This can occur in several ways that all include entering the codes and . A key entry will interrupt a screen update that is in progress.