Ted, the text editor

The initial implementation of the text editor compiled with no great difficulty. The I/O routines written for the Ratfor preprocessor were used and the pattern matching routines were extracted from the FIND and CHANGE programs.

The limitations of this implementation soon became obvious - all text is held in a linked list in memory, and no attempt is made to reclaim the space used by lines that are deleted or changed.

I decided to make a version based on the "scratch file" implementation of the editor described in the book, with some significant changes:

The heart of the implementation consists of two routines, findtxt and spacefor:

findtxt

findtxt returns the address in the buffer for a given line. If the text is being held in the buffer its simple, but if the text is in the scratch file there are three cases:
  1. The text is in the block currently being written - it's address is returned. (The block being written is held in the top of the buffer).
  2. The text is in the block last read - it's address is returned (the last block read is held in the next 512 words of the buffer).
  3. Otherwise the appropriate block is read into the read part of the buffer and its address is returned.

spacefor

spacefor allocates space in the buffer to hold a new line.
  1. If the text is currently being held in memory and there is enough space available its address is returned.
  2. If there is not enough space in memory a garbage collection is launched. If the garbage collection frees enough space then it is returned, otherwise the text is copied to the scratch file.
  3. If the text is in the scratch file and there is enough space in the block currently being written it is returned.
  4. Otherwise the block is written out to the scratch file, making enough space available.

Installation

To install ted download the NEWCOPYIN source tape, (5250003,EDITTAPE), then:
  1. Copy the tape image to your tapes directory.
  2. On George, create a new directory, and make it the current directory:
    10.46.01← MK EDIT
    10.46.02← DY EDIT
    
  3. Use NEWCOPYIN to read the file NEWCOPYINPAR from the tape, then copy in all the files listed in NEWCOPYINPAR:
    10.46.03← NEWCOPYIN (5250003),TRAPOPEN
    ← NEWCOPYINPAR
    ← ****
    ...
    10.46.04← NEWCOPYIN (5250003),TRAPOPEN,*CR NEWCOPYINPAR
    ...
    10.46.05← 
    
  4. Run the macro MAKEEDIT (in a background job if you feel like it).
    10.46.06← RJ EDITJOB,MAKEEDIT
    
  5. When the compilation has finished log in as user :LIB and run the macro INSTALL in the directory:
    10.46.07← LN :LIB,EDITMOP
    PASSWORD← XXXX
    10.46.08← DY :XXXX.EDIT
    10.46.09← INSTALL
    
  6. Now log in as MACROS and re-run the install script:
    10.46.07← LN :MACROS,EDITMOP
    PASSWORD← XXXX
    10.46.08← DY :XXXX.EDIT
    10.46.09← INSTALL
    
That's it, now the editor is installed.

The macro TED takes the file to be edited as the first argument (which may be omitted to start TED with an empty buffer) and optionaly an edit script as the 2nd argument.