T:EDIT

T:EDIT screen

by: Bryan Schappel

Publication date: May 1987.

Download the executable (6,169 bytes).

A sweet little text editor.

Well, someone had to do it. Someone had to write a text editor for the 8-bit Atari, one you could type in and get a lot of use out of... and that someone was me.

In the last few years, quite a few compiled languages have become available for the 8-bit Atari. Some of these are Deep Blue C, Kyan Pascal, Draper Pascal, and DVC/65. All these programs require you to create your source code with a text editor, load the compiler, compile the source code, and go back to the editor to fix your mistakes. If you're like me, the only text editor you have is AtariWriter. That means you have to plug in the cartridge, boot up, edit your text, save it, remove the cartridge, load the compiler, and so on. Not only is this process tedious and time consuming, it also puts plenty of wear and tear on your computer.

I bet you thought, "Gee, it sure would be nice to have a little text editor that you could binary load from DOS, do a little editing and, with the touch of two keys, pop back into DOS again. That would certainly make life a lot easier."

Well, I thought so, too. And, as I thought these sick thoughts, my mind kept screaming, "Why don't you write a text editor?" So I did. I now offer you T:EDIT (short for Text EDITor).

Some of the things my mind told me T:EDIT must do were... (1) this editor must be a full-scrolling screen edi-tor like those other fancy editors; (2) it had better have a lot of commands, or else; and, finally, (3) it has to be easy to use. So, to appease my mind, I made T:EDIT do all these things and a little more.

To use T:EDIT, after creating the TEDIT.COM file, simply turn your computer off, remove all cartridges (on XL and XE computers, hold down OPTION while booting up) and follow these loading instructions.

If you're using ATARI DOS 2.0s, type L and RETURN, then type TEDIT.COM and RETURN. T:EDIT will load and run automatically. From OSS OS/A+ DOS or from SpartaDOS, simply type TEDIT and hit RETURN. The program will load and run automatically.

The program resides in cartridge slot A memory locations ($A000 - $BFFF) and uses addresses $BCOO - $BFFF as screen memory. This was done to allow the maximum amount of text space on a 48K Atari. The amount of free space varies on each computer and with each DOS. With SpartaDOS version 2.3e, you get 37120 bytes of text space.

Table 1 - The Commands.

TEXT COMMANDS
Key Function
^L
^S
^P
^M
^X
^F
^C
^l
^C
^E
^K
^R
^Q
^N
TAB
DS
^DS
^>
SH>
SHDS
Load a text file
Save a text file
Print a text file
Print to any device
Disk directory
Global search and replace
Erase text in memory
Toggle insert mode
Show "false" spaces
Erase spaces
Change char case (^CAPS)
Reverse two characters
Quit T:EDIT and enter DOS
Count words in text
Insert five spaces
Delete back one character
Delete one character
Insert one space
Insert 255 spaces
Delete 1 screen line

CURSOR CONTROLS
Key Function
^+
^*
^--
^=
^T
^B
^A
^Z
^W
^U
^D
^H
Move 1 character to left
Move 1 character to right
Move up one screen line
Move down one screen line
Jump to top of text
Jump to bottom of text
Jump to beginning of line
Jump to end of line
Jump one word to the right
Jump up 1 screen of text
Jump down 1 screen of text
Home cursor to upper left

The screen editor.
T:EDIT is a screen-oriented text editor, very much like AtariWriter. Because it's screen oriented, T:EDIT gives you a very natural programming environment. The screen editor in T:EDIT uses a word-wrap routine, so that none of the words will be broken on the right margin. This method is similar to that of most word processing packages, and makes the screen much easier for the user to read and comprehend.

The editing screen is twenty lines high and thirty-eight characters across. There are three lines at the bottom of the screen used to display information and ask for input. The first of the three lines is the cursor line. It contains the row and column position of the cursor on the editing screen, and the number of free bytes left for new text. The two following lines are the input/output lines used to display messages.

You may enter almost any character you wish into your document, except a few. No control characters are permitted, as they're reserved for commands; CTRL-COMMA, CTRL-PERIOD, CTRL-SEMICOLON and CTRL-CLEAR are not allowed. Uppercase, lowercase and all inverse video keys are allowed.

If you must insert any control characters into your text, you can do so by pressing SELECT and the key you want as a control. This method will only work for letters, such as CTRL-A. While in the editor, all control characters appear in a "tech-computer" font; these are larger and easy to distinguish from normal text.

Command description.
To use one of the commands in Table 1, simply type the correct key combination, given under the heading Key. In the table, the A character indicates that the CONTROL key is pressed with the letter after the A. SH indicates that you press and hold SHIFT; DS stands for DELETE-BACK-SPACE key; and < and > are the CLEAR and INSERT keys, respectively.

Before I describe all the commands, I'd like to tell you how to abort most. With any command that asks you for keyboard input, simply press the ESC key. The command will abort, and you can continue to edit your text. Some commands will ask you, Are you sure - Y/N? The only key that will give a yes response is Y key; any other key is taken as a no.

Load a text file (^L). This command allows you to load any standard ATASCII text file into memory. You'll be prompted for a filename, and, after you enter this, the current text file will be erased and the new file loaded. Once the loading begins, all text in memory is lost forever. If the load was successful you can edit the file. Otherwise, the message LOAD FILE ERROR will appear, and you must press a key to continue.

Save a text file (^S). This command permits you to save the text in memory to disk. You're asked for a filename, then the save begins. If the save is successful, you can continue to edit text; otherwise, the message SAVE FILE ERROR will appear, and you must press a key to continue to edit your text. This command will overwrite a disk file if it already exists, so be sure you've typed the correct filename.

Print a text file (^P). This command will print the file in memory to your printer, in 80-column format. If your printer's not on-line, the message PRINTER ERROR will appear at the bottom of the screen, and you must press a key to continue editing. Pressing BREAK during printing will halt the printing and force a PRINTER ERROR.

The print function will produce formatted output with no broken words on the right margin. It will skip the perforations between pages and number each page in the upper left-hand corner.

The print function will work on any 80-colunm printer, since it doesn't send any control codes to the printer. Because of this, you must have the paper at the top of form before you start printing, or else the page breaks won't be in the right places. If the end of text is reached before the end of a page, the print function will form feed to the top of the next page for you.

Since you can load any text file into T:EDIT, the print routine must be able to print anything. If you load a file from AtariWriter into T:EDIT it's embedded with various control characters having some meaning to AtariWriter - but none to T:EDIT. So the print routine will simply print all control characters as inverse uppercase characters. On most printers, these characters will come out as italics.

Print to Device (^M). This function is exactly the same as the print command, except that the text may be sent to any Atari device (barring only the E: and S: devices).

This is an extremely powerful feature, allowing one to make formatted disk files of text for uploading to the Delphi Atari User's Group. These files can then be downloaded and printed to any 80-column printer, with the DOS copy function.

Disk Directory (^X). When you select this command, you are asked: DIRECTORY FOR DRIVE - (1-2-3-4-8)? Respond by typing one of the numbers in the brackets (pressing any other key will abort). Then the screen will clear, and the directory of the chosen drive will be displayed in two-column format.

If the directory's longer than one screen, the message DIRECTORY PAUSED - PRESS A KEY will appear. Simply press any key (ESC to abort), and the screen will clear. The remaining portion of the directory will be displayed.

When the end of the directory is reached, the message DIRECTORY FINISHED - PRESS A KEY will appear. Just press a key to continue to edit your text.

If you attempt to get a directory from a drive that doesn't exist, or you press BREAK while the directory's being read, or you have no disk in the drive, you'll get a DIRECTORY ERROR. When you get this error, simply press any key to continue editing your text.

Global Search and Replace (^F). When this is executed, you're asked FIND WHAT? Respond with a string up to twenty-four characters in length and press RETURN. If the program finds the string, the screen will move to the beginning of the string, and the string's first character will be highlighted in inverse video. Then you're asked REPLACE STRING - Y/N? If you wish to do so, respond by pressing Y; otherwise, hit any other key to abort. If you pressed Y, you're asked REP. WITH? Type in your replacement string, up to twenty-four characters, and press RETURN. The program will then begin to replace all occurrences of the search string. Once a replace starts, it can't be stopped until it ends, so be careful. The search/replace will begin at the current cursor position and continue until the end of text is reached.

Erase text in memory (^C). This command will wipe out the text currently in memory. You're asked if you're sure about the erase. If you say yes, the document in memory is erased and you may enter a new one. Once text is erased, you can't recover it.

Toggle Insert Mode (^l). T:EDIT has two modes of operation, "replace" and "insert." Replace is the default mode. The insert mode is useful, but can get very slow if you're inserting at the top of a long document. To tell which mode you're in, the cursor line will be blue for replace mode and red for insert mode.

Show "false" spaces (^O). Pressing this key will cause any space used to word-wrap the screen to appear as a small dot. Pressing it again will make all "false" spaces blank again. This is a very useful command. It shows you which spaces are yours and which are generated for the word-wrap's sake.

Erase spaces (^E). This function will erase all spaces, from the cursor to the next non-space character. You'll see the use of this command later.

Change character case (^K or ^CAPS key). Pressing this key will cause the character under the cursor to be changed to uppercase if it was in lowercase, and vice versa. After this command executes, the cursor moves one character to the right.

Reverse two characters (^R). This command is for all the people out there who just love to make transposition errors. When you use it, the character under the cursor will be swapped with the character to the right of the cursor.

Quit T:EDIT (^Q). This command will exit you back to DOS. It will also erase your text, so you're asked if you're sure. If you answer yes, you'll go to DOS.

To re-enter T:EDIT from Atari DOS 2.0s, you can either reload it or perform a RUN AT ADDRESS, with the address being 9FFD. From OSS OS/A+ or from SpartaDOS, typing RUN or RUN 9FFD at the D1: prompt will restart T:EDIT.

Count Words in text (^N). When you press ^N, T:EDIT will count all the words in your text and display the number on the first I/O line at the bottom of the screen. This is a true word count, not faked by counting spaces and dividing by two, hence it's accurate to within one word of the actual number of words in memory. When the program is through counting, you're asked to press a key. Do so and you may edit more text.

Insert five spaces (TAB). Pressing the TAB key will insert five spaces into the text at the cursor position (not tab across the screen). This can be useful if you're in replace mode and want some space to insert a new word. The program can insert five spaces in the same amount of time it can insert one space, so this can be quite a time saver.

Delete back one character (DS). Pressing DELETE-BACKSPACE will delete the character to the left of the cursor and move the rest of the document up. Again, this can be slow with large documents.

Delete one character (^DS). This deletes the character under the cursor and moves the rest of the document up.

Insert one space (^>). This will move the document down and insert a space under the cursor.

Insert 255 spaces (SH-). If you must have a lot of room for new revisions, this is how you get it. The command will insert 255 spaces from the cursor's position in the time it takes to insert one space. If you find that you don't need all this space, simply press ^E to remove the remaining spaces.

Delete one screen line (SHDS). This will delete text from the cursor position to the end of the line the cursor's sitting on. Usually, this is anywhere between one and twenty characters.

A note about deleting text: deleted text is lost forever. Since the deletions are usually rather small, this doesn't cause too many problems. However, care should be taken before deleting anything.

Cursor movement.
T:EDIT uses the arrow keys (^+,^*,^-,^=) to move the cursor around the screen, much like the normal screen editor; with a few variations.

If you're at the bottom of the screen and try to go further down, a new line of text will appear. The same goes for trying to cursor off the top of the screen. If you try to go past the left margin, you wind up on the last character of the previous line. If you cursor past the last character on a line, the cursor is placed on the first character of the next line. There are other ways to move the cursor around within the document.

Jump to TOP of text (^T). This will place the cursor at the top of your text. The cursor is also in the "home" position. (The home position is the upper left corner of the screen).

Jump to BOTTOM of text (^R). This will move the cursor to the end of the document. It's placed after the last character in the document.

Moving on the line (^A, ^Z). ^A will place the cursor on the first character on the screen line. ^Z will place the cursor on the last.

Jump one word to the right (^W). This will move the cursor to the next word in the document. The command was included as a replacement for the TAB function.

Moving by screenfuls (^U, ^D). Pressing ^U will send the cursor home and move it back nineteen lines of text. Pressing ^D will move the cursor home, then bring it forward nineteen lines.

Homing the cursor (^H). ^H will move the cursor to the home position.

That finishes up the commands for T:EDIT. Now we'll look at some of the program's technical aspects.

Entering filenames.
T:EDIT allows you to load or save text from any disk drive or device. When you select either SAVE or LOAD, you're asked for a filename. You can respond in many ways. Here are some examples:

  1. filename.ext RETURN
  2. d2 :filename.ext RETURN
  3. C: RETURN
  4. E:filename.ext

In example (1), you simply enter a filename. T:EDIT will default to using drive 1 as the device. In (2), you specified drive number and filename; therefore, T:EDIT will use this device and name. In (3), we specified the device as the cassette drive. In (4), we tried to load/save text to the screen editor. If you try this to either the E: or S: devices, T:EDIT defaults to the D: device. This makes T:EDIT extremely powerful. So, if you want a simple rough text printout, just save it to the printer (P:). You won't get any page breaks or page numbers, but it can be useful.

T:EDIT has a smart filename handler. If your filename has any lowercase, control or inverse characters, they'll all be converted to normal video uppercase characters. Since you may enter up to twenty-four characters for a filename, the program can access text files stored in subdirectories with SpartaDOS or MYDOS version 4.0, thus making T:EDIT easier to use.

Technical notes.
The program uses a custom display list and display list interrupts (DLI's) to produce an attractive screen. The blinking underline used for the cursor was quite a little task to code.

The cursor works this way:

  1. We figure out which character's under the cursor and copy its definition to another character (in this case, character 127).
  2. Then we replace the character under the cursor with character 127.
  3. Now, simply blink the eighth bit in character 127 with an EOR #$FF. By doing this, you get a nice little cursor that looks really neat on a character with a descender, like a y or g.

All the text is stored in memory in internal code, for speed. If we store all text in internal code, there's no time needed to convert a screenful of text each time we redraw the screen. When text is saved, it's saved in ATASCII.

You'll notice that the DLI’s don't flicker during I/O operations. This is because the immediate mode vertical blank is used to copy the screen color shadow registers into their corresponding hardware registers.

I've found T:EDIT a very useful utility to have around. I hope you get as much use from it as I have.

© 2008 Bryan P. Schappel • Valid XHTML Transitional • Valid CSS