Breakout, the game the course builds in HiSoft C, running on the Tatung Einstein: coloured brick rows, the bat and the ball on a black court
← Back to Courses
module
5

The Editor

Introduction

In S4 you typed a program straight through and saved it. Programs are not written like that; they are written, read, and changed, and this section is the keys that let you move about a file and take things out of it. ED80 was HiSoft's programmer's editor for all CP/M machines, and it works the way WordStar did, which in 1985 meant the way everyone expected - with one difference on this disc that you have already met.

GRPH Is The Command Key

Most editors of the period used CONTROL and a letter for every command. ED80's manual does too, and lets you change any of them; on the course disc's copy they have been moved onto the GRPH key, so a command is GRPH held down and a letter. (In MAME: GRPH is F8.) If you hold CONTROL instead, ED80 takes the letter as text and puts ^E or the like into your program; DEL takes it out again.

While a two-key command is waiting for its second key, a ? appears in the status line.

Moving

KeysWhat it does
GRPH-S, GRPH-DLeft a character, right a character
GRPH-A, GRPH-FLeft a word, right a word
GRPH-E, GRPH-XUp a line, down a line
GRPH-CDown a screenful - on a short file, to the end
GRPH-Q then DTo the end of the line
GRPH-Q then RTo the start of the file
GRPH-Q then CTo the end of the file

The arrow keys will not do any of this: on the Einstein they type [, ] and ^ (S3).

Deleting

KeysWhat it does
DELDelete the character to the left of the cursor
GRPH-GDelete the character under the cursor
CTRL-YDelete the whole line

CTRL-Y is the one command on this copy that stayed on CONTROL. (In MAME: Ctrl and Y.)

Insert And Change

ED80 starts in insert mode: what you type goes in at the cursor and pushes the rest of the line along. GRPH-V switches to change mode, in which what you type overwrites what is there - useful for correcting one letter in the middle of a word - and GRPH-V again switches back. The status line says which you are in, when you can see it.

Auto-Indent

GRPH-O then I turns auto-indent on (I/AUTO appears in the status line) and off again. With it on, ENTER starts the next line under the first character of the one before, which is what you want in a program where most lines are indented like the one above. Every listing in this course is indented by four spaces inside main; with auto-indent on you type the four spaces once.

The Status Line

ED80 was written for an 80-column screen, and on the Einstein's 40 its top status line wraps round: the second half of it - the mode, and any message - is drawn over the first line of your text. Your text is still there, and scrolling the file by a line brings it back into view. It is a nuisance rather than a fault, and you will stop noticing it.

Help

GRPH-J shows a screen of ED80's commands - the ones above and the rest, including blocks and find-and-replace, which this course does not need. ENTER brings your file back.

Leaving

KeysWhat it does
GRPH-K then XSave and exit. ED80 shows Filename: with the file's name; ENTER accepts it. Any file already saved under that name is kept as .BAK
GRPH-K then QExit without saving. ED80 asks Abandon text: Sure?; Y and it is gone

There is no "save and stay". Save with GRPH-K X, and ED NAME.C again when you want to go on.

The Code

No new program. Open S4's again:

ED HELLO.C

and try every key in the tables above on it. Then leave with GRPH-K Q and Y, so that nothing you did is kept.

Starting from

The disc as S4 left it, with HELLO.C on it.

What you should see

The cursor moving as each table says; a ? in the status line after GRPH-Q, GRPH-K or GRPH-O until the second key; Abandon text: Sure? at the end, and 0: after Y.

Change One Thing

  • Put the cursor in the middle of Einstein, press GRPH-V, and type Tatung. What happens to the letters that were there? Press GRPH-V again and type it again.
  • Turn auto-indent on, put the cursor at the end of the printf line, and press ENTER. Where does the cursor land?
  • Hold CONTROL and press E. What appears, and what takes it away?

Exercises

5.1 Open HELLO.C, add a second printf line above the first using only GRPH-Q R, GRPH-X and ENTER to get there, and save it.

5.2 Open the same file, delete the line you added with CTRL-Y, and leave without saving. Then DISP HELLO.C and say why the line is still there.

Worked solutions are in Appendix II.

When It Goes Wrong

SymptomCause
^E, ^X or another ^ pair appears in the textCONTROL and a letter. The command key is GRPH. DEL removes it.
A ? sits in the status line and the next key does something oddA GRPH-Q, GRPH-K or GRPH-O was waiting for its second key.
The first line of the file seems to have vanishedIt is under the wrapped status line. GRPH-X and GRPH-E bring it back into view.
Typing overwrites instead of insertingGRPH-V was pressed. Press it again.
Filename: appears when you did not expect itGRPH-K X. ENTER saves under that name; DEL and retype to change it.

Summary

GRPH and a letter is a command: S/D/A/F/E/X/C move, G deletes, Q-D and Q-R and Q-C jump, V toggles change mode, O-I auto-indent, J help; DEL deletes left and CTRL-Y the line. GRPH-K X saves and exits, GRPH-K Q abandons. The status line wraps over the first text row on 40 columns.

Next

S6, What The Compiler Makes - the memory map read, why an empty program is 6K, and keeping the disc from filling up.

Get the Newsletter

New guides, disk images and community finds, roughly once a quarter. No spam, we promise, this isn't Tatung's marketing department.
Your subscription could not be saved. Please try again.
Your subscription has been successful.

Newsletter

Subscribe to our newsletter and stay updated.