The window above implements a version of Ecce similar to the version that
was used on the PDP9/15 systems in the late 70's. This demo implementation
is written in Javascript and is here just to let you try a few commands and
get a feel for the syntax. The C version which can be downloaded at this
site has been extended beyond the version above.
A brief introduction.
It is quite easy to learn how to use ECCE - half a dozen commands can get
you started, and the rest can be learned as you go along. Lets look at some
examples:
p Print the current line
m Move down a line
g Get a new line
k Kill the current line
'Move' is obvious...
'Get' gives you a ':' prompt, and you type a line of text at it.
When you press return, that line is inserted in your file.
'Kill' deletes the entire current line.
Two more concepts are needed and you will be able to edit any file with these
commands: firstly, if you put a number after a command, the command will be
executed that number of times, e.g.
p23 Print the next 23 lines
m10 Move down ten lines
g5 Make space for and accept 5 new lines of text
Secondly, any command which can sensibly be done in reverse (such as Move)
will do so if invoked with a '-', as in:
m-10 Move back up 10 lines
These are the simplest commands of ECCE, and let you get started editing a
file. Lots of editors look like this, and there is nothing really special
here. Here are a few others which are self-explanatory and the sort of thing
you will be used to in your own editor.
i/text/ Insert a text string here in the line.
f/text/ Find the quoted text.
r Move Right one character on the current line
l ditto Left
e Erase one character on this line
Similarly, all these can take repeat counts where appropriate:
f/text/4 Find the 4th occurance of "text"
r40 Move Right 40 characters
And can be strung together quite happily:
m23 f/text/ p3
Where ECCE comes in to its own is in its more advanced features:
Failures, Conditionals, and Repeat groups.
Any of the commands above can fail - for instance, if you try to print 25
lines, and you are only ten lines from the end of the file, then the print
command will fail with an error after those ten lines have been printed.
The smart bit about ECCE is that it allows you to test for such a failure,
and if one has happened, let you do something else instead. The epitome of
this condition testing is the Verify command:
v/text/ Verify that the quoted text is at the
current point in the line.
This command does nothing at all if the text is present, and does nothing but
issue a failure message if it is not!
However, rather than print a failure message and abandon the command, we
can test whether the command worked and do something else instead.
v/text 1/ i/First text: /, i/Not first text: /
Finally the above can be executed multiple times by enclosing any
command in brackets, such as:
r0 (l v/ / e)*
which will remove all trailing spaces from a line, and
m-* (r0 (l v/ /e)* m, m)*
will remove all trailing spaces from all lines in the file.
Experienced ECCE users will have a repertoire of these combined sequences
which they can routinely used to perform complex edits. For instance the
following will align all "//" comments in a C++ file to column 50:
(f.//. l50m, l0f1.//. i/ /50l0r50(v/ /e)0 m, m)0
Once you get to the stage that you understand the line above on first
reading, you can award yourself an Ecce Certificate of Merit, and
I have nothing more I can teach you!
Ecce was written by Hamish Dewar
This document was written by Graham Toal