annotate lisp/emulators/teco.el @ 0:376386a54a3c r19-14

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