-
Notifications
You must be signed in to change notification settings - Fork 80
/
teco.primer
executable file
·344 lines (287 loc) · 10.6 KB
/
teco.primer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
AN ANNOTATED OUTLINE OF TECO COMMANDS
*************************************
META-NOTATION
=============
|x Denotes the single character, control-x.
| Used alone to denote alternation.
m | n | arg Integer arguments.
string String argument.
cmd A command string.
$ Denotes the character altmode unless mentioned otherwise.
k Denotes either "m,n", or "n"; a text range of characters m through
n, or n lines.
file Denotes a file name pair, e.g., "FOO BAR".
dir Denotes a device and directory specification, e.g., "DSK: USERS;".
SPECIAL CHARACTERS
==================
|G Quit to TECO top-level; cancels partial command line.
|Z Interrupt to DDT.
altmode Terminates text argument; two successive altmodes terminate
command string.
rubout Deletes last character typed in.
QUOTE
-----
|Q Quote next character.
MODIFIERS
---------
: | ^ Prefix to certain commands, modifies them.
LOGICAL CONNECTIVES
-------------------
& Logical and, an arithmetic operator.
# Inclusive or, an arithmetic operator.
|A Exclusive or, an arithmetic operator.
ARITHMETIC
----------
0-9 Digits: xxxx is interpreted in base FS IBASE$ (10)
xxxx. is interpreted in base FS I.BASE$ (8)
+ Addition, an arithmetic operator.
space Same as "+", except that space, by itself, is not a non-null arg.
- Subtraction, an arithmetic operator.
* Multiplication, an arithmetic operator(with no operator precedence).
/ Division, an arithmetic operator(with no operator precedence).
( | ) Parentheses, grouping in arithmetic expressions.
ARGUMENT SEPARATOR
------------------
, Separates numerical arguments.
THE BUFFER
==========
. Value is number of char to left of pointer.
Z Value is number of char in buffer*.
H Equivalent to "B,Z", i.e., specifies whole buffer*.
B Value is 0, i.e., beginning of buffer*.
*Meaning is modified by use of virtual boundaries.
INSERTING
---------
Istring$ Insert string in buffer to left of pointer.
^Ixstringx Insert string delimited by char x to left of pointer.
nI Insert the char with ASCII code n.
m,nI Insert m copies of the char with code n.
tab Horizontal tab, self-inserting character.
backspace Backspace, self-inserting character.
n\ Insert printed representation of n (in base ..E).
|^ Value = ASCII code of next char in cmd.
FI Read one char from TTY and return its ASCII code as value.
ASCII
-----
mA Value = ASCII code of char m positions to right of ptr.
0A => char to immediate left of ptr.
UPPER-CASE/LOWER-CASE
---------------------
F$ Controls case conversion on input/output ($ => dollar).
kFC Convert text range k to lower-case.
MOVING AROUND
-------------
ABSOLUTE POSITION
-----------------
mJ Position ptr to after m-th char in buffer.
RELATIVE CHARACTER POSITION
---------------------------
mR Move ptr left m char; R => 1R, -mR => mC.
m:R Same as mR but returns -1(move OK) or 0(if move would cause an error).
mC Move ptr right m char; C => 1C.
m:C Returns value like m:R.
\ Move ptr right over number, return number's value.
LINE POSITION
-------------
mL Move ptr to beginning of m-th line after current position;
0L => beginning of current line.
m,nL Same as m+n-.J, used by FW, etc.
m:L Do mL, then backup over CR-LF; :l => end of current line.
WORD POSITION
-------------
nFW Returns ".,m", a buffer range where m is the position immediately after
the n-th word(contiguous string of non-delimiters; see ..D, the delimiter
dispatch table).
-nFW Returns "m,.", the range to the left.
n:FW Same as FW, but stops before the n-th word; i.e., n:FWL = nFWL-FWL.
n^FW Same as FW, but finds LISP atoms, not words.
nFWL Do an nFW, yielding ".,m", move to m (=m+.-.J).
nFWR Same as nFWL.
LIST POSITION
-------------
nFL Returns ".,m", where m is the position immediately after the
n-th list to the right.
-nFL Returns "m,.", the range to the left.
n^FL Same as nFL, but finds S-expressions, not lists.
nFU Returns ".,m", where m is the position immediately after the n-th
level up in parentheses to the right.
-nFU Same as nFU, but returns "m,.", and works to the left.
nFD Returns ".,m", where m is the position immediately after the n-th
level down in parentheses to the right.
-nFD Same as nFD, but returns "m,.", and works to the left.
nFLL Does nFL, yielding ".,m", moves to m.
nFLR Same as nFLL.
DELETING
--------
ABSOLUTE POSITION
-----------------
m,nK Kill chars in the range m,n. Move ptr there.
CHARACTER
---------
nD Delete n chars to right of ptr.
-nD Delete n chars to left of ptr.
LINE
----
nK Kill chars from . to position nL would have moved to.
K => 1K, kill to beginning of next line.
n:K Kill chars from . to position n:L would have moved to.
:K => 1:K, kill to end of current line.
WORD
----
nFWK Do an nFW returning ".,m"; kill chars in this range.
nFWD Same as nFWK.
LIST
----
nFLK Do an nFL returning ".,m"; kill chars in this range.
nFLD Same as nFLK.
TYPE-OUT
========
kT Type out text in range k (n lines or m,n chars).
kV Display text in range k on CRT.
FTstring$ Types its string argument.
FVstring$ Displays its string argument.
kVW Does kV, then waits for TTY input of one char whose ASCII code
is returned as value.
k= Types out k ("n" or "m,n") in current output radix(in ..E).
SEARCH
======
nSstring$ Find n-th occurrence of string searching forward and position ptr after it.
-nSstring$ Same as nSstring$, but search backward and position ptr before n-th string.
n^Sxstringx Same as nSstring, where string is delimited by any char x.
n:Sstring$ Same as nSstring$, but returns value = -n if successful, 0 if not.
Special chars in string:
|B Matches any delimiter(see ..D).
|Nx Matches any char but x.
|O Divides string into alternate patterns.
|Qx Quotes x.
|X Matches any char.
nNstring$ Same as nSstring$, but does P if end of buffer is reached.
n_string$ Same as nSstring$, but does Y if end of buffer is reached.
kFBstring$ Same as Sstring$ in the search domain defined by k; for k = m,n where
m>n, search backwards; ":" and "^" modifiers work.
FK Returns value = - FS INSLEN$ = - length of last string inserted, or found
by search or FW. FK < 0 except for backward search or FW.
SORT
====
|Pcmd0$cmd1$cmd2$ ASCII sort command, with the following algorithm:
Move ptr to start of buffer;
..0 := cmd0; ..1 := cmd1; ..2 := cmd2;
Iterate:
Ptr is at start of next record;
Cmd0 moves ptr to start of key;
Cmd1 moves ptr to end of key;
Cmd2 moves ptr to end of record;
Do a sort of records based on keys;
Notes: Dollar signs in the cmdi are replaced by altmodes.
If FS ^P CASE$ .NEQ. 0, then |P ignores case.
FILES
=====
DIRECTORIES
-----------
ETfile$ Set default filenames to file.
EL Type out listing of default directory.
EYdir$ Same as EL, but with specified device and sname.
EM Insert listing of default directory in buffer.
EZdir$ Same as EM, but with specified device and sname.
OPEN READ
---------
ERfile$ Opens file for input.
EPfile$ Does ERfile$, then bigprints filename twice on device open for writing.
OPEN WRITE
----------
EI Open a file "_TECO_ OUTPUT" for writing on default device and sname.
0EI Same as EI, but sets default device to DSK:.
:EI Same as EI, but uses current filename defaults rather than "_TECO_ OUTPUT".
EWdir$ Same as EI, but with specified device and sname.
:EW dir file$ Same as EW, but also with specified filenames.
INPUT
-----
Y Kills the buffer; inserts one page from current input file into buffer.
^Y Kills the buffer; yanks the entire input file into buffer.
A Append next page of input file to buffer (no arg allowed).
n:A Append n lines or up to page boundary of input file to buffer.
^A Append all of input file, and close file.
nP Output buffer and "|L", kill buffer, read one page from input file;
all done n times.
OUTPUT
------
nP See description above under input.
m,nP Output specified range of buffer, but do not clear it or input.
nPW Output buffer and "|L", but do not clear it or input; done n times.
EEfile$ Same as "infinityP EFfile$ EC".
CLOSE
-----
EFfile$ Close the output file and change its name to "file".
EC Close the input file.
DELETE
------
EDfile$ Delete the file.
COPY
----
E_old$new$ Make a copy of file "old" and name it "new".
LINK
----
EQfrom$to$ Create a link named "from" pointing to the file "to".
RENAME
------
ENold$new$ Rename the file "old" to have name "new".
Q-REGISTERS
===========
:Iqstring$ Insert string into Q-reg q, replacing prior contents.
n:Iq Insert char with ASCII code n into Q-reg q, replacing prior contents.
^:Iqxstringx Same as :Iqstring$, where string is delimited by any char x.
m,n:Iq Same as n:Iq, but inserts m copies of char.
nUq Inserts number n in Q-reg q; returns no value.
m,nUq Inserts number n in Q-reg q; returns m.
kXq Inserts text range k into Q-reg q, replacing prior contents.
k^Xq Same as kXq, but appends text to q's contents.
kFXq Same as X and K combined, i.e., "kXq kK".
nFWXq Combines nFW with Xq.
nFLXq Combines nFL with Xq.
Gq Inserts text (or decimal representation of number) from Q-reg q into buffer.
FS INSLEN$ is set to length of inserted string.
%q Increments numeric contents of Q-reg q and returns result.
[q Push text or number from Q-reg q onto Q-reg push-down list.
]q Pop text or number from Q-reg push-down list into Q-reg q.
FQq Value = number of char in Q-reg q or -1 if a number.
MACROS
======
EXECUTE
-------
m,nMqstring$ Execute string or buffer contents of Q-reg q as a TECO command. If q
contains a number, execute the corresponding |R-mode character.
ARGUMENTS
---------
|X Value is m, first arg to m,nMq. Only used inside macros.
|Y Value is n, second arg to m,nMq (or only arg to nMq).
F|X Value is all args to kMq.
F|Y Value is number of args to kMq.
|]|X Reads and returns string arg which follows kMq.
ITERATION
---------
n< cmd > Command is executed n times, or indefinitely if n is null.
n; Does nothing if n<0, otherwise passes control to char after next ">",
i.e., terminates iteration. Null n => use value of last search.
TEST AND BRANCH
---------------
arg"x then-cmd '"# else-cmd '
Conditional which checks arg according to condition x; discards arg;
executes then-cmd if condition was true, else-cmd if false.
arg"x then-cmd '
Conditional without else-cmd.
argF"x Same as arg"x, but passes first arg to then-cmd or else-cmd.
Note: The conditions x are:
B Arg is ASCII code for a delimiter(see ..D).
C Arg is ASCII code for a non-delimiter.
E Arg = 0.
G Arg > 0.
L Arg < 0.
N Arg .NEQ. 0.
TAG
---
!label! Defines label, or brackets comments.
GOTO
----
Olabel$ Sends command execution to character after !label!.
Compiled by: Mike Wirth (MCW@MIT-MC)
Oct. 29, 1976