annotate lisp/emulators/teco.el @ 108:360340f9fd5f r20-1b6

Import from CVS: tag r20-1b6
author cvs
date Mon, 13 Aug 2007 09:18:39 +0200
parents b9518feda344
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; teco.el --- Teco interpreter for Gnu Emacs, version 1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
3 ;; Author: Dale R. Worley.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
4 ;; Keywords: emulators
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
5
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
6 ;; This file is part of XEmacs.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
7
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
8 ;; XEmacs is free software; you can redistribute it and/or modify it
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
9 ;; under the terms of the GNU General Public License as published by
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
11 ;; any later version.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
12
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
13 ;; XEmacs is distributed in the hope that it will be useful, but
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
16 ;; General Public License for more details.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
17
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
18 ;; You should have received a copy of the GNU General Public License
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
19 ;; along with XEmacs; see the file COPYING. If not, write to the Free
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
20 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
21 ;; 02111-1307, USA.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
22
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
23 ;;; Synched up with: Not in FSF
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
24
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
25 ;;; Commentary:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
26
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; This code has been tested some, but no doubt contains a zillion bugs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; You have been warned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; Written by Dale R. Worley based on a C implementation by Matt Fichtenbaum.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; Please send comments, bug fixes, enhancements, etc. to drw@math.mit.edu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; Emacs Lisp version copyright (C) 1991 by Dale R. Worley.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; Do what you will with it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; Since much of this code is translated from the C version by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; Matt Fichtenbaum, I include his copyright notice:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; TECO for Ultrix. Copyright 1986 Matt Fichtenbaum.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; This program and its components belong to GenRad Inc, Concord MA 01742.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; They may be copied if this copyright notice is included.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; To invoke directly, do:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; (global-set-key ?\C-z 'teco-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; (autoload teco-command "teco"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; "Read and execute a Teco command string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; t nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; Differences from other Tecos:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; Character positions in the buffer are numbered in the Emacs way: The first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; character is numbered 1 (or (point-min) if narrowing is in effect). The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; B command returns that number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; Ends of lines are represented by a single character (newline), so C and R
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; skip over them, rather than 2C and 2R.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; All file I/O is left to the underlying Emacs. Thus, almost all Ex commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; are omitted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; Command set:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; NUL Not a command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; ^A Output message to terminal (argument ends with ^A)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; ^C Exit macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; ^C^C Stop execution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; ^D Set radix to decimal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; ^EA (match char) Match alphabetics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; ^EC (match char) Match symbol constituents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; ^ED (match char) Match numerics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; ^EGq (match char) Match any char in q-reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; ^EL (match char) Match line terminators
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; ^EQq (string char) Use contents of q-reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; ^ER (match char) Match alphanumerics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; ^ES (match char) Match non-null space/tab
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; ^EV (match char) Match lower case alphabetic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; ^EW (match char) Match upper case alphabetic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; ^EX (match char) Match any char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; ^G^G (type-in) Kill command string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; ^G<sp> (type-in) Retype current command line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; ^G* (type-in) Retype current command input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; TAB Insert tab and text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; LF Line terminator; Ignored in commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; VT Ignored in commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; FF Ignored in commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; CR Ignored in commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; ^Nx (match char) Match all but x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;; ^O Set radix to octal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; ^P Find matching parenthesis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; ^Q Convert line argument into character argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; ^Qx (string char) Use x literally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; n^R Set radix to n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; :^R Enter recursive edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; ^S -(length of last referenced string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; ^S (match char) match separator char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; ^T Ascii value of next character typed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; n^T Output Ascii character with value n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; ^U (type-in) Kill command line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; ^Uq Put text argument into q-reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; n^Uq Put Ascii character 'n' into q-reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; :^Uq Append text argument to q-reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; n:^Uq Append character 'n' to q-reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; ^X Set/get search mode flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; ^X (match char) Match any character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;; ^Y Equivalent to '.+^S,.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;; ^Z Not a Teco command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;; ESC String terminator; absorbs arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; ESC ESC (type-in) End command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;; ^\ Not a Teco command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;; ^] Not a Teco command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; ^^x Ascii value of the character x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;; ^_ One's complement (logical NOT)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;; ! Define label (argument ends with !)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; " Start conditional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;; n"< Test for less than zero
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;; n"> Test for greater than zero
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;; n"= Test for equal to zero
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;; n"A Test for alphabetic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;; n"C Test for symbol constituent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;; n"D Test for numeric
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; n"E Test for equal to zero
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;; n"F Test for false
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;; n"G Test for greater than zero
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;; n"L Test for less than zero
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;; n"N Test for not equal to zero
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;; n"R Test for alphanumeric
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;; n"S Test for successful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;; n"T Test for true
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; n"U Test for unsuccessful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; n"V Test for lower case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;; n"W Test for upper case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;; # Logical OR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; $ Not a Teco command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; n%q Add n to q-reg and return result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; & Logical AND
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; ' End conditional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; ( Expression grouping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;; ) Expression grouping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; * Multiplication
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; + Addition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; , Argument separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; - Subtraction or negation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;; . Current pointer position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;; / Division
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;; 0-9 Digit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;; n< Iterate n times
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;; = Type in decimal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;; := Type in decimal, no newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;; = Type in octal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;; := Type in octal, no newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;; = Type in hexadecimal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;; := Type in hexadecimal, no newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;; :: Make next search a compare
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;; > End iteration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;; n:A Get Ascii code of character at relative position n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;; B Character position of beginning of buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;; nC Advance n characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;; nD Delete n characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;; n,mD Delete characters between n and m
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; Gq Get string from q-reg into buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;; :Gq Type out q-reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; H Equivalent to 'B,Z'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;; I Insert text argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; nJ Move pointer to character n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;; nK Kill n lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; n,mK Kill characters between n and m
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;; nL Advance n lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;; Mq Execute string in q-reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;; O Goto label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;; nO Go to n-th label in list (0-origin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; Qq Number in q-reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; nQq Ascii value of n-th character in q-reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;; :Qq Size of text in q-reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; nR Back up n characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;; nS Search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;; nT Type n lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;; n,mT Type chars from n to m
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;; nUq Put number n into q-reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;; nV Type n lines around pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;; nXq Put n lines into q-reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;; n,mXq Put characters from n to m into q-reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;; n:Xq Append n lines to q-reg q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;; n,m:Xq Append characters from n to m into q-reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;; Z Pointer position at end of buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;; [q Put q-reg on stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;; \ Value of digit string in buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;; n\ Convert n to digits and insert in buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;; ]q Pop q-reg from stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; :]q Test whether stack is empty and return value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;; ` Not a Teco command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;; a-z Treated the same as A-Z
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;; { Not a Teco command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; | Conditional 'else'
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 72
diff changeset
189 ;; } Not a Teco command
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;; ~ Not a Teco command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;; DEL Delete last character typed in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
194 ;;; Code:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
195 (require 'backquote)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
196
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;; set a range of elements of an array to a value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (defun teco-set-elements (array start end value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (let ((i start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (while (<= i end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (aset array i value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (setq i (1+ i)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; set a range of elements of an array to their indexes plus an offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (defun teco-set-elements-index (array start end offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (let ((i start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (while (<= i end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (aset array i (+ i offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (setq i (1+ i)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (defvar teco-command-string ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 "The current command string being executed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (defvar teco-command-pointer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 "Pointer into teco-command-string showing next character to be executed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (defvar teco-ctrl-r 10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 "Current number radix.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (defvar teco-digit-switch nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 "Set if we have just executed a digit.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (defvar teco-exp-exp nil
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 72
diff changeset
224 "Expression value preceding operator.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (defvar teco-exp-val1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 "Current argument value.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (defvar teco-exp-val2 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 "Argument before comma.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (defvar teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 "t if argument is present.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (defvar teco-exp-flag2 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 "t if argument before comma is present.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (defvar teco-exp-op nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 "Pending arithmetic operation on argument.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (defvar teco-exp-stack nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 "Stack for parenthesized expressions.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (defvar teco-macro-stack nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 "Stack for macro invocations.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (defvar teco-mapch-l nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 "Translation table to lower-case letters.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (setq teco-mapch-l (make-vector 256 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (teco-set-elements-index teco-mapch-l 0 255 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (teco-set-elements-index teco-mapch-l ?A ?Z (- ?a ?A))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (defvar teco-trace nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 "t if tracing is on.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (defvar teco-at-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 "t if an @ flag is pending.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (defvar teco-colon-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 "1 if a : flag is pending, 2 if a :: flag is pending.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (defvar teco-qspec-valid nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 "Flags describing whether a character is a vaid q-register name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 3 means yes, 2 means yes but only for file and search operations.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (setq teco-qspec-valid (make-vector 256 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (teco-set-elements teco-qspec-valid ?a ?z 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (teco-set-elements teco-qspec-valid ?0 ?9 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (aset teco-qspec-valid ?_ 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (aset teco-qspec-valid ?* 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (aset teco-qspec-valid ?% 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (aset teco-qspec-valid ?# 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (defvar teco-exec-flags 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 "Flags for iteration in process, ei macro, etc.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (defvar teco-iteration-stack nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 "Iteration list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (defvar teco-cond-stack nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 "Conditional stack.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (defvar teco-qreg-text (make-vector 256 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 "The text contents of the q-registers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (defvar teco-qreg-number (make-vector 256 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 "The number contents of the q-registers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (defvar teco-qreg-stack nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 "The stack of saved q-registers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (defconst teco-prompt "*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 "*Prompt to be used when inputting Teco command.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (defconst teco-exec-1 (make-vector 256 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 "Names of routines handling type 1 characters (characters that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 part of expression processing).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (defconst teco-exec-2 (make-vector 256 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 "Names of routines handling type 2 characters (characters that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 not part of expression processing).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (defvar teco-last-search-string ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 "Last string searched for.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (defvar teco-last-search-regexp ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 "Regexp version of teco-last-search-string.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (defmacro teco-define-type-1 (char &rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 "Define the code to process a type 1 character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 Transforms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (teco-define-type-1 ?x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 code ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (defun teco-type-1-x ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 code ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 and does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (aset teco-exec-1 ?x 'teco-type-1-x)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (let ((s (intern (concat "teco-type-1-" (char-to-string char)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (` (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (defun (, s) ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (,@ body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (aset teco-exec-1 (, char) '(, s))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (defmacro teco-define-type-2 (char &rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 "Define the code to process a type 2 character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 Transforms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (teco-define-type-2 ?x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 code ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (defun teco-type-2-x ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 code ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 and does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (aset teco-exec-2 ?x 'teco-type-2-x)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (let ((s (intern (concat "teco-type-2-" (char-to-string char)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (` (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (defun (, s) ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (,@ body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (aset teco-exec-2 (, char) '(, s))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (defconst teco-char-types (make-vector 256 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 "Define the characteristics of characters, as tested by \":
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 1 alphabetic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 2 alphabetic, $, or .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 4 digit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 8 alphabetic or digit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 16 lower-case alphabetic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 32 upper-case alphabetic")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (teco-set-elements teco-char-types ?0 ?9 (+ 4 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (teco-set-elements teco-char-types ?A ?Z (+ 1 2 8 32))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (teco-set-elements teco-char-types ?a ?z (+ 1 2 8 16))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (aset teco-char-types ?$ 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (aset teco-char-types ?. 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (defconst teco-error-texts '(("BNI" . "> not in iteration")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 ("CPQ" . "Can't pop Q register")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 ("COF" . "Can't open output file ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ("FNF" . "File not found ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 ("IEC" . "Invalid E character")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ("IFC" . "Invalid F character")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 ("IIA" . "Invalid insert arg")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 ("ILL" . "Invalid command")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 ("ILN" . "Invalid number")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ("IPA" . "Invalid P arg")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 ("IQC" . "Invalid \" character")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 ("IQN" . "Invalid Q-reg name")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 ("IRA" . "Invalid radix arg")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 ("ISA" . "Invalid search arg")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 ("ISS" . "Invalid search string")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 ("IUC" . "Invalid ^ character")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 ("LNF" . "Label not found")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 ("MEM" . "Insufficient memory available")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 ("MRP" . "Missing )")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ("NAB" . "No arg before ^_")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 ("NAC" . "No arg before ,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 ("NAE" . "No arg before =")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 ("NAP" . "No arg before )")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 ("NAQ" . "No arg before \"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 ("NAS" . "No arg before ;")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 ("NAU" . "No arg before U")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 ("NFI" . "No file for input")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ("NFO" . "No file for output")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 ("NYA" . "Numeric arg with Y")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 ("OFO" . "Output file already open")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 ("PDO" . "Pushdown list overflow")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 ("POP" . "Pointer off page")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 ("SNI" . "; not in iteration")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 ("SRH" . "Search failure ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 ("STL" . "String too long")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 ("UTC" . "Unterminated command")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 ("UTM" . "Unterminated macro")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 ("XAB" . "Execution interrupted")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 ("YCA" . "Y command suppressed")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ("IWA" . "Invalid W arg")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ("NFR" . "Numeric arg with FR")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 ("INT" . "Internal error")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ("EFI" . "EOF read from std input")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 ("IAA" . "Invalid A arg")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (defconst teco-spec-chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 [
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 0 1 0 0 ; ^@ ^A ^B ^C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 0 64 0 0 ; ^D ^E ^F ^G
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 0 2 128 128 ; ^H ^I ^J ^K
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 128 0 64 0 ; ^L ^M ^N ^O
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 0 64 64 64 ; ^P ^Q ^R ^S
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 0 34 0 0 ; ^T ^U ^V ^W
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 64 0 0 0 ; ^X ^Y ^Z ^\[
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 0 0 1 0 ; ^\ ^\] ^^ ^_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 0 1 16 0 ; ! \" #
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 0 0 0 16 ; $ % & '
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 0 0 0 0 ; \( \) * +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 0 0 0 0 ; , - . /
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 0 0 0 0 ; 0 1 2 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 0 0 0 0 ; 4 5 6 7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 0 0 0 0 ; 8 9 : ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 16 0 16 0 ; < = > ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 1 0 12 0 ; @ A B C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 0 1 1 32 ; D E F G
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 0 6 0 0 ; H I J K
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 0 32 10 2 ; L M N O
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 0 32 4 10 ; P Q R S
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 0 32 0 4 ; T U V W
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 32 0 0 32 ; X Y Z \[
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 0 32 1 6 ; \ \] ^ _
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 0 0 12 0 ; ` a b c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 0 1 1 32 ; d e f g
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 0 6 0 0 ; h i j k
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 0 32 10 2 ; l m n o
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 0 32 4 10 ; p q r s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 0 32 0 4 ; t u v w
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 32 0 0 0 ; x y z {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 16 0 0 0 ; | } ~ DEL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 ]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 "The special properties of characters:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 1 skipto() special character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 2 command with std text argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 4 E<char> takes a text argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 8 F<char> takes a text argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 16 char causes skipto() to exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 32 command with q-register argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 64 special char in search string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 128 character is a line separator")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (defun teco-execute-command (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 "Execute teco command string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ;; Initialize everything
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (let ((teco-command-string string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (teco-command-pointer 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (teco-digit-switch nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (teco-exp-exp nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (teco-exp-val1 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (teco-exp-val2 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (teco-exp-flag1 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (teco-exp-flag2 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (teco-exp-op 'start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (teco-trace nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (teco-at-flag nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (teco-colon-flag nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (teco-exec-flags 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (teco-iteration-stack nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (teco-cond-stack nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (teco-exp-stack nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (teco-macro-stack nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (teco-qreg-stack nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ;; initialize output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (teco-out-init)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ;; execute commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (catch 'teco-exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (while t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 ;; get next command character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (let ((cmdc (teco-get-command0 teco-trace)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ;; if it's ^, interpret the next character as a control character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (if (eq cmdc ?^)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (setq cmdc (logand (teco-get-command teco-trace) 31)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (if (and (<= ?0 cmdc) (<= cmdc ?9))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;; process a number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (setq cmdc (- cmdc ?0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ;; check for invalid digit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (if (>= cmdc teco-ctrl-r)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (teco-error "ILN"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (if teco-digit-switch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 ;; later digits
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (setq teco-exp-val1 (+ (* teco-exp-val1 teco-ctrl-r) cmdc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ;; first digit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (setq teco-exp-val1 cmdc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (setq teco-digit-switch t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ;; indicate a value was read in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (setq teco-exp-flag1 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 ;; not a digit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (setq teco-digit-switch nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 ;; cannonicalize the case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (setq cmdc (aref teco-mapch-l cmdc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;; dispatch on the character, if it is a type 1 character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (let ((r (aref teco-exec-1 cmdc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (if r
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (funcall r)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 ;; if a value has been entered, process any pending operation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (if teco-exp-flag1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (cond ((eq teco-exp-op 'start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 ((eq teco-exp-op 'add)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (setq teco-exp-val1 (+ teco-exp-exp teco-exp-val1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (setq teco-exp-op 'start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 ((eq teco-exp-op 'sub)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (setq teco-exp-val1 (- teco-exp-exp teco-exp-val1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (setq teco-exp-op 'start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 ((eq teco-exp-op 'mult)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (setq teco-exp-val1 (* teco-exp-exp teco-exp-val1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (setq teco-exp-op 'start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 ((eq teco-exp-op 'div)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (setq teco-exp-val1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (if (/= teco-exp-val1 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (/ teco-exp-exp teco-exp-val1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (setq teco-exp-op 'start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 ((eq teco-exp-op 'and)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (setq teco-exp-val1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (logand teco-exp-exp teco-exp-val1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (setq teco-exp-op 'start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 ((eq teco-exp-op 'or)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (setq teco-exp-val1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (logior teco-exp-exp teco-exp-val1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (setq teco-exp-op 'start))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 ;; dispatch on a type 2 character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (let ((r (aref teco-exec-2 cmdc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (if r
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (funcall r)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (teco-error "ILL")))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 ;; Type 1 commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 ?\m ; CR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 ?\n ; LF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 ?\^k ; VT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 ?\^l ; FF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 32 ; SPC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 ?\e ; ESC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (if (teco-peek-command ?\e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 ;; ESC ESC terminates macro or command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (teco-pop-macro-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 ;; otherwise, consume argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (setq teco-exp-flag1 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (setq teco-exp-op 'start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ?! ; !
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (while (/= (teco-get-command teco-trace) ?!)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 ?@ ; @
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 ;; set at-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (setq teco-at-flag t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 ?: ; :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 ;; is it '::'?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (if (teco-peek-command ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 ;; skip second colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (teco-get-command teco-trace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 ;; set flag to show two colons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (setq teco-colon-flag 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 ;; set flag to show one colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (setq teco-colon-flag 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ?? ; ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 ;; toggle trace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (setq teco-trace (not teco-trace)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 ?. ; .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 ;; value is point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (setq teco-exp-val1 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 teco-exp-flag1 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 ?z ; z
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 ;; value is point-max
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (setq teco-exp-val1 (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 teco-exp-flag1 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 ?b ; b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 ;; value is point-min
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (setq teco-exp-val1 (point-min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 teco-exp-flag1 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 ?h ; h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 ;; value is b,z
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (setq teco-exp-val1 (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 teco-exp-val2 (point-min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 teco-exp-flag1 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 teco-exp-flag2 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 teco-exp-op 'start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 ?\^s ; ^s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 ;; value is - length of last insert, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (setq teco-exp-val1 teco-ctrl-s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 teco-exp-flag1 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 ?\^y ; ^y
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 ;; value is .+^S,.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (setq teco-exp-val1 (+ (point) teco-ctrl-s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 teco-exp-val2 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 teco-exp-flag1 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 teco-exp-flag2 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 teco-exp-op 'start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 ?\( ; \(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 ;; push expression stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (teco-push-exp-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (setq teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 teco-exp-flag2 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 teco-exp-op 'start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 ?\^p ; ^p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (teco-do-ctrl-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (teco-define-type-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 ?\C-^ ; ^^
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ;; get next command character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (setq teco-exp-val1 (teco-get-command teco-trace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 teco-exp-flag1 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 ;; Type 2 commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 ?+ ; +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (setq teco-exp-exp (if teco-exp-flag1 teco-exp-val1 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 teco-exp-op 'add))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 ?- ; -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (setq teco-exp-exp (if teco-exp-flag1 teco-exp-val1 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 teco-exp-op 'sub))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 ?* ; *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (setq teco-exp-exp (if teco-exp-flag1 teco-exp-val1 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 teco-exp-op 'mult))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 ?/ ; /
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (setq teco-exp-exp (if teco-exp-flag1 teco-exp-val1 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 teco-exp-op 'div))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 ?& ; &
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (setq teco-exp-exp (if teco-exp-flag1 teco-exp-val1 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 teco-exp-op 'and))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 ?# ; #
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (setq teco-exp-exp (if teco-exp-flag1 teco-exp-val1 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 teco-exp-op 'or))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 ?\) ; \)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (if (or (not teco-exp-flag1) (not teco-exp-stack))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (teco-error "NAP"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (let ((v teco-exp-val1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (teco-pop-exp-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (setq teco-exp-val1 v
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 teco-exp-flag1 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 ?, ; ,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (if (not teco-exp-flag1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (teco-error "NAC"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (setq teco-exp-val2 teco-exp-val1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 teco-exp-flag2 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 teco-exp-flag1 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 ?\^_ ; ^_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (if (not teco-exp-flag1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (teco-error "NAB")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (setq teco-exp-val1 (lognot teco-exp-val1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 ?\^d ; ^d
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (setq teco-ctrl-r 10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 teco-exp-op 'start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 ?\^o ; ^o
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (setq teco-ctrl-r 8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 teco-exp-op 'start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 ?\^r ; ^r
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (if teco-colon-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (recursive-edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (setq teco-colon-flag nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (if teco-exp-flag1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 ;; set radix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (if (and (/= teco-exp-val1 8)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (/= teco-exp-val1 10)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (/= teco-exp-val1 16))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (teco-error "IRA"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (setq teco-ctrl-r teco-exp-val1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 teco-exp-op 'start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 ;; get radix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (setq teco-exp-val1 teco-ctrl-r
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 teco-exp-flag1 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 ?\^c ; ^c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (if (teco-peek-command ?\^c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 ;; ^C^C stops execution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (throw 'teco-exit nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (if teco-macro-stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 ;; ^C inside macro exits macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (teco-pop-macro-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 ;; ^C in command stops execution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (throw 'teco-exit nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 ?\^x ; ^x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 ;; set/get search mode flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (teco-set-var 'teco-ctrl-x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 ?m ; m
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (let ((macro-name (teco-get-qspec nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (teco-get-command teco-trace))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (teco-push-macro-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (setq teco-command-string (aref teco-qreg-text macro-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 teco-command-pointer 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 ?< ; <
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 ;; begin iteration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (if (and teco-exp-flag1 (<= teco-exp-val1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 ;; if this is not to be executed, just skip the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 ;; intervening stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (teco-find-enditer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 ;; push iteration stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (teco-push-iter-stack teco-command-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 teco-exp-flag1 teco-exp-val1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 ;; consume the argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (setq teco-exp-flag1 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 ?> ; >
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 ;; end iteration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (if (not teco-iteration-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (teco-error "BNI"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 ;; decrement count and pop conditionally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (teco-pop-iter-stack nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 ;; consume arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (setq teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 teco-exp-flag2 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 teco-exp-op 'start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 59 ; ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 ;; semicolon iteration exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (if (not teco-iteration-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (teco-error "SNI"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 ;; if exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (if (if (>= (if teco-exp-flag1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 teco-exp-val1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 teco-search-result) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (not teco-colon-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 teco-colon-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (teco-find-enditer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (teco-pop-iter-stack t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 ;; consume argument and colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (setq teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 teco-colon-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 teco-exp-op 'start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 ?\" ; \"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 ;; must be an argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (if (not teco-exp-flag1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (teco-error "NAQ"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 ;; consume argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (setq teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 teco-exp-op 'start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (let* (;; get the test specification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (c (aref teco-mapch-l (teco-get-command teco-trace)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 ;; determine whether the test is true
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (test (cond ((eq c ?a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (/= (logand (aref teco-char-types teco-exp-val1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 1) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 ((eq c ?c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (/= (logand (aref teco-char-types teco-exp-val1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 2) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 ((eq c ?d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (/= (logand (aref teco-char-types teco-exp-val1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 4) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 ((or (eq c ?e) (eq c ?f) (eq c ?u) (eq c ?=))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (= teco-exp-val1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 ((or (eq c ?g) (eq c ?>))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (> teco-exp-val1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 ((or (eq c ?l) (eq c ?s) (eq c ?t) (eq c ?<))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (< teco-exp-val1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 ((eq c ?n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (/= teco-exp-val1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 ((eq c ?r)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (/= (logand (aref teco-char-types teco-exp-val1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 8) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 ((eq c ?v)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (/= (logand (aref teco-char-types teco-exp-val1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 16) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 ((eq c ?w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (/= (logand (aref teco-char-types teco-exp-val1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 32) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (teco-error "IQC")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (if (not test)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 ;; if the conditional isn't satisfied, read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 ;; to matching | or '
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (let ((ll 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (while (> ll 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (while (progn (setq c (teco-skipto))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (and (/= c ?\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (/= c ?|)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (/= c ?\')))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (if (= c ?\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (setq ll (1+ ll))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (if (= c ?\')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (setq ll (1- ll))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (if (= ll 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (break))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 ?' ; '
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 ;; ignore it if executing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 ?| ; |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (let ((ll 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (while (> ll 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (while (progn (setq c (teco-skipto))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (and (/= c ?\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (/= c ?\')))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (if (= c ?\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (setq ll (1+ ll))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (setq ll (1- ll))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 ?u ; u
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (if (not teco-exp-flag1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (teco-error "NAU"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (aset teco-qreg-number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (teco-get-qspec 0 (teco-get-command teco-trace))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 teco-exp-val1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (setq teco-exp-flag1 teco-exp-flag2 ; command's value is second arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 teco-exp-val1 teco-exp-val2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 teco-exp-flag2 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 teco-exp-op 'start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 ?q ; q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 ;; Qn is numeric val, :Qn is # of chars, mQn is mth char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (let ((mm (teco-get-qspec (or teco-colon-flag teco-exp-flag1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (teco-get-command teco-trace))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (if (not teco-exp-flag1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (setq teco-exp-val1 (if teco-colon-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 ;; :Qn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (length (aref teco-qreg-text mm))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 ;; Qn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (aref teco-qreg-number mm))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 teco-exp-flag1 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 ;; mQn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (let ((v (aref teco-qreg-text mm)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (setq teco-exp-val1 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (aref v teco-exp-val1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (error -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 teco-exp-op 'start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (setq teco-colon-flag nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 ?% ; %
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (let* ((mm (teco-get-qspec nil (teco-get-command teco-trace)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (v (+ (aref teco-qreg-number mm) (teco-get-value 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (aset teco-qreg-number mm v)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (setq teco-exp-val1 v
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 teco-exp-flag1 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 ?c ; c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (let ((p (+ (point) (teco-get-value 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (if (or (< p (point-min)) (> p (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (teco-error "POP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (goto-char p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (setq teco-exp-flag2 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 ?r ; r
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (let ((p (- (point) (teco-get-value 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (if (or (< p (point-min)) (> p (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (teco-error "POP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (goto-char p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (setq teco-exp-flag2 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 ?j ; j
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (let ((p (teco-get-value (point-min))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (if (or (< p (point-min)) (> p (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (teco-error "POP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (goto-char p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (setq teco-exp-flag2 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 ?l ; l
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 ;; move forward by lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (forward-char (teco-lines (teco-get-value 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 ?\C-q ; ^q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 ;; number of characters until the nth line feed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (setq teco-exp-val1 (teco-lines (teco-get-value 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 teco-exp-flag1 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 ?= ; =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 ;; print numeric value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (if (not teco-exp-flag1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (teco-error "NAE"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (teco-output (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (if (teco-peek-command ?=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 ;; at least one more =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 ;; read past it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (teco-get-command teco-trace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (if (teco-peek-command ?=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 ;; another?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 ;; read it too
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (teco-get-command teco-trace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 ;; print in hex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 "%x")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 ;; print in octal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 "%o"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 ;; print in decimal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 "%d")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 teco-exp-val1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 ;; add newline if no colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (if (not teco-colon-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (teco-output ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 ;; absorb argument, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (setq teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 teco-exp-flag2 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 teco-colon-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 teco-exp-op 'start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 ?\t ; TAB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (if exp-flag1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (teco-error "IIA"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (let ((text (teco-get-text-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (insert ?\t text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (setq teco-ctrl-s (1+ (length text))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 ;; clear arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (setq teco-colon-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 teco-exp-flag2 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 ?i ; i
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (let ((text (teco-get-text-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (if teco-exp-flag1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 ;; if a nI$ command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 ;; text argument must be null
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (or (string-equal text "") (teco-error "IIA"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 ;; insert the character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (insert teco-exp-val1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (setq teco-ctrl-s 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 ;; consume argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (setq teco-exp-op 'start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 ;; otherwise, insert the text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (insert text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (setq teco-ctrl-s (length text)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 ;; clear arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (setq teco-colon-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 teco-exp-flag2 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 ?t ; t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (let ((args (teco-line-args nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (teco-output (buffer-substring (car args) (cdr args)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 ?v ; v
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (let ((ll (teco-get-value 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (teco-output (buffer-substring (+ (point) (teco-lines (- 1 ll)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (+ (point) (teco-lines ll))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 ?\C-a ; ^a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (teco-output (teco-get-text-arg nil ?\C-a))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (setq teco-at-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 teco-colon-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 teco-exp-flag2 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 teco-exp-op 'start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 ?d ; d
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (if (not teco-exp-flag2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 ;; if only one argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (delete-char (teco-get-value 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 ;; if two arguments, treat as n,mK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (let ((ll (teco-line-args 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (delete-region (car ll) (cdr ll)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 ?k ; k
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (let ((ll (teco-line-args 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (delete-region (car ll) (cdr ll))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 ?\C-u ; ^u
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (let* ((mm (teco-get-qspec nil (teco-get-command teco-trace)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 (text-arg (teco-get-text-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 (text (if (not teco-exp-flag1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 text-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 (if (string-equal text-arg "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (char-to-string teco-exp-val1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (teco-error "IIA")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 ;; if :, append to the register
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (aset teco-qreg-text mm (if teco-colon-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (concat (aref teco-qreg-text mm) text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 text))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 ;; clear various flags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (setq teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 teco-at-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 teco-colon-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 teco-exp-flag1 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 ?x ; x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (let* ((mm (teco-get-qspec nil (teco-get-command teco-trace)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (args (teco-line-args 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (text (buffer-substring (car args) (cdr args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 ;; if :, append to the register
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (aset teco-qreg-text mm (if teco-colon-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (concat (aref teco-qreg-text mm) text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 text))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 ;; clear various flags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (setq teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 teco-at-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 teco-colon-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 teco-exp-flag1 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 ?g ; g
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (let ((mm (teco-get-qspec t (teco-get-command teco-trace))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (if teco-colon-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (teco-output (aref teco-qreg-text mm))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (insert (aref teco-qreg-text mm)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (setq teco-colon-flag nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 ?\[ ; \[
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 (let ((mm (teco-get-qspec t (teco-get-command teco-trace))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (setq teco-qreg-stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (cons (cons (aref teco-qreg-text mm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (aref teco-qreg-number mm))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 teco-qreg-stack))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 ?\] ; \]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 (let ((mm (teco-get-qspec t (teco-get-command teco-trace))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 (if teco-colon-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 (setq teco-exp-flag1 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 teco-exp-val1 (if teco-qreg-stack -1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 (if teco-qreg-stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (let ((pop (car teco-qreg-stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 (aset teco-qreg-text mm (car pop))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (aset teco-qreg-number mm (cdr pop))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (setq teco-qreg-stack (cdr teco-qreg-stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (teco-error "CPQ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (setq teco-colon-flag nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 ?\\ ; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (if (not teco-exp-flag1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 ;; no argument; read number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (let ((p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (sign +1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (setq c (char-after p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (if c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 (if (= c ?+)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (setq p (1+ p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (if (= c ?-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (setq p (1+ p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 sign -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 ((= teco-ctrl-r 8)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (while (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (setq c (char-after p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (and c (>= c ?0) (<= c ?7)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (setq p (1+ p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 n (+ c -48 (* n 8)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 ((= teco-ctrl-r 10)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (while (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (setq c (char-after p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 (and c (>= c ?0) (<= c ?9)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 (setq p (1+ p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 n (+ c -48 (* n 10)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (while (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 (setq c (char-after p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (and c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (and (>= c ?0) (<= c ?9))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (and (>= c ?a) (<= c ?f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (and (>= c ?A) (<= c ?F)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (setq p (1+ p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 n (+ c (if (> c ?F)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 ;; convert 'a' to 10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 -87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (if (> c ?9)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 ;; convert 'A' to 10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 -55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 ;; convert '0' to 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 -48))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (* n 16))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (setq teco-exp-val1 (* n sign)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 teco-exp-flag1 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 teco-ctrl-s (- (point) p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 ;; argument: insert it as a digit string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (insert (format (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 ((= teco-ctrl-r 8) "%o")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 ((= teco-ctrl-r 10) "%d")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (t "%x"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 teco-exp-val1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (setq teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 teco-exp-op 'start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 ?\C-t ; ^t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (if teco-exp-flag1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 ;; type a character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (teco-output teco-exp-val1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (setq teco-exp-flag1 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 ;; input a character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (let* ((echo-keystrokes 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (c (read-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 (teco-output c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 (setq teco-exp-val1 c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 teco-exp-flag1 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 ?s ; s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (let ((arg (teco-get-text-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (count (if teco-exp-flag1 teco-expr-val1 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (if (not (string-equal arg ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (setq regexp (teco-parse-search-string arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 teco-last-search-string arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 teco-last-search-regexp regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 (setq regexp (teco-last-search-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 arg teco-last-search-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (let ((p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (result (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 ((> count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (re-search-forward regexp nil t count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 ((< count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (re-search-backward regexp nil t count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 ;; 0s always is successful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 ;; if ::s, restore point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (if (eq teco-colon-flag 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (goto-char p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 ;; if no real or implied colon, error if not found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (if (and (not result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (not teco-colon-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (/= (teco-peekcmdc) 34))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (teco-error "SRH"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 ;; set return results
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (setq teco-exp-flag2 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 teco-colon-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 teco-at-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 teco-exp-op 'start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (if teco-colon-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (setq teco-exp-flag1 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 teco-exp-val1 (if result -1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (setq teco-exp-flag1 nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (defun teco-parse-search-string (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (let ((i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (l (length s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (r "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (while (< i l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (setq r (concat r (teco-parse-search-string-1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 r))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (defun teco-parse-search-string-1 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (if (>= i l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (teco-error "ISS"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (setq c (aref s i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (setq i (1+ i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 ((eq c ?\C-e) ; ^E - special match characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (teco-parse-search-string-e))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 ((eq c ?\C-n) ; ^Nx - match all but x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (teco-parse-search-string-n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 ((eq c ?\C-q) ; ^Qx - use x literally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 (teco-parse-search-string-q))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 ((eq c ?\C-s) ; ^S - match separator chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 "[^A-Za-z0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 ((eq c ?\C-x) ; ^X - match any character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 "[\000-\377]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (t ; ordinary character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 (teco-parse-search-string-char c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (defun teco-parse-search-string-char (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 (regexp-quote (char-to-string c)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (defun teco-parse-search-string-q ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (if (>= i l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (teco-error "ISS"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (setq c (aref s i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (setq i (1+ i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (teco-parse-search-string-char c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 (defun teco-parse-search-string-e ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 (if (>= i l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 (teco-error "ISS"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (setq c (aref s i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (setq i (1+ i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 ((or (eq c ?a) (eq c ?A)) ; ^EA - match alphabetics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 "[A-Za-z]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 ((or (eq c ?c) (eq c ?C)) ; ^EC - match symbol constituents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 "[A-Za-z.$]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 ((or (eq c ?d) (eq c ?D)) ; ^ED - match numerics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 "[0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 ((eq c ?g) ; ^EGq - match any char in q-reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 (teco-parse-search-string-e-g))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 ((or (eq c ?l) (eq c ?L)) ; ^EL - match line terminators
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 "[\012\013\014]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 ((eq c ?q) ; ^EQq - use contents of q-reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (teco-parse-search-string-e-q))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 ((eq c ?r) ; ^ER - match alphanumerics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 "[A-Za-z0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 ((eq c ?s) ; ^ES - match non-null space/tab seq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 "[ \t]+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 ((eq c ?v) ; ^EV - match lower case alphabetic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 "[a-z]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 ((eq c ?w) ; ^EW - match upper case alphabetic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 "[A-Z]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 ((eq c ?x) ; ^EX - match any character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 "[\000-\377]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (teco-error "ISS"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (defun teco-parse-search-string-e-q ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (if (>= i l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (teco-error "ISS"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 (setq c (aref s i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 (setq i (1+ i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (regexp-quote (aref reco:q-reg-text c)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (defun teco-parse-search-string-e-g ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (if (>= i l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 (teco-error "ISS"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 (setq c (aref s i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 (setq i (1+ i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 (let* ((q (aref teco-qreg-text c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (len (length q))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 (null (= len 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 (one-char (= len 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (dash-present (string-match "-" q))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (caret-present (string-match "\\^" q))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 (outbracket-present (string-match "]" q))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (null
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 "[^\000-\377]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (one-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (teco-parse-search-string-char c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (while (setq p (string-match "^]\\^"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (setq q (concat (substring q 1 p) (substring q (1+ p)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 "["
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (if outbracket-present "]" "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (if dash-present "---" "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 (if caret-present "^" ""))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (defun teco-parse-search-string-n ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (let ((p (teco-parse-search-string-1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 ((= (aref p 0) ?\[)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 (if (= (aref p 1) ?^)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 ;; complement character set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (if (= (length p) 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 ;; complement of one character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (teco-parse-search-string-char (aref p 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 ;; complement of more than one character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (concat "[" (substring p 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 ;; character set - invert it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 (concat "[^" (substring p 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 ((= (aref p 0) ?\\)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 ;; single quoted character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (concat "[^" (substring p 1) "]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 ;; single character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 (if (string-equal p "-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 "[^---]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (concat "[^" p "]"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 ?o ; o
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (let ((label (teco-get-text-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (index (and teco-exp-flag1 teco-exp-val1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (setq teco-exp-flag1 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 ;; handle computed goto by extracting the proper label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 (if index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 (if (< index 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 ;; argument < 0 is a noop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 (setq label "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 ;; otherwise, find the n-th label (0-origin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (setq label (concat label ","))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 (let ((p 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 (while (and (> index 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (setq p (string-match "," label p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (setq p (1+ p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 (setq index (1- index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (setq q (string-match "," label p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (setq label (substring label p q)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 ;; if the label is non-null, find the correct label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 ;; start from beginning of iteration or macro, and look for tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 (setq teco-command-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (if teco-iteration-stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 ;; if in iteration, start at beginning of iteration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (aref (car teco-iteration-stack) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 ;; if not in iteration, start at beginning of command or macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 ;; search for tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (catch 'label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (let ((level 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 c p l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 ;; look for interesting things, including !
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (while t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (setq c (teco-skipto t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 ((= c ?<) ; start of iteration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (setq level (1+ level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 ((= c ?>) ; end of iteration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (if (= level 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (teco-pop-iter-stack t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (setq level (1- level))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 ((= c ?!) ; start of tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (setq p (string-match "!" teco-command-string teco-command-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (if (and p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (string-equal label (substring teco-command-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 teco-command-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (setq teco-command-pointer (1+ p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 (throw 'label nil))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 (teco-define-type-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 ?a ; :a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 ;; 'a' must be used as ':a'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 (if (and teco-exp-flag1 teco-colon-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (let ((char (+ (point) teco-exp-val1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (setq teco-exp-val1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (if (and (>= char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 (< char (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (char-after char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 teco-colon-flag nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (teco-error "ILL")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 ;; Routines to get next character from command buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 ;; getcmdc0, when reading beyond command string, pops
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 ;; macro stack and continues.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 ;; getcmdc, in similar circumstances, reports an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 ;; If pushcmdc() has returned any chars, read them first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 ;; routines type characters as read, if argument != 0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (defun teco-get-command0 (trace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 ;; get the next character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 (let (char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 (while (not (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 (setq char (aref teco-command-string teco-command-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 ;; if we've exhausted the string, pop the macro stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 ;; if we exhaust the macro stack, exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (error (teco-pop-macro-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 ;; bump the command pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (setq teco-command-pointer (1+ teco-command-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 ;; trace, if requested
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 (and trace (teco-trace-type char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 ;; return the character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 ;; while (cptr.dot >= cptr.z) /* if at end of this level, pop macro stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 ;; {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 ;; if (--msp < &mstack[0]) /* pop stack; if top level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 ;; {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 ;; msp = &mstack[0]; /* restore stack pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 ;; cmdc = ESC; /* return an ESC (ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 ;; exitflag = 1; /* set to terminate execution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 ;; return(cmdc); /* exit "while" and return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 ;; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 ;; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 ;; cmdc = cptr.p->ch[cptr.c++]; /* get char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 ;; ++cptr.dot; /* increment character count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 ;; if (trace) type_char(cmdc); /* trace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 ;; if (cptr.c > CELLSIZE-1) /* and chain if need be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 ;; {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 ;; cptr.p = cptr.p->f;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 ;; cptr.c = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 ;; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 ;; return(cmdc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 ;; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 (defun teco-get-command (trace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 ;; get the next character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 (let ((char (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (aref teco-command-string teco-command-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 ;; if we've exhausted the string, give error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (teco-error (if teco-macro-stack "UTM" "UTC"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 ;; bump the command pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 (setq teco-command-pointer (1+ teco-command-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 ;; trace, if requested
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (and trace (teco-trace-type char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 ;; return the character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 ;; char getcmdc(trace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 ;; {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 ;; if (cptr.dot++ >= cptr.z) ERROR((msp <= &mstack[0]) ? E_UTC : E_UTM);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 ;; else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 ;; {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 ;; cmdc = cptr.p->ch[cptr.c++]; /* get char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 ;; if (trace) type_char(cmdc); /* trace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 ;; if (cptr.c > CELLSIZE-1) /* and chain if need be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 ;; {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 ;; cptr.p = cptr.p->f;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 ;; cptr.c = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 ;; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 ;; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 ;; return(cmdc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 ;; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 ;; peek at next char in command string, return 1 if it is equal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 ;; (case independent) to argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 (defun teco-peek-command (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 (eq (aref teco-mapch-l (aref teco-command-string teco-command-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 (aref teco-mapch-l arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 ;; int peekcmdc(arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 ;; char arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 ;; {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 ;; return(((cptr.dot < cptr.z) && (mapch_l[cptr.p->ch[cptr.c]] == mapch_l[arg])) ? 1 : 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 ;; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (defun teco-get-text-arg (&optional term-char default-term-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 ;; figure out what the terminating character is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (setq teco-term-char (or term-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 (if teco-at-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 (teco-get-command teco-trace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 (or default-term-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 ?\e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 teco-at_flag nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 (let ((s "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (while (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (setq c (teco-get-command teco-trace))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 (/= c teco-term-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 (setq s (concat s (char-to-string c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 ;; Routines to manipulate the stacks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 ;; Pop the macro stack. Throw to 'teco-exit' if the stack is empty.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (defun teco-pop-macro-stack ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 (if teco-macro-stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 (let ((frame (car teco-macro-stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 (setq teco-macro-stack (cdr teco-macro-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 teco-command-string (aref frame 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 teco-command-pointer (aref frame 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 teco-exec-flags (aref frame 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 teco-iteration-stack (aref frame 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 teco-cond-stack (aref frame 4)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 (throw 'teco-exit nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 ;; Push the macro stack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 (defun teco-push-macro-stack ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 (setq teco-macro-stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (cons (vector teco-command-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 teco-command-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 teco-exec-flags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 teco-iteration-stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 teco-cond-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 teco-macro-stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 ;; Pop the expression stack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 (defun teco-pop-exp-stack ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 (let ((frame (car teco-exp-stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (setq teco-exp-stack (cdr teco-exp-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 teco-exp-val1 (aref frame 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 teco-exp-flag1 (aref frame 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 teco-exp-val2 (aref frame 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 teco-exp-flag2 (aref frame 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 teco-exp-exp (aref frame 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 teco-exp-op (aref frame 5))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 ;; Push the expression stack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 (defun teco-push-exp-stack ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (setq teco-exp-stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 (cons (vector teco-exp-val1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 teco-exp-flag1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 teco-exp-val2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 teco-exp-flag2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 teco-exp-exp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 teco-exp-op)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 teco-exp-stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 ;; Pop the iteration stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 ;; if arg t, exit unconditionally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 ;; else check exit conditions and exit or reiterate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 (defun teco-pop-iter-stack (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (let ((frame (car teco-iteration-stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 (if (or arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (not (aref frame 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 ;; test against 1, since one iteration has already been done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 (<= (aref frame 2) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 ;; exit iteration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 (setq teco-iteration-stack (cdr teco-iteration-stack))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 ;; continue with iteration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 ;; decrement count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 (aset frame 2 (1- (aref frame 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 ;; reset command pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 (setq teco-command-pointer (aref frame 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 ;; Push the iteration stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (defun teco-push-iter-stack (pointer flag count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 (setq teco-iteration-stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 (cons (vector pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 teco-iteration-stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 (defun teco-find-enditer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 (let ((icnt 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 (while (> icnt 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 (while (progn (setq c (teco-skipto))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 (and (/= c ?<)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 (/= c ?>)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (if (= c ?<)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (setq icnt (1+ icnt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 (setq icnt (1- icnt)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 ;; I/O routines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 (defvar teco-output-buffer (get-buffer-create "*Teco Output*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 "The buffer into which Teco output is written.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 (defun teco-out-init ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 ;; Recreate the teco output buffer, if necessary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 (setq teco-output-buffer (get-buffer-create "*Teco Output*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 (set-buffer teco-output-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 ;; get a fresh line in output buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 ;; remember where to start displaying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 (setq teco-output-start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 ;; clear minibuffer, in case we have to display in it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 (select-window (minibuffer-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 (erase-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 ;; if output is visible, position it correctly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 (let ((w (get-buffer-window teco-output-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 (if w
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (set-window-start w teco-output-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (set-window-point w teco-output-start))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 (defun teco-output (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 (let ((w (get-buffer-window teco-output-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 (b (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 (sw (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 ;; Put the text in the output buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 (set-buffer teco-output-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 (insert s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 (let ((p (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (set-buffer b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 (if w
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 ;; if output is visible, move the window point to the end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 (set-window-point w p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 ;; Otherwise, we have to figure out how to display the text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 ;; Has a newline followed by another character been added to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 ;; output buffer? If so, we have to make the output buffer visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (set-buffer teco-output-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 (search-backward "\n" teco-output-start t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 ;; a newline has been seen, clear the minibuffer and make the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 ;; output buffer visible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 (select-window (minibuffer-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 (erase-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 (let ((pop-up-windows t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 (pop-to-buffer teco-output-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 (goto-char p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 (set-window-start w teco-output-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 (set-window-point w p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 (select-window sw)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 ;; a newline has not been seen, add output to minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 (select-window (minibuffer-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 (insert s)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 ;; Output a character of tracing information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 (defun teco-trace-type (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 (teco-output (if (= c ?\e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 ?$
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 c)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 ;; Report an error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 (defun teco-error (code)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 (let ((text (cdr (assoc code teco-error-texts))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 (teco-output (concat (if (save-excursion (set-buffer teco-output-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 (/= (point) teco-output-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 "? " code " " text))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (if debug-on-error (debug nil code text))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 (throw 'teco-exit nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 ;; Utility routines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 ;; copy characters from command string to buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 (defun teco-moveuntil (string pointer terminate trace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 (let ((count 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 (while (/= (aref string pointer) terminate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 (and teco-trace (teco-trace-type (aref string pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 (insert (aref string pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 (setq pointer (1+ pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 (setq count (1+ count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (error (teco-error (if teco-macro-stack "UTM" "UTC"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 ;; Convert character to q-register name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 ;; If file-or-search is t, allow _, *, %, #
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 (defun teco-get-qspec (file-or-search char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 ;; lower-case char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 (setq char (aref teco-mapch-l char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 ;; test that it's valid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 (if (= (logand (aref teco-qspec-valid char) (if file-or-search 2 1)) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 (teco-error "IQN"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 ;; Set or get value of a variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 (defun teco-set-var (var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 (if teco-exp-flag1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 (if teco-exp-flag2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 ;; if two arguments, they they are <clear bits>, <set bits>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 (set var (logior (logand (symbol-value var) (lognot teco-exp-val2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 teco-exp-val1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 ;; if one argument, it is the new value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 (set var teco-exp-val1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 ;; consume argument(s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 (setq teco-exp-flag2 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 teco-exp-flag1 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 ;; if no arguments, fetch the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 (setq teco-exp-val1 (symbol-value var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 teco-exp-flag1 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 ;; Get numeric argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 (defun teco-get-value (default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 (if teco-exp-flag1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 teco-exp-val1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 (if (eq teco-exp-op 'sub)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 (- default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 ;; consume argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 (setq teco-exp-flag1 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 teco-exp-op 'start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 ;; Get argument measuring in lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 (defun teco-lines (r)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 (- (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 (if (> r 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 (if (search-forward "\n" nil t r)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 (if (search-backward "\n" nil t (- 1 r))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 (1+ (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 (point-min))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 ;; routine to handle args for K, T, X, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 ;; if two args, 'char x' to 'char y'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 ;; if just one arg, then n lines (default 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 (defun teco-line-args (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 (if teco-exp-flag2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 (cons teco-exp-val1 teco-exp-val2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 (cons (point) (+ (point) (teco-lines (if teco-exp-flag1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 teco-exp-val1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 ;; routine to skip to next ", ', |, <, or >
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 ;; skips over these chars embedded in text strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 ;; stops in ! if argument is t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 ;; returns character found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 (defun teco-skipto (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 (catch 'teco-skip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 (let (;; "at" prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 (atsw nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 ;; temp attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 ta
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 ;; terminator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 term
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 skipc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (while t ; forever
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 (while (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 (setq skipc (teco-get-command nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 ta (aref teco-spec-chars skipc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 ;; if char is ^, treat next char as control
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 (if (eq skipc ?^)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 (setq skipc (logand 31 (teco-get-command nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 ta (aref teco-spec-chars skipc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 (= (logand ta 51) 0)) ; read until something interesting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 ; found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 (if (/= (logand ta 32) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 (teco-get-command nil)) ; if command takes a Q spec,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 ; skip the spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 (if (/= (logand ta 16) 0) ; sought char found: quit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 (if (= skipc ?\") ; quote must skip next char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 (teco-get-command nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 (throw 'teco-skip skipc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 (if (/= (logand ta 1) 0) ; other special char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 ((eq skipc ?@) ; use alternative text terminator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 (setq atsw t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 ((eq skipc ?\C-^) ; ^^ is value of next char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 ; skip that char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 (teco-get-command nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 ((eq skipc ?\C-a) ; type text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 (setq term (if atsw (teco-get-command nil) ?\C-a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 atsw nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 (while (/= (teco-get-command nil) term)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 nil)) ; skip text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 ((eq skipc ?!) ; tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 (throw 'teco-skip skipc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 (while (/= (teco-get-command nil) ?!)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 nil)) ; skip until next !
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 ((or (eq skipc ?e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 (eq skipc ?f)) ; first char of two-letter E or F
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 ; command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 nil))) ; not implemented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 (if (/= (logand ta 2) 0) ; command with a text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 ; argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 (setq term (if atsw (teco-get-command nil) ?\e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 atsw nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 (while (/= (teco-get-command nil) term)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 nil) ; skip text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 ))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 (defvar teco-command-keymap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 ;; This is what used to be (make-vector 128 'teco-command-self-insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 ;; Oh well
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 (let ((map (make-keymap)) (n 127))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 (while (>= n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 (define-key map (if (< n 32) (list 'control (+ n 32)) n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 'teco-command-self-insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 (setq n (1- n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 "Keymap used while reading teco commands.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 (define-key teco-command-keymap "\^g" 'teco-command-ctrl-g)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 (define-key teco-command-keymap "\^m" 'teco-command-return)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 (define-key teco-command-keymap "\^u" 'teco-command-ctrl-u)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 (define-key teco-command-keymap "\e" 'teco-command-escape)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 (define-key teco-command-keymap "\^?" 'teco-command-delete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 (defvar teco-command-escapes nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 "Records where ESCs are, since they are represented in the command buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 by $.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 (defun teco-command ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 "Read and execute a Teco command string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 (let* ((teco-command-escapes nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 (command (catch 'teco-command-quit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 (read-from-minibuffer teco-prompt nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 teco-command-keymap))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 (if command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 (while teco-command-escapes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 (aset command (car teco-command-escapes) ?\e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 (setq teco-command-escapes (cdr teco-command-escapes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 (setq teco-output-buffer (get-buffer-create "*Teco Output*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 (set-buffer teco-output-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 (insert teco-prompt command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 (teco-execute-command command)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 (defun teco-read-command ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 "Read a teco command string from the user."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 (let ((command (catch 'teco-command-quit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 (read-from-minibuffer teco-prompt nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 teco-command-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 teco-command-escapes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 (if command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 (while teco-command-escapes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 (aset command (car teco-command-escapes ?\e))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 (setq teco-command-escapes (cdr teco-command-escapes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 (defun teco-command-self-insert ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 (insert last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 (if (not (pos-visible-in-window-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 (enlarge-window 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 (defun teco-command-ctrl-g ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 (throw 'teco-command-quit nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 (defun teco-command-return ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 (setq last-command-char ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 (teco-command-self-insert))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 (defun teco-command-escape ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 ;; Two ESCs in a row terminate the command string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 (if (eq last-command 'teco-command-escape)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 (throw 'teco-command-quit (buffer-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 (setq teco-command-escapes (cons (1- (point)) teco-command-escapes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 (setq last-command-char ?$)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 (teco-command-self-insert))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (defun teco-command-ctrl-u ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 ;; delete the characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 (kill-line 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 ;; forget that they were ESCs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 (while (and teco-command-escapes (<= (point) (car teco-command-escapes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 (setq teco-command-escapes (cdr teco-command-escapes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 ;; decide whether to shrink the window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 (while (let ((a (insert ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 (b (pos-visible-in-window-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 (c (backward-delete-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 (shrink-window 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 (defun teco-command-delete ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 ;; delete the character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 (backward-delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 ;; forget that it was an ESC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 (if (and teco-command-escapes (= (point) (car teco-command-escapes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 (setq teco-command-escapes (cdr teco-command-escapes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 ;; decide whether to shrink the window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 (if (prog1 (pos-visible-in-window-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 (backward-delete-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 (shrink-window 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 (provide 'teco)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 ;;; teco.el ends here