Mercurial > emacs
annotate tparam.c @ 4872:628cbf7e7005
(comint-after-partial-file-name-command):
Renamed from comint-after-partial-pathname-command.
(comint-match-partial-file-name, comint-after-partial-file-name):
Renamed from comint-match-partial-pathname, etc.
(comint-last-output-start): New variable to record
where most recent process output started from.
(comint-mode): Initialise it.
(comint-output-filter): Set it.
(comint-previous-matching-input-string): Moved to
comint-previous-matching-input-position.
(comint-previous-matching-input-string): Use it.
(comint-search-arg, comint-search-start,
comint-previous-input-string): New subroutines.
(comint-previous-input, comint-next-input,
comint-previous-matching-input, comint-next-matching-input,
comint-previous-matching-input-from-input,
comint-next-matching-input-from-input): Use them.
(comint-mode-map): Added signal menu-bar. Moved
comint-backward/forward-matching-input to output menu-bar, since
they move within the buffer rather than do input.
(comint-send-input, comint-after-pmark-p,
comint-kill-input, comint-proc-query): Removed serialisation of
obtaining the process mark's marker-position.
Commented out comint-load-hooks.
(comint-dynamic-simple-complete): New subroutine.
(comint-dynamic-complete-filename-command): New variable.
(comint-after-partial-pathname-command): New variable.
(comint-after-partial-pathname): New subroutine.
(comint-dynamic-complete): Use them.
(comint-mode): Make them local.
Renamed comint-dynamic-complete-command to
comint-dynamic-complete-command-command for consistency.
Renamed comint-file-name-addsuffix/autolist/recexact to
comint-completion-addsuffix/autolist/recexact for consistency.
(comint-replace-by-expanded-history): Check if input
ring size is not big enough for relative reference.
(comint-read-input-ring, comint-input-ring-file-name):
From shell.el.
(shell-write-input-ring): New subroutine.
(comint-file-name-prefix): New variable.
(comint-directory): New inline subroutine.
(comint-dynamic-complete-filename, comint-dynamic-complete-variable,
comint-dynamic-list-filename-completions): Use it.
(comint-dynamic-complete-filename,
comint-dynamic-complete-variable,
comint-dynamic-list-filename-completions): Make sure local
completion-ignore-case is nil.
(comint-next-prompt, comint-previous-prompt): Use
paragraph-start and paragraph motion commands rather than
re-search-forward and re-search-backward commands.
(comint-dynamic-list-input-ring,
comint-previous-matching-input-string): Use ring-empty-p rather
than zerop and ring-length.
(comint-input-ignoredups): New variable.
(comint-send-input, shell-read-input-ring): Use it.
(comint-mode): Make comint-input-ignoredups local. Doc fix.
(comint-scroll-to-bottom-on-input): New variable.
(comint-scroll-to-bottom-on-output): New variable.
(comint-scroll-show-maximum-output): New variable.
(comint-output-filter-hook): New variable, defaults to
comint-postoutput-scroll-to-bottom.
(comint-output-filter): Renamed from comint-filter
for consistency. Now calls comint-output-filter-hook.
(comint-preinput-scroll-to-bottom): New subroutine.
(comint-postoutput-scroll-to-bottom): New subroutine.
(comint-show-maximum-output): New command.
(comint-copy-old-input): New command.
(comint-send-input): Run comint-output-filter-hook if
necessary as a kludge to prevent messy redisplays.
(comint-mode-map): Added comint-show-maximum-output to
C-c C-e and menu-bar output, and comint-copy-old-input to C-c C-i
and menu-bar input.
(comint-mode): Make local variables
comint-scroll-to-bottom-on-input, before-change-function,
comint-scroll-to-bottom-on-output, comint-scroll-show-maximum-output,
and comint-output-filter-hook.
(comint-version): Deleted--no need for separate version.
(comint-input-ring-index): Make this a permanent local.
(comint-mode): Don't alter comint-input-ring-index or comint-input-ring
if already set meaningfully.
(comint-mode-map): Added keys M-R/S for
comint-previous/next-matching-input-from-input and to completion
menu-bar. Added comint-forward/backward-matching-input and
comint-previous/next-matching-input to completion menu-bar.
(comint-mode): Doc fix for functionality.
(comint-exec-1): Uses setenv.
(comint-update-env): Removed.
(comint-input-ring-size): Incremented to 32, as with
command history.
(comint-dynamic-list-input-ring): Check for zero
length ring. Use ring length, not ring size, when generating
list. Use buffer " *Input History*".
(comint-previous-matching-input-string): Check for zero-length ring.
Check last item in case at end of cycle and it's a match.
(comint-searching-input-ring): New subroutine.
(comint-regexp-arg): New subroutine.
(comint-previous-matching-input-from-input): New command.
(comint-next-matching-input-from-input): New command.
(comint-replace-by-expanded-history): Fix for matching
inside quotes. Fix to allow argument subrange specifiers. Fix to
identify and reject absolute input number references.
(comint-within-quotes): New subroutine.
(comint-how-many-region): New subroutine.
(comint-args): New subroutine.
(comint-delim-arg): New subroutine.
(comint-arguments): New subroutine.
(comint-delimiter-argument-list): New variable.
(comint-send-input): Inserts input arguments into ring
separated by single spaces.
(comint-filter): Checks the buffer's process to make
sure it's still there. Otherwise, set-buffer will fail.
(comint-backward-matching-input): New command.
(comint-forward-matching-input): New command.
(comint-next-prompt, comint-previous-prompt):
Error if reach beg/end of buffer.
(comint-dynamic-complete): Fix for absolute input
number references.
(comint-dynamic-complete-filename): Changed listings
function to comint-dynamic-list-filename-completions. Uses
file-directory-p rather than string-match to test for directories.
(comint-dynamic-list-completions): Changed to list the
list of completions supplied as the function argument. Use buffer
" *Completions*".
(comint-match-partial-pathname): New subroutine.
(comint-dynamic-complete-variable): New command.
(comint-dynamic-list-filename-completions): New function.
(comint-previous-input):
Don't use replace-match; just insert before deleting.
(comint-magic-space): Use self-insert command.
(comint-history-file-name): New variable.
(comint-mode): Initialize comint-input-ring before
running comint-mode-hook.
(comint-input-autoexpand): New variable.
(comint-dynamic-complete-command): New variable.
(comint-get-current-command): New variable.
(comint-read-input-ring): New function.
(comint-send-input): Handle history expansion.
(comint-input-sentinel): Doc fix.
(comint-mode-map): Added key binding for C-c C-h.
Added menu bars for completion, input and output.
(comint-dynamic-list-input-ring): New function.
(comint-previous-input-string): New subroutine.
(comint-previous-input): Use it.
(comint-previous-matching-input-string): New subroutine.
(comint-previous-matching-input): Use it.
(comint-replace-by-expanded-history): New command.
(comint-magic-space): New command.
(comint-replace-by-expanded-filename): Now replaces
expanded match for a filename, and then calls filename completion
comint-dynamic-complete-filename to do file name completion.
(comint-kill-output): Don't kill prompt.
(comint-show-output): Don't move point if it's
visible where it is, and if point is moved, put it after prompt.
(comint-dynamic-complete): Totally new definition.
(comint-dynamic-complete-filename): New name for old
function comint-dynamic-complete, completes files and lists
candidates, souped up for configurability.
(comint-dynamic-complete-variable): New command.
(comint-file-name-autolist): New variable.
(comint-file-name-addsuffix): New variable,
(comint-file-name-recexact): New variable.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 22 Oct 1993 02:57:36 +0000 |
parents | f0abfb1b59fd |
children | 8fc56d171ada |
rev | line source |
---|---|
4687 | 1 /* Merge parameters into a termcap entry string. |
2 Copyright (C) 1985, 1987, 1993 Free Software Foundation, Inc. | |
3 | |
4 This program is free software; you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 2, or (at your option) | |
7 any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
15 along with this program; see the file COPYING. If not, write to | |
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
17 | |
18 /* Emacs config.h may rename various library functions such as malloc. */ | |
19 #ifdef HAVE_CONFIG_H | |
20 #include <config.h> | |
21 #else /* not HAVE_CONFIG_H */ | |
22 | |
23 #if defined(HAVE_STRING_H) || defined(STDC_HEADERS) | |
24 #define bcopy(s, d, n) memcpy ((d), (s), (n)) | |
25 #endif | |
26 | |
27 #ifdef STDC_HEADERS | |
28 #include <stdlib.h> | |
29 #include <string.h> | |
30 #else | |
31 char *malloc (); | |
32 char *realloc (); | |
33 #endif | |
34 | |
35 #endif /* not HAVE_CONFIG_H */ | |
36 | |
37 #ifndef NULL | |
38 #define NULL (char *) 0 | |
39 #endif | |
40 | |
41 #ifndef emacs | |
42 static void | |
43 memory_out () | |
44 { | |
45 write (2, "virtual memory exhausted\n", 25); | |
46 exit (1); | |
47 } | |
48 | |
49 static char * | |
50 xmalloc (size) | |
51 unsigned size; | |
52 { | |
53 register char *tem = malloc (size); | |
54 | |
55 if (!tem) | |
56 memory_out (); | |
57 return tem; | |
58 } | |
59 | |
60 static char * | |
61 xrealloc (ptr, size) | |
62 char *ptr; | |
63 unsigned size; | |
64 { | |
65 register char *tem = realloc (ptr, size); | |
66 | |
67 if (!tem) | |
68 memory_out (); | |
69 return tem; | |
70 } | |
71 #endif /* not emacs */ | |
72 | |
73 /* Assuming STRING is the value of a termcap string entry | |
74 containing `%' constructs to expand parameters, | |
75 merge in parameter values and store result in block OUTSTRING points to. | |
76 LEN is the length of OUTSTRING. If more space is needed, | |
77 a block is allocated with `malloc'. | |
78 | |
79 The value returned is the address of the resulting string. | |
80 This may be OUTSTRING or may be the address of a block got with `malloc'. | |
81 In the latter case, the caller must free the block. | |
82 | |
83 The fourth and following args to tparam serve as the parameter values. */ | |
84 | |
85 static char *tparam1 (); | |
86 | |
87 /* VARARGS 2 */ | |
88 char * | |
89 tparam (string, outstring, len, arg0, arg1, arg2, arg3) | |
90 char *string; | |
91 char *outstring; | |
92 int len; | |
93 int arg0, arg1, arg2, arg3; | |
94 { | |
95 #ifdef NO_ARG_ARRAY | |
96 int arg[4]; | |
97 arg[0] = arg0; | |
98 arg[1] = arg1; | |
99 arg[2] = arg2; | |
100 arg[3] = arg3; | |
101 return tparam1 (string, outstring, len, NULL, NULL, arg); | |
102 #else | |
103 return tparam1 (string, outstring, len, NULL, NULL, &arg0); | |
104 #endif | |
105 } | |
106 | |
107 char *BC; | |
108 char *UP; | |
109 | |
110 static char tgoto_buf[50]; | |
111 | |
112 char * | |
113 tgoto (cm, hpos, vpos) | |
114 char *cm; | |
115 int hpos, vpos; | |
116 { | |
117 int args[2]; | |
118 if (!cm) | |
119 return NULL; | |
120 args[0] = vpos; | |
121 args[1] = hpos; | |
122 return tparam1 (cm, tgoto_buf, 50, UP, BC, args); | |
123 } | |
124 | |
125 static char * | |
126 tparam1 (string, outstring, len, up, left, argp) | |
127 char *string; | |
128 char *outstring; | |
129 int len; | |
130 char *up, *left; | |
131 register int *argp; | |
132 { | |
133 register int c; | |
134 register char *p = string; | |
135 register char *op = outstring; | |
136 char *outend; | |
137 int outlen = 0; | |
138 | |
139 register int tem; | |
140 int *old_argp = argp; | |
141 int doleft = 0; | |
142 int doup = 0; | |
143 | |
144 outend = outstring + len; | |
145 | |
146 while (1) | |
147 { | |
148 /* If the buffer might be too short, make it bigger. */ | |
149 if (op + 5 >= outend) | |
150 { | |
151 register char *new; | |
152 if (outlen == 0) | |
153 { | |
154 outlen = len + 40; | |
155 new = (char *) xmalloc (outlen); | |
156 outend += 40; | |
157 bcopy (outstring, new, op - outstring); | |
158 } | |
159 else | |
160 { | |
161 outend += outlen; | |
162 outlen *= 2; | |
163 new = (char *) xrealloc (outstring, outlen); | |
164 } | |
165 op += new - outstring; | |
166 outend += new - outstring; | |
167 outstring = new; | |
168 } | |
169 c = *p++; | |
170 if (!c) | |
171 break; | |
172 if (c == '%') | |
173 { | |
174 c = *p++; | |
175 tem = *argp; | |
176 switch (c) | |
177 { | |
178 case 'd': /* %d means output in decimal. */ | |
179 if (tem < 10) | |
180 goto onedigit; | |
181 if (tem < 100) | |
182 goto twodigit; | |
183 case '3': /* %3 means output in decimal, 3 digits. */ | |
184 if (tem > 999) | |
185 { | |
186 *op++ = tem / 1000 + '0'; | |
187 tem %= 1000; | |
188 } | |
189 *op++ = tem / 100 + '0'; | |
190 case '2': /* %2 means output in decimal, 2 digits. */ | |
191 twodigit: | |
192 tem %= 100; | |
193 *op++ = tem / 10 + '0'; | |
194 onedigit: | |
195 *op++ = tem % 10 + '0'; | |
196 argp++; | |
197 break; | |
198 | |
199 case 'C': | |
200 /* For c-100: print quotient of value by 96, if nonzero, | |
201 then do like %+. */ | |
202 if (tem >= 96) | |
203 { | |
204 *op++ = tem / 96; | |
205 tem %= 96; | |
206 } | |
207 case '+': /* %+x means add character code of char x. */ | |
208 tem += *p++; | |
209 case '.': /* %. means output as character. */ | |
210 if (left) | |
211 { | |
212 /* If want to forbid output of 0 and \n and \t, | |
213 and this is one of them, increment it. */ | |
214 while (tem == 0 || tem == '\n' || tem == '\t') | |
215 { | |
216 tem++; | |
217 if (argp == old_argp) | |
218 doup++, outend -= strlen (up); | |
219 else | |
220 doleft++, outend -= strlen (left); | |
221 } | |
222 } | |
223 *op++ = tem ? tem : 0200; | |
224 case 'f': /* %f means discard next arg. */ | |
225 argp++; | |
226 break; | |
227 | |
228 case 'b': /* %b means back up one arg (and re-use it). */ | |
229 argp--; | |
230 break; | |
231 | |
232 case 'r': /* %r means interchange following two args. */ | |
233 argp[0] = argp[1]; | |
234 argp[1] = tem; | |
235 old_argp++; | |
236 break; | |
237 | |
238 case '>': /* %>xy means if arg is > char code of x, */ | |
239 if (argp[0] > *p++) /* then add char code of y to the arg, */ | |
240 argp[0] += *p; /* and in any case don't output. */ | |
241 p++; /* Leave the arg to be output later. */ | |
242 break; | |
243 | |
244 case 'a': /* %a means arithmetic. */ | |
245 /* Next character says what operation. | |
246 Add or subtract either a constant or some other arg. */ | |
247 /* First following character is + to add or - to subtract | |
248 or = to assign. */ | |
249 /* Next following char is 'p' and an arg spec | |
250 (0100 plus position of that arg relative to this one) | |
251 or 'c' and a constant stored in a character. */ | |
252 tem = p[2] & 0177; | |
253 if (p[1] == 'p') | |
254 tem = argp[tem - 0100]; | |
255 if (p[0] == '-') | |
256 argp[0] -= tem; | |
257 else if (p[0] == '+') | |
258 argp[0] += tem; | |
259 else if (p[0] == '*') | |
260 argp[0] *= tem; | |
261 else if (p[0] == '/') | |
262 argp[0] /= tem; | |
263 else | |
264 argp[0] = tem; | |
265 | |
266 p += 3; | |
267 break; | |
268 | |
269 case 'i': /* %i means add one to arg, */ | |
270 argp[0] ++; /* and leave it to be output later. */ | |
271 argp[1] ++; /* Increment the following arg, too! */ | |
272 break; | |
273 | |
274 case '%': /* %% means output %; no arg. */ | |
275 goto ordinary; | |
276 | |
277 case 'n': /* %n means xor each of next two args with 140. */ | |
278 argp[0] ^= 0140; | |
279 argp[1] ^= 0140; | |
280 break; | |
281 | |
282 case 'm': /* %m means xor each of next two args with 177. */ | |
283 argp[0] ^= 0177; | |
284 argp[1] ^= 0177; | |
285 break; | |
286 | |
287 case 'B': /* %B means express arg as BCD char code. */ | |
288 argp[0] += 6 * (tem / 10); | |
289 break; | |
290 | |
291 case 'D': /* %D means weird Delta Data transformation. */ | |
292 argp[0] -= 2 * (tem % 16); | |
293 break; | |
294 } | |
295 } | |
296 else | |
297 /* Ordinary character in the argument string. */ | |
298 ordinary: | |
299 *op++ = c; | |
300 } | |
301 *op = 0; | |
302 while (doup-- > 0) | |
303 strcat (op, up); | |
304 while (doleft-- > 0) | |
305 strcat (op, left); | |
306 return outstring; | |
307 } | |
308 | |
309 #ifdef DEBUG | |
310 | |
311 main (argc, argv) | |
312 int argc; | |
313 char **argv; | |
314 { | |
315 char buf[50]; | |
316 int args[3]; | |
317 args[0] = atoi (argv[2]); | |
318 args[1] = atoi (argv[3]); | |
319 args[2] = atoi (argv[4]); | |
320 tparam1 (argv[1], buf, "LEFT", "UP", args); | |
321 printf ("%s\n", buf); | |
322 return 0; | |
323 } | |
324 | |
325 #endif /* DEBUG */ |