INTRODUCTION TO TEXT EDITING

ECCE is a text editor. Under the control of commands entered from a terminal keyboard, it carries out modifications to a body of text held in a computer file. This text file may be, for example, a source program in some high-level language, or tables of results generated by a statistical package, or data intended as input to a user's program; it may simply be material which is held in the computer filing system solely for the purposes of editing and listing. The differences between these kinds of text files are not in any way significant to the operation of the Editor. What ECCE cannot do is edit files which are not composed of lines of text, such as executable code files.

Text files

A text file consists of a number of lines, each line containing a number of characters. The characters making up a line are either printing characters or space characters. There is no need when typing in lines on a computer terminal, any more than on a conventional typewriter, to 'space' after the last printing character on a line, in order to pad lines out to a particular fixed length; RETURN suffices to mark the end of the line. The Editor regards lines as being of variable length, usually ending with the last printing character. Hence 'white' space at the right-hand end of a line is not part of the line, in the way that space at the left or within the line is, being made up of individual space characters (corresponding to depressions of the space-bar).
Although these make no impact on the printed page or video screen, they are just as significant for editing as other characters. For example, the line: longing for those wide open spaces would look like this if the spaces were replaced by ampersands: &&&longing&&&for&those&&wide&open&&&&&&spaces A blank line is an empty line; that is, it contains no characters, not even spaces. Blank lines are just as significant for editing as other lines. The main function of the Editor is to enable the terminal user to make alterations to a file held within the computer system, but it may also be used to create a new file from scratch or simply to inspect a file without altering it.

The file pointer

The operation of the Editor is directed by a series of commands which are carried out one after the other in the order typed. The effect of most commands depends partly on the position of a notional pointer which identifies the 'current position reached' in the file. Initially the file pointer is positioned at the start of the first line in the file. It may be moved along lines and down from one line to the next. It may be positioned at the start of any line, between any two characters on a line, or at the end of a line. It may also be positioned at the very end of the file, that is, after the last line of text.
Many commands have no effect other than that of re-positioning the file pointer. The usual direction of movement is forwards, that is, from left to right along a line and downwards from one line to the next, but there are also commands which move the pointer backwards in the file. Commands which simply move the file pointer around will be called location commands; commands which actually change the material in the file will be called alteration commands. The typical pattern of use of the Editor is to go progressively through the file, using whatever location commands are most convenient to reach the next point at which a correction is required, and then use one or more alteration commands to effect the correction.

Feedback

ECCE commands are usually typed on-line, that is, in interactive mode. After the execution of each complete command, some feedback is provided to the user. This enables the user to confirm whether the command has had the effect intended, before issuing the next command. The nature of the feedback depends on whether the Editor is being used from a hard-copy (printing) device or from a video terminal. As editors are increasingly being accessed in the latter way, the emphasis in most of this document is on that case. It is hoped that users of hard-copy devices (or videos used as hard-copy devices) will be able to ignore or re-interpret parts of the description which are not relevant to this mode of access.

Video feedback

In the case of videos, feedback is in the form of a 'window' displaying a group of consecutive lines in the file. As successive commands are executed, the window is updated so that it always includes the current line and so that the position of the pointer is indicated. Unfortunately video terminals vary considerably in terms of their capabilities and the way they are controlled. In consequence the fashion in which the window is updated and the pointer is displayed varies from terminal to terminal, and a particular implementation of the Editor will support only a particular selection of video terminals; others may have to be used as if they were hard-copy devices. The size of the window used for video feedback varies between a minimum and maximum number of lines, within a screen region which may be specified by the user. Whenever editing moves to a fresh site in the file, the display is completely re-written, with a minimum size window. Moving off the bottom or top of the window causes the window to be extended, when this is possible.
A line which exceeds the window width is truncated rather than wrapped round on the display. The invisible characters can still be edited. For purposes of printing or display, the end of the file is shown as an extra line, beyond the last genuine line, in the form: **END** This line does not actually exist in the file and therefore cannot be edited.

Hard-copy feedback

In the case of printing terminals (or videos used as hard-copy devices), the feedback consists of printing out the current line, with the position of the file pointer indicated by insertion of a circumflex character (up-arrow on some terminals). However, this extra character is not included when the pointer is at the start of the line. Thus: here the file pointer is splitting ha^irs and: here it is at the end of the line^ but: here it is at the start of the line With slow terminals, it can be excessively time-consuming if the current line is printed out after every command is executed and there are options which may be selected to reduce the frequency of output.

Editing modes

There are two modes in which the Editor may be used from a video terminal, and the user may switch freely between them. They are command mode and data-entry mode. In command mode, the ordinary printing keys are used to enter strings of characters to be interpreted as editing commands; in data-entry mode, these keys are used to enter text as part of the file. In the latter mode, the actual video cursor indicates the position of the Editor's file pointer, by highlighting the character immediately to the right of the pointer; (recall that the Editor's pointer is understood to lie between a pair of characters).
However, in command mode (in most implementations), the actual video cursor is pre-empted for use in the command region of the screen and a variety of alternative means are used to indicate the position of the Editor's file pointer within the file region. This may be in the same form as the video cursor but the choice is limited by terminal capabilities. Often reduced or increased intensity has to be used; in this case, a vertical bar is displayed if the character to the right of the pointer is a space or the pointer is at the end of the line. For terminals lacking the capability to highlight an arbitrary character position in any way, the pointer is shown as a circumflex (or other marker character) temporarily overwriting the character to the left of the pointer, and an extra column is added at the left of each line for use when the pointer is at the start of the line.

Control keys

It is part of the philosophy of ECCE that all the editing commands should be accessible from any terminal, using just conventional printing characters and the line-terminator RETURN. No assumption is made about the availability of special control keys on the terminal keyboard. However, where a terminal is fitted with special keys, such as cursor controls, function keys, or switchable numeric pad, these keys are usually available as more convenient ways of entering frequently required commands. Alphabetic keys used in conjunction with the CONTROL shift available on most terminals may also be used in this way. All such keys, or key combinations, will be referred to as control keys. The particular advantage of control keys is that they are immediate in their effect; they do not require a following RETURN.
Technically, these keys are MACROS. Macros are described in detail in a separate section but the basic principle is that a single key can be made to stand for an arbitrary command or command sequence. Initial definitions for some of the keys are pre-set on entry to the Editor; the interpretation of these may be freely altered, and others defined, at any time. This is part of a general capability to extend the repertoire of the Editor by means of user-defined commands. Because of the fact that the interpretation of control keys is not fixed and because of the considerable variation in what is available on different terminals, it is not possible to provide an enumeration of their functions here, despite the fact that they often provide the most convenient access to certain editing facilities.
One control key which is always available is RETURN, which when used by itself in command mode is defined to cause a Move to the next line in the file. If cursor control keys are available, these will in general be associated with the Editor commands Cursor Up, Cursor Down, Cursor Left and Cursor Right. In many implementations the LF key is defined to cause repetition of the last command and the TAB key to cause a move to the next word in the file. It should be noted that the possibility of using control keys depends on appropriate support being available in the terminal handling software, so that they may not be usable in all modes of connection. In addition, some control keys have a reserved significance for the operating system and it is advisable to find out what these are sooner rather than later.
One function which, as an exception to the general rule, cannot be invoked except by a control key is that of switching between command mode and data-entry mode. The restriction is solely to ensure that if data-entry mode can be entered, it can be left, since in this mode none of the printing characters has a command significance. The key enquiry command (%Q) which is described in the section on MACROS provides a means of investigating the significance of both control and ordinary keys.