Expand PMF_FN_* macros.
[netbsd-mini2440.git] / lib / libedit / map.c
blob67db30130e0c4688e7d4c8f7eab46d0f054a76fc
1 /* $NetBSD: map.c,v 1.24 2006/04/09 01:36:51 christos Exp $ */
3 /*-
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Christos Zoulas of Cornell University.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
35 #include "config.h"
36 #if !defined(lint) && !defined(SCCSID)
37 #if 0
38 static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
39 #else
40 __RCSID("$NetBSD: map.c,v 1.24 2006/04/09 01:36:51 christos Exp $");
41 #endif
42 #endif /* not lint && not SCCSID */
45 * map.c: Editor function definitions
47 #include <stdlib.h>
48 #include "el.h"
50 private void map_print_key(EditLine *, el_action_t *, const Char *);
51 private void map_print_some_keys(EditLine *, el_action_t *, Int, Int);
52 private void map_print_all_keys(EditLine *);
53 private void map_init_nls(EditLine *);
54 private void map_init_meta(EditLine *);
56 /* keymap tables ; should be N_KEYS*sizeof(KEYCMD) bytes long */
59 private const el_action_t el_map_emacs[] = {
60 /* 0 */ EM_SET_MARK, /* ^@ */
61 /* 1 */ ED_MOVE_TO_BEG, /* ^A */
62 /* 2 */ ED_PREV_CHAR, /* ^B */
63 /* 3 */ ED_TTY_SIGINT, /* ^C */
64 /* 4 */ EM_DELETE_OR_LIST, /* ^D */
65 /* 5 */ ED_MOVE_TO_END, /* ^E */
66 /* 6 */ ED_NEXT_CHAR, /* ^F */
67 /* 7 */ ED_UNASSIGNED, /* ^G */
68 /* 8 */ EM_DELETE_PREV_CHAR, /* ^H */
69 /* 9 */ ED_UNASSIGNED, /* ^I */
70 /* 10 */ ED_NEWLINE, /* ^J */
71 /* 11 */ ED_KILL_LINE, /* ^K */
72 /* 12 */ ED_CLEAR_SCREEN, /* ^L */
73 /* 13 */ ED_NEWLINE, /* ^M */
74 /* 14 */ ED_NEXT_HISTORY, /* ^N */
75 /* 15 */ ED_TTY_FLUSH_OUTPUT, /* ^O */
76 /* 16 */ ED_PREV_HISTORY, /* ^P */
77 /* 17 */ ED_TTY_START_OUTPUT, /* ^Q */
78 /* 18 */ ED_REDISPLAY, /* ^R */
79 /* 19 */ ED_TTY_STOP_OUTPUT, /* ^S */
80 /* 20 */ ED_TRANSPOSE_CHARS, /* ^T */
81 /* 21 */ EM_KILL_LINE, /* ^U */
82 /* 22 */ ED_QUOTED_INSERT, /* ^V */
83 /* 23 */ EM_KILL_REGION, /* ^W */
84 /* 24 */ ED_SEQUENCE_LEAD_IN, /* ^X */
85 /* 25 */ EM_YANK, /* ^Y */
86 /* 26 */ ED_TTY_SIGTSTP, /* ^Z */
87 /* 27 */ EM_META_NEXT, /* ^[ */
88 /* 28 */ ED_TTY_SIGQUIT, /* ^\ */
89 /* 29 */ ED_TTY_DSUSP, /* ^] */
90 /* 30 */ ED_UNASSIGNED, /* ^^ */
91 /* 31 */ ED_UNASSIGNED, /* ^_ */
92 /* 32 */ ED_INSERT, /* SPACE */
93 /* 33 */ ED_INSERT, /* ! */
94 /* 34 */ ED_INSERT, /* " */
95 /* 35 */ ED_INSERT, /* # */
96 /* 36 */ ED_INSERT, /* $ */
97 /* 37 */ ED_INSERT, /* % */
98 /* 38 */ ED_INSERT, /* & */
99 /* 39 */ ED_INSERT, /* ' */
100 /* 40 */ ED_INSERT, /* ( */
101 /* 41 */ ED_INSERT, /* ) */
102 /* 42 */ ED_INSERT, /* * */
103 /* 43 */ ED_INSERT, /* + */
104 /* 44 */ ED_INSERT, /* , */
105 /* 45 */ ED_INSERT, /* - */
106 /* 46 */ ED_INSERT, /* . */
107 /* 47 */ ED_INSERT, /* / */
108 /* 48 */ ED_DIGIT, /* 0 */
109 /* 49 */ ED_DIGIT, /* 1 */
110 /* 50 */ ED_DIGIT, /* 2 */
111 /* 51 */ ED_DIGIT, /* 3 */
112 /* 52 */ ED_DIGIT, /* 4 */
113 /* 53 */ ED_DIGIT, /* 5 */
114 /* 54 */ ED_DIGIT, /* 6 */
115 /* 55 */ ED_DIGIT, /* 7 */
116 /* 56 */ ED_DIGIT, /* 8 */
117 /* 57 */ ED_DIGIT, /* 9 */
118 /* 58 */ ED_INSERT, /* : */
119 /* 59 */ ED_INSERT, /* ; */
120 /* 60 */ ED_INSERT, /* < */
121 /* 61 */ ED_INSERT, /* = */
122 /* 62 */ ED_INSERT, /* > */
123 /* 63 */ ED_INSERT, /* ? */
124 /* 64 */ ED_INSERT, /* @ */
125 /* 65 */ ED_INSERT, /* A */
126 /* 66 */ ED_INSERT, /* B */
127 /* 67 */ ED_INSERT, /* C */
128 /* 68 */ ED_INSERT, /* D */
129 /* 69 */ ED_INSERT, /* E */
130 /* 70 */ ED_INSERT, /* F */
131 /* 71 */ ED_INSERT, /* G */
132 /* 72 */ ED_INSERT, /* H */
133 /* 73 */ ED_INSERT, /* I */
134 /* 74 */ ED_INSERT, /* J */
135 /* 75 */ ED_INSERT, /* K */
136 /* 76 */ ED_INSERT, /* L */
137 /* 77 */ ED_INSERT, /* M */
138 /* 78 */ ED_INSERT, /* N */
139 /* 79 */ ED_INSERT, /* O */
140 /* 80 */ ED_INSERT, /* P */
141 /* 81 */ ED_INSERT, /* Q */
142 /* 82 */ ED_INSERT, /* R */
143 /* 83 */ ED_INSERT, /* S */
144 /* 84 */ ED_INSERT, /* T */
145 /* 85 */ ED_INSERT, /* U */
146 /* 86 */ ED_INSERT, /* V */
147 /* 87 */ ED_INSERT, /* W */
148 /* 88 */ ED_INSERT, /* X */
149 /* 89 */ ED_INSERT, /* Y */
150 /* 90 */ ED_INSERT, /* Z */
151 /* 91 */ ED_INSERT, /* [ */
152 /* 92 */ ED_INSERT, /* \ */
153 /* 93 */ ED_INSERT, /* ] */
154 /* 94 */ ED_INSERT, /* ^ */
155 /* 95 */ ED_INSERT, /* _ */
156 /* 96 */ ED_INSERT, /* ` */
157 /* 97 */ ED_INSERT, /* a */
158 /* 98 */ ED_INSERT, /* b */
159 /* 99 */ ED_INSERT, /* c */
160 /* 100 */ ED_INSERT, /* d */
161 /* 101 */ ED_INSERT, /* e */
162 /* 102 */ ED_INSERT, /* f */
163 /* 103 */ ED_INSERT, /* g */
164 /* 104 */ ED_INSERT, /* h */
165 /* 105 */ ED_INSERT, /* i */
166 /* 106 */ ED_INSERT, /* j */
167 /* 107 */ ED_INSERT, /* k */
168 /* 108 */ ED_INSERT, /* l */
169 /* 109 */ ED_INSERT, /* m */
170 /* 110 */ ED_INSERT, /* n */
171 /* 111 */ ED_INSERT, /* o */
172 /* 112 */ ED_INSERT, /* p */
173 /* 113 */ ED_INSERT, /* q */
174 /* 114 */ ED_INSERT, /* r */
175 /* 115 */ ED_INSERT, /* s */
176 /* 116 */ ED_INSERT, /* t */
177 /* 117 */ ED_INSERT, /* u */
178 /* 118 */ ED_INSERT, /* v */
179 /* 119 */ ED_INSERT, /* w */
180 /* 120 */ ED_INSERT, /* x */
181 /* 121 */ ED_INSERT, /* y */
182 /* 122 */ ED_INSERT, /* z */
183 /* 123 */ ED_INSERT, /* { */
184 /* 124 */ ED_INSERT, /* | */
185 /* 125 */ ED_INSERT, /* } */
186 /* 126 */ ED_INSERT, /* ~ */
187 /* 127 */ EM_DELETE_PREV_CHAR, /* ^? */
188 /* 128 */ ED_UNASSIGNED, /* M-^@ */
189 /* 129 */ ED_UNASSIGNED, /* M-^A */
190 /* 130 */ ED_UNASSIGNED, /* M-^B */
191 /* 131 */ ED_UNASSIGNED, /* M-^C */
192 /* 132 */ ED_UNASSIGNED, /* M-^D */
193 /* 133 */ ED_UNASSIGNED, /* M-^E */
194 /* 134 */ ED_UNASSIGNED, /* M-^F */
195 /* 135 */ ED_UNASSIGNED, /* M-^G */
196 /* 136 */ ED_DELETE_PREV_WORD, /* M-^H */
197 /* 137 */ ED_UNASSIGNED, /* M-^I */
198 /* 138 */ ED_UNASSIGNED, /* M-^J */
199 /* 139 */ ED_UNASSIGNED, /* M-^K */
200 /* 140 */ ED_CLEAR_SCREEN, /* M-^L */
201 /* 141 */ ED_UNASSIGNED, /* M-^M */
202 /* 142 */ ED_UNASSIGNED, /* M-^N */
203 /* 143 */ ED_UNASSIGNED, /* M-^O */
204 /* 144 */ ED_UNASSIGNED, /* M-^P */
205 /* 145 */ ED_UNASSIGNED, /* M-^Q */
206 /* 146 */ ED_UNASSIGNED, /* M-^R */
207 /* 147 */ ED_UNASSIGNED, /* M-^S */
208 /* 148 */ ED_UNASSIGNED, /* M-^T */
209 /* 149 */ ED_UNASSIGNED, /* M-^U */
210 /* 150 */ ED_UNASSIGNED, /* M-^V */
211 /* 151 */ ED_UNASSIGNED, /* M-^W */
212 /* 152 */ ED_UNASSIGNED, /* M-^X */
213 /* 153 */ ED_UNASSIGNED, /* M-^Y */
214 /* 154 */ ED_UNASSIGNED, /* M-^Z */
215 /* 155 */ ED_UNASSIGNED, /* M-^[ */
216 /* 156 */ ED_UNASSIGNED, /* M-^\ */
217 /* 157 */ ED_UNASSIGNED, /* M-^] */
218 /* 158 */ ED_UNASSIGNED, /* M-^^ */
219 /* 159 */ EM_COPY_PREV_WORD, /* M-^_ */
220 /* 160 */ ED_UNASSIGNED, /* M-SPACE */
221 /* 161 */ ED_UNASSIGNED, /* M-! */
222 /* 162 */ ED_UNASSIGNED, /* M-" */
223 /* 163 */ ED_UNASSIGNED, /* M-# */
224 /* 164 */ ED_UNASSIGNED, /* M-$ */
225 /* 165 */ ED_UNASSIGNED, /* M-% */
226 /* 166 */ ED_UNASSIGNED, /* M-& */
227 /* 167 */ ED_UNASSIGNED, /* M-' */
228 /* 168 */ ED_UNASSIGNED, /* M-( */
229 /* 169 */ ED_UNASSIGNED, /* M-) */
230 /* 170 */ ED_UNASSIGNED, /* M-* */
231 /* 171 */ ED_UNASSIGNED, /* M-+ */
232 /* 172 */ ED_UNASSIGNED, /* M-, */
233 /* 173 */ ED_UNASSIGNED, /* M-- */
234 /* 174 */ ED_UNASSIGNED, /* M-. */
235 /* 175 */ ED_UNASSIGNED, /* M-/ */
236 /* 176 */ ED_ARGUMENT_DIGIT, /* M-0 */
237 /* 177 */ ED_ARGUMENT_DIGIT, /* M-1 */
238 /* 178 */ ED_ARGUMENT_DIGIT, /* M-2 */
239 /* 179 */ ED_ARGUMENT_DIGIT, /* M-3 */
240 /* 180 */ ED_ARGUMENT_DIGIT, /* M-4 */
241 /* 181 */ ED_ARGUMENT_DIGIT, /* M-5 */
242 /* 182 */ ED_ARGUMENT_DIGIT, /* M-6 */
243 /* 183 */ ED_ARGUMENT_DIGIT, /* M-7 */
244 /* 184 */ ED_ARGUMENT_DIGIT, /* M-8 */
245 /* 185 */ ED_ARGUMENT_DIGIT, /* M-9 */
246 /* 186 */ ED_UNASSIGNED, /* M-: */
247 /* 187 */ ED_UNASSIGNED, /* M-; */
248 /* 188 */ ED_UNASSIGNED, /* M-< */
249 /* 189 */ ED_UNASSIGNED, /* M-= */
250 /* 190 */ ED_UNASSIGNED, /* M-> */
251 /* 191 */ ED_UNASSIGNED, /* M-? */
252 /* 192 */ ED_UNASSIGNED, /* M-@ */
253 /* 193 */ ED_UNASSIGNED, /* M-A */
254 /* 194 */ ED_PREV_WORD, /* M-B */
255 /* 195 */ EM_CAPITOL_CASE, /* M-C */
256 /* 196 */ EM_DELETE_NEXT_WORD, /* M-D */
257 /* 197 */ ED_UNASSIGNED, /* M-E */
258 /* 198 */ EM_NEXT_WORD, /* M-F */
259 /* 199 */ ED_UNASSIGNED, /* M-G */
260 /* 200 */ ED_UNASSIGNED, /* M-H */
261 /* 201 */ ED_UNASSIGNED, /* M-I */
262 /* 202 */ ED_UNASSIGNED, /* M-J */
263 /* 203 */ ED_UNASSIGNED, /* M-K */
264 /* 204 */ EM_LOWER_CASE, /* M-L */
265 /* 205 */ ED_UNASSIGNED, /* M-M */
266 /* 206 */ ED_SEARCH_NEXT_HISTORY, /* M-N */
267 /* 207 */ ED_SEQUENCE_LEAD_IN, /* M-O */
268 /* 208 */ ED_SEARCH_PREV_HISTORY, /* M-P */
269 /* 209 */ ED_UNASSIGNED, /* M-Q */
270 /* 210 */ ED_UNASSIGNED, /* M-R */
271 /* 211 */ ED_UNASSIGNED, /* M-S */
272 /* 212 */ ED_UNASSIGNED, /* M-T */
273 /* 213 */ EM_UPPER_CASE, /* M-U */
274 /* 214 */ ED_UNASSIGNED, /* M-V */
275 /* 215 */ EM_COPY_REGION, /* M-W */
276 /* 216 */ ED_COMMAND, /* M-X */
277 /* 217 */ ED_UNASSIGNED, /* M-Y */
278 /* 218 */ ED_UNASSIGNED, /* M-Z */
279 /* 219 */ ED_SEQUENCE_LEAD_IN, /* M-[ */
280 /* 220 */ ED_UNASSIGNED, /* M-\ */
281 /* 221 */ ED_UNASSIGNED, /* M-] */
282 /* 222 */ ED_UNASSIGNED, /* M-^ */
283 /* 223 */ ED_UNASSIGNED, /* M-_ */
284 /* 223 */ ED_UNASSIGNED, /* M-` */
285 /* 224 */ ED_UNASSIGNED, /* M-a */
286 /* 225 */ ED_PREV_WORD, /* M-b */
287 /* 226 */ EM_CAPITOL_CASE, /* M-c */
288 /* 227 */ EM_DELETE_NEXT_WORD, /* M-d */
289 /* 228 */ ED_UNASSIGNED, /* M-e */
290 /* 229 */ EM_NEXT_WORD, /* M-f */
291 /* 230 */ ED_UNASSIGNED, /* M-g */
292 /* 231 */ ED_UNASSIGNED, /* M-h */
293 /* 232 */ ED_UNASSIGNED, /* M-i */
294 /* 233 */ ED_UNASSIGNED, /* M-j */
295 /* 234 */ ED_UNASSIGNED, /* M-k */
296 /* 235 */ EM_LOWER_CASE, /* M-l */
297 /* 236 */ ED_UNASSIGNED, /* M-m */
298 /* 237 */ ED_SEARCH_NEXT_HISTORY, /* M-n */
299 /* 238 */ ED_UNASSIGNED, /* M-o */
300 /* 239 */ ED_SEARCH_PREV_HISTORY, /* M-p */
301 /* 240 */ ED_UNASSIGNED, /* M-q */
302 /* 241 */ ED_UNASSIGNED, /* M-r */
303 /* 242 */ ED_UNASSIGNED, /* M-s */
304 /* 243 */ ED_UNASSIGNED, /* M-t */
305 /* 244 */ EM_UPPER_CASE, /* M-u */
306 /* 245 */ ED_UNASSIGNED, /* M-v */
307 /* 246 */ EM_COPY_REGION, /* M-w */
308 /* 247 */ ED_COMMAND, /* M-x */
309 /* 248 */ ED_UNASSIGNED, /* M-y */
310 /* 249 */ ED_UNASSIGNED, /* M-z */
311 /* 250 */ ED_UNASSIGNED, /* M-{ */
312 /* 251 */ ED_UNASSIGNED, /* M-| */
313 /* 252 */ ED_UNASSIGNED, /* M-} */
314 /* 253 */ ED_UNASSIGNED, /* M-~ */
315 /* 254 */ ED_DELETE_PREV_WORD /* M-^? */
316 /* 255 */
321 * keymap table for vi. Each index into above tbl; should be
322 * N_KEYS entries long. Vi mode uses a sticky-extend to do command mode:
323 * insert mode characters are in the normal keymap, and command mode
324 * in the extended keymap.
326 private const el_action_t el_map_vi_insert[] = {
327 #ifdef KSHVI
328 /* 0 */ ED_UNASSIGNED, /* ^@ */
329 /* 1 */ ED_INSERT, /* ^A */
330 /* 2 */ ED_INSERT, /* ^B */
331 /* 3 */ ED_INSERT, /* ^C */
332 /* 4 */ VI_LIST_OR_EOF, /* ^D */
333 /* 5 */ ED_INSERT, /* ^E */
334 /* 6 */ ED_INSERT, /* ^F */
335 /* 7 */ ED_INSERT, /* ^G */
336 /* 8 */ VI_DELETE_PREV_CHAR, /* ^H */ /* BackSpace key */
337 /* 9 */ ED_INSERT, /* ^I */ /* Tab Key */
338 /* 10 */ ED_NEWLINE, /* ^J */
339 /* 11 */ ED_INSERT, /* ^K */
340 /* 12 */ ED_INSERT, /* ^L */
341 /* 13 */ ED_NEWLINE, /* ^M */
342 /* 14 */ ED_INSERT, /* ^N */
343 /* 15 */ ED_INSERT, /* ^O */
344 /* 16 */ ED_INSERT, /* ^P */
345 /* 17 */ ED_TTY_START_OUTPUT, /* ^Q */
346 /* 18 */ ED_INSERT, /* ^R */
347 /* 19 */ ED_TTY_STOP_OUTPUT, /* ^S */
348 /* 20 */ ED_INSERT, /* ^T */
349 /* 21 */ VI_KILL_LINE_PREV, /* ^U */
350 /* 22 */ ED_QUOTED_INSERT, /* ^V */
351 /* 23 */ ED_DELETE_PREV_WORD, /* ^W */
352 /* ED_DELETE_PREV_WORD: Only until strt edit pos */
353 /* 24 */ ED_INSERT, /* ^X */
354 /* 25 */ ED_INSERT, /* ^Y */
355 /* 26 */ ED_INSERT, /* ^Z */
356 /* 27 */ VI_COMMAND_MODE, /* ^[ */ /* [ Esc ] key */
357 /* 28 */ ED_TTY_SIGQUIT, /* ^\ */
358 /* 29 */ ED_INSERT, /* ^] */
359 /* 30 */ ED_INSERT, /* ^^ */
360 /* 31 */ ED_INSERT, /* ^_ */
361 #else /* !KSHVI */
363 * NOTE: These mappings do NOT Correspond well
364 * to the KSH VI editing assignments.
365 * On the other and they are convenient and
366 * many people have have gotten used to them.
368 /* 0 */ ED_UNASSIGNED, /* ^@ */
369 /* 1 */ ED_MOVE_TO_BEG, /* ^A */
370 /* 2 */ ED_PREV_CHAR, /* ^B */
371 /* 3 */ ED_TTY_SIGINT, /* ^C */
372 /* 4 */ VI_LIST_OR_EOF, /* ^D */
373 /* 5 */ ED_MOVE_TO_END, /* ^E */
374 /* 6 */ ED_NEXT_CHAR, /* ^F */
375 /* 7 */ ED_UNASSIGNED, /* ^G */
376 /* 8 */ VI_DELETE_PREV_CHAR, /* ^H */ /* BackSpace key */
377 /* 9 */ ED_UNASSIGNED, /* ^I */ /* Tab Key */
378 /* 10 */ ED_NEWLINE, /* ^J */
379 /* 11 */ ED_KILL_LINE, /* ^K */
380 /* 12 */ ED_CLEAR_SCREEN, /* ^L */
381 /* 13 */ ED_NEWLINE, /* ^M */
382 /* 14 */ ED_NEXT_HISTORY, /* ^N */
383 /* 15 */ ED_TTY_FLUSH_OUTPUT, /* ^O */
384 /* 16 */ ED_PREV_HISTORY, /* ^P */
385 /* 17 */ ED_TTY_START_OUTPUT, /* ^Q */
386 /* 18 */ ED_REDISPLAY, /* ^R */
387 /* 19 */ ED_TTY_STOP_OUTPUT, /* ^S */
388 /* 20 */ ED_TRANSPOSE_CHARS, /* ^T */
389 /* 21 */ VI_KILL_LINE_PREV, /* ^U */
390 /* 22 */ ED_QUOTED_INSERT, /* ^V */
391 /* 23 */ ED_DELETE_PREV_WORD, /* ^W */
392 /* 24 */ ED_UNASSIGNED, /* ^X */
393 /* 25 */ ED_TTY_DSUSP, /* ^Y */
394 /* 26 */ ED_TTY_SIGTSTP, /* ^Z */
395 /* 27 */ VI_COMMAND_MODE, /* ^[ */
396 /* 28 */ ED_TTY_SIGQUIT, /* ^\ */
397 /* 29 */ ED_UNASSIGNED, /* ^] */
398 /* 30 */ ED_UNASSIGNED, /* ^^ */
399 /* 31 */ ED_UNASSIGNED, /* ^_ */
400 #endif /* KSHVI */
401 /* 32 */ ED_INSERT, /* SPACE */
402 /* 33 */ ED_INSERT, /* ! */
403 /* 34 */ ED_INSERT, /* " */
404 /* 35 */ ED_INSERT, /* # */
405 /* 36 */ ED_INSERT, /* $ */
406 /* 37 */ ED_INSERT, /* % */
407 /* 38 */ ED_INSERT, /* & */
408 /* 39 */ ED_INSERT, /* ' */
409 /* 40 */ ED_INSERT, /* ( */
410 /* 41 */ ED_INSERT, /* ) */
411 /* 42 */ ED_INSERT, /* * */
412 /* 43 */ ED_INSERT, /* + */
413 /* 44 */ ED_INSERT, /* , */
414 /* 45 */ ED_INSERT, /* - */
415 /* 46 */ ED_INSERT, /* . */
416 /* 47 */ ED_INSERT, /* / */
417 /* 48 */ ED_INSERT, /* 0 */
418 /* 49 */ ED_INSERT, /* 1 */
419 /* 50 */ ED_INSERT, /* 2 */
420 /* 51 */ ED_INSERT, /* 3 */
421 /* 52 */ ED_INSERT, /* 4 */
422 /* 53 */ ED_INSERT, /* 5 */
423 /* 54 */ ED_INSERT, /* 6 */
424 /* 55 */ ED_INSERT, /* 7 */
425 /* 56 */ ED_INSERT, /* 8 */
426 /* 57 */ ED_INSERT, /* 9 */
427 /* 58 */ ED_INSERT, /* : */
428 /* 59 */ ED_INSERT, /* ; */
429 /* 60 */ ED_INSERT, /* < */
430 /* 61 */ ED_INSERT, /* = */
431 /* 62 */ ED_INSERT, /* > */
432 /* 63 */ ED_INSERT, /* ? */
433 /* 64 */ ED_INSERT, /* @ */
434 /* 65 */ ED_INSERT, /* A */
435 /* 66 */ ED_INSERT, /* B */
436 /* 67 */ ED_INSERT, /* C */
437 /* 68 */ ED_INSERT, /* D */
438 /* 69 */ ED_INSERT, /* E */
439 /* 70 */ ED_INSERT, /* F */
440 /* 71 */ ED_INSERT, /* G */
441 /* 72 */ ED_INSERT, /* H */
442 /* 73 */ ED_INSERT, /* I */
443 /* 74 */ ED_INSERT, /* J */
444 /* 75 */ ED_INSERT, /* K */
445 /* 76 */ ED_INSERT, /* L */
446 /* 77 */ ED_INSERT, /* M */
447 /* 78 */ ED_INSERT, /* N */
448 /* 79 */ ED_INSERT, /* O */
449 /* 80 */ ED_INSERT, /* P */
450 /* 81 */ ED_INSERT, /* Q */
451 /* 82 */ ED_INSERT, /* R */
452 /* 83 */ ED_INSERT, /* S */
453 /* 84 */ ED_INSERT, /* T */
454 /* 85 */ ED_INSERT, /* U */
455 /* 86 */ ED_INSERT, /* V */
456 /* 87 */ ED_INSERT, /* W */
457 /* 88 */ ED_INSERT, /* X */
458 /* 89 */ ED_INSERT, /* Y */
459 /* 90 */ ED_INSERT, /* Z */
460 /* 91 */ ED_INSERT, /* [ */
461 /* 92 */ ED_INSERT, /* \ */
462 /* 93 */ ED_INSERT, /* ] */
463 /* 94 */ ED_INSERT, /* ^ */
464 /* 95 */ ED_INSERT, /* _ */
465 /* 96 */ ED_INSERT, /* ` */
466 /* 97 */ ED_INSERT, /* a */
467 /* 98 */ ED_INSERT, /* b */
468 /* 99 */ ED_INSERT, /* c */
469 /* 100 */ ED_INSERT, /* d */
470 /* 101 */ ED_INSERT, /* e */
471 /* 102 */ ED_INSERT, /* f */
472 /* 103 */ ED_INSERT, /* g */
473 /* 104 */ ED_INSERT, /* h */
474 /* 105 */ ED_INSERT, /* i */
475 /* 106 */ ED_INSERT, /* j */
476 /* 107 */ ED_INSERT, /* k */
477 /* 108 */ ED_INSERT, /* l */
478 /* 109 */ ED_INSERT, /* m */
479 /* 110 */ ED_INSERT, /* n */
480 /* 111 */ ED_INSERT, /* o */
481 /* 112 */ ED_INSERT, /* p */
482 /* 113 */ ED_INSERT, /* q */
483 /* 114 */ ED_INSERT, /* r */
484 /* 115 */ ED_INSERT, /* s */
485 /* 116 */ ED_INSERT, /* t */
486 /* 117 */ ED_INSERT, /* u */
487 /* 118 */ ED_INSERT, /* v */
488 /* 119 */ ED_INSERT, /* w */
489 /* 120 */ ED_INSERT, /* x */
490 /* 121 */ ED_INSERT, /* y */
491 /* 122 */ ED_INSERT, /* z */
492 /* 123 */ ED_INSERT, /* { */
493 /* 124 */ ED_INSERT, /* | */
494 /* 125 */ ED_INSERT, /* } */
495 /* 126 */ ED_INSERT, /* ~ */
496 /* 127 */ VI_DELETE_PREV_CHAR, /* ^? */
497 /* 128 */ ED_INSERT, /* M-^@ */
498 /* 129 */ ED_INSERT, /* M-^A */
499 /* 130 */ ED_INSERT, /* M-^B */
500 /* 131 */ ED_INSERT, /* M-^C */
501 /* 132 */ ED_INSERT, /* M-^D */
502 /* 133 */ ED_INSERT, /* M-^E */
503 /* 134 */ ED_INSERT, /* M-^F */
504 /* 135 */ ED_INSERT, /* M-^G */
505 /* 136 */ ED_INSERT, /* M-^H */
506 /* 137 */ ED_INSERT, /* M-^I */
507 /* 138 */ ED_INSERT, /* M-^J */
508 /* 139 */ ED_INSERT, /* M-^K */
509 /* 140 */ ED_INSERT, /* M-^L */
510 /* 141 */ ED_INSERT, /* M-^M */
511 /* 142 */ ED_INSERT, /* M-^N */
512 /* 143 */ ED_INSERT, /* M-^O */
513 /* 144 */ ED_INSERT, /* M-^P */
514 /* 145 */ ED_INSERT, /* M-^Q */
515 /* 146 */ ED_INSERT, /* M-^R */
516 /* 147 */ ED_INSERT, /* M-^S */
517 /* 148 */ ED_INSERT, /* M-^T */
518 /* 149 */ ED_INSERT, /* M-^U */
519 /* 150 */ ED_INSERT, /* M-^V */
520 /* 151 */ ED_INSERT, /* M-^W */
521 /* 152 */ ED_INSERT, /* M-^X */
522 /* 153 */ ED_INSERT, /* M-^Y */
523 /* 154 */ ED_INSERT, /* M-^Z */
524 /* 155 */ ED_INSERT, /* M-^[ */
525 /* 156 */ ED_INSERT, /* M-^\ */
526 /* 157 */ ED_INSERT, /* M-^] */
527 /* 158 */ ED_INSERT, /* M-^^ */
528 /* 159 */ ED_INSERT, /* M-^_ */
529 /* 160 */ ED_INSERT, /* M-SPACE */
530 /* 161 */ ED_INSERT, /* M-! */
531 /* 162 */ ED_INSERT, /* M-" */
532 /* 163 */ ED_INSERT, /* M-# */
533 /* 164 */ ED_INSERT, /* M-$ */
534 /* 165 */ ED_INSERT, /* M-% */
535 /* 166 */ ED_INSERT, /* M-& */
536 /* 167 */ ED_INSERT, /* M-' */
537 /* 168 */ ED_INSERT, /* M-( */
538 /* 169 */ ED_INSERT, /* M-) */
539 /* 170 */ ED_INSERT, /* M-* */
540 /* 171 */ ED_INSERT, /* M-+ */
541 /* 172 */ ED_INSERT, /* M-, */
542 /* 173 */ ED_INSERT, /* M-- */
543 /* 174 */ ED_INSERT, /* M-. */
544 /* 175 */ ED_INSERT, /* M-/ */
545 /* 176 */ ED_INSERT, /* M-0 */
546 /* 177 */ ED_INSERT, /* M-1 */
547 /* 178 */ ED_INSERT, /* M-2 */
548 /* 179 */ ED_INSERT, /* M-3 */
549 /* 180 */ ED_INSERT, /* M-4 */
550 /* 181 */ ED_INSERT, /* M-5 */
551 /* 182 */ ED_INSERT, /* M-6 */
552 /* 183 */ ED_INSERT, /* M-7 */
553 /* 184 */ ED_INSERT, /* M-8 */
554 /* 185 */ ED_INSERT, /* M-9 */
555 /* 186 */ ED_INSERT, /* M-: */
556 /* 187 */ ED_INSERT, /* M-; */
557 /* 188 */ ED_INSERT, /* M-< */
558 /* 189 */ ED_INSERT, /* M-= */
559 /* 190 */ ED_INSERT, /* M-> */
560 /* 191 */ ED_INSERT, /* M-? */
561 /* 192 */ ED_INSERT, /* M-@ */
562 /* 193 */ ED_INSERT, /* M-A */
563 /* 194 */ ED_INSERT, /* M-B */
564 /* 195 */ ED_INSERT, /* M-C */
565 /* 196 */ ED_INSERT, /* M-D */
566 /* 197 */ ED_INSERT, /* M-E */
567 /* 198 */ ED_INSERT, /* M-F */
568 /* 199 */ ED_INSERT, /* M-G */
569 /* 200 */ ED_INSERT, /* M-H */
570 /* 201 */ ED_INSERT, /* M-I */
571 /* 202 */ ED_INSERT, /* M-J */
572 /* 203 */ ED_INSERT, /* M-K */
573 /* 204 */ ED_INSERT, /* M-L */
574 /* 205 */ ED_INSERT, /* M-M */
575 /* 206 */ ED_INSERT, /* M-N */
576 /* 207 */ ED_INSERT, /* M-O */
577 /* 208 */ ED_INSERT, /* M-P */
578 /* 209 */ ED_INSERT, /* M-Q */
579 /* 210 */ ED_INSERT, /* M-R */
580 /* 211 */ ED_INSERT, /* M-S */
581 /* 212 */ ED_INSERT, /* M-T */
582 /* 213 */ ED_INSERT, /* M-U */
583 /* 214 */ ED_INSERT, /* M-V */
584 /* 215 */ ED_INSERT, /* M-W */
585 /* 216 */ ED_INSERT, /* M-X */
586 /* 217 */ ED_INSERT, /* M-Y */
587 /* 218 */ ED_INSERT, /* M-Z */
588 /* 219 */ ED_INSERT, /* M-[ */
589 /* 220 */ ED_INSERT, /* M-\ */
590 /* 221 */ ED_INSERT, /* M-] */
591 /* 222 */ ED_INSERT, /* M-^ */
592 /* 223 */ ED_INSERT, /* M-_ */
593 /* 224 */ ED_INSERT, /* M-` */
594 /* 225 */ ED_INSERT, /* M-a */
595 /* 226 */ ED_INSERT, /* M-b */
596 /* 227 */ ED_INSERT, /* M-c */
597 /* 228 */ ED_INSERT, /* M-d */
598 /* 229 */ ED_INSERT, /* M-e */
599 /* 230 */ ED_INSERT, /* M-f */
600 /* 231 */ ED_INSERT, /* M-g */
601 /* 232 */ ED_INSERT, /* M-h */
602 /* 233 */ ED_INSERT, /* M-i */
603 /* 234 */ ED_INSERT, /* M-j */
604 /* 235 */ ED_INSERT, /* M-k */
605 /* 236 */ ED_INSERT, /* M-l */
606 /* 237 */ ED_INSERT, /* M-m */
607 /* 238 */ ED_INSERT, /* M-n */
608 /* 239 */ ED_INSERT, /* M-o */
609 /* 240 */ ED_INSERT, /* M-p */
610 /* 241 */ ED_INSERT, /* M-q */
611 /* 242 */ ED_INSERT, /* M-r */
612 /* 243 */ ED_INSERT, /* M-s */
613 /* 244 */ ED_INSERT, /* M-t */
614 /* 245 */ ED_INSERT, /* M-u */
615 /* 246 */ ED_INSERT, /* M-v */
616 /* 247 */ ED_INSERT, /* M-w */
617 /* 248 */ ED_INSERT, /* M-x */
618 /* 249 */ ED_INSERT, /* M-y */
619 /* 250 */ ED_INSERT, /* M-z */
620 /* 251 */ ED_INSERT, /* M-{ */
621 /* 252 */ ED_INSERT, /* M-| */
622 /* 253 */ ED_INSERT, /* M-} */
623 /* 254 */ ED_INSERT, /* M-~ */
624 /* 255 */ ED_INSERT /* M-^? */
627 private const el_action_t el_map_vi_command[] = {
628 /* 0 */ ED_UNASSIGNED, /* ^@ */
629 /* 1 */ ED_MOVE_TO_BEG, /* ^A */
630 /* 2 */ ED_UNASSIGNED, /* ^B */
631 /* 3 */ ED_TTY_SIGINT, /* ^C */
632 /* 4 */ ED_UNASSIGNED, /* ^D */
633 /* 5 */ ED_MOVE_TO_END, /* ^E */
634 /* 6 */ ED_UNASSIGNED, /* ^F */
635 /* 7 */ ED_UNASSIGNED, /* ^G */
636 /* 8 */ ED_DELETE_PREV_CHAR, /* ^H */
637 /* 9 */ ED_UNASSIGNED, /* ^I */
638 /* 10 */ ED_NEWLINE, /* ^J */
639 /* 11 */ ED_KILL_LINE, /* ^K */
640 /* 12 */ ED_CLEAR_SCREEN, /* ^L */
641 /* 13 */ ED_NEWLINE, /* ^M */
642 /* 14 */ ED_NEXT_HISTORY, /* ^N */
643 /* 15 */ ED_TTY_FLUSH_OUTPUT, /* ^O */
644 /* 16 */ ED_PREV_HISTORY, /* ^P */
645 /* 17 */ ED_TTY_START_OUTPUT, /* ^Q */
646 /* 18 */ ED_REDISPLAY, /* ^R */
647 /* 19 */ ED_TTY_STOP_OUTPUT, /* ^S */
648 /* 20 */ ED_UNASSIGNED, /* ^T */
649 /* 21 */ VI_KILL_LINE_PREV, /* ^U */
650 /* 22 */ ED_UNASSIGNED, /* ^V */
651 /* 23 */ ED_DELETE_PREV_WORD, /* ^W */
652 /* 24 */ ED_UNASSIGNED, /* ^X */
653 /* 25 */ ED_UNASSIGNED, /* ^Y */
654 /* 26 */ ED_UNASSIGNED, /* ^Z */
655 /* 27 */ EM_META_NEXT, /* ^[ */
656 /* 28 */ ED_TTY_SIGQUIT, /* ^\ */
657 /* 29 */ ED_UNASSIGNED, /* ^] */
658 /* 30 */ ED_UNASSIGNED, /* ^^ */
659 /* 31 */ ED_UNASSIGNED, /* ^_ */
660 /* 32 */ ED_NEXT_CHAR, /* SPACE */
661 /* 33 */ ED_UNASSIGNED, /* ! */
662 /* 34 */ ED_UNASSIGNED, /* " */
663 /* 35 */ VI_COMMENT_OUT, /* # */
664 /* 36 */ ED_MOVE_TO_END, /* $ */
665 /* 37 */ VI_MATCH, /* % */
666 /* 38 */ ED_UNASSIGNED, /* & */
667 /* 39 */ ED_UNASSIGNED, /* ' */
668 /* 40 */ ED_UNASSIGNED, /* ( */
669 /* 41 */ ED_UNASSIGNED, /* ) */
670 /* 42 */ ED_UNASSIGNED, /* * */
671 /* 43 */ ED_NEXT_HISTORY, /* + */
672 /* 44 */ VI_REPEAT_PREV_CHAR, /* , */
673 /* 45 */ ED_PREV_HISTORY, /* - */
674 /* 46 */ VI_REDO, /* . */
675 /* 47 */ VI_SEARCH_PREV, /* / */
676 /* 48 */ VI_ZERO, /* 0 */
677 /* 49 */ ED_ARGUMENT_DIGIT, /* 1 */
678 /* 50 */ ED_ARGUMENT_DIGIT, /* 2 */
679 /* 51 */ ED_ARGUMENT_DIGIT, /* 3 */
680 /* 52 */ ED_ARGUMENT_DIGIT, /* 4 */
681 /* 53 */ ED_ARGUMENT_DIGIT, /* 5 */
682 /* 54 */ ED_ARGUMENT_DIGIT, /* 6 */
683 /* 55 */ ED_ARGUMENT_DIGIT, /* 7 */
684 /* 56 */ ED_ARGUMENT_DIGIT, /* 8 */
685 /* 57 */ ED_ARGUMENT_DIGIT, /* 9 */
686 /* 58 */ ED_COMMAND, /* : */
687 /* 59 */ VI_REPEAT_NEXT_CHAR, /* ; */
688 /* 60 */ ED_UNASSIGNED, /* < */
689 /* 61 */ ED_UNASSIGNED, /* = */
690 /* 62 */ ED_UNASSIGNED, /* > */
691 /* 63 */ VI_SEARCH_NEXT, /* ? */
692 /* 64 */ VI_ALIAS, /* @ */
693 /* 65 */ VI_ADD_AT_EOL, /* A */
694 /* 66 */ VI_PREV_BIG_WORD, /* B */
695 /* 67 */ VI_CHANGE_TO_EOL, /* C */
696 /* 68 */ ED_KILL_LINE, /* D */
697 /* 69 */ VI_END_BIG_WORD, /* E */
698 /* 70 */ VI_PREV_CHAR, /* F */
699 /* 71 */ VI_TO_HISTORY_LINE, /* G */
700 /* 72 */ ED_UNASSIGNED, /* H */
701 /* 73 */ VI_INSERT_AT_BOL, /* I */
702 /* 74 */ ED_SEARCH_NEXT_HISTORY, /* J */
703 /* 75 */ ED_SEARCH_PREV_HISTORY, /* K */
704 /* 76 */ ED_UNASSIGNED, /* L */
705 /* 77 */ ED_UNASSIGNED, /* M */
706 /* 78 */ VI_REPEAT_SEARCH_PREV, /* N */
707 /* 79 */ ED_SEQUENCE_LEAD_IN, /* O */
708 /* 80 */ VI_PASTE_PREV, /* P */
709 /* 81 */ ED_UNASSIGNED, /* Q */
710 /* 82 */ VI_REPLACE_MODE, /* R */
711 /* 83 */ VI_SUBSTITUTE_LINE, /* S */
712 /* 84 */ VI_TO_PREV_CHAR, /* T */
713 /* 85 */ VI_UNDO_LINE, /* U */
714 /* 86 */ ED_UNASSIGNED, /* V */
715 /* 87 */ VI_NEXT_BIG_WORD, /* W */
716 /* 88 */ ED_DELETE_PREV_CHAR, /* X */
717 /* 89 */ VI_YANK_END, /* Y */
718 /* 90 */ ED_UNASSIGNED, /* Z */
719 /* 91 */ ED_SEQUENCE_LEAD_IN, /* [ */
720 /* 92 */ ED_UNASSIGNED, /* \ */
721 /* 93 */ ED_UNASSIGNED, /* ] */
722 /* 94 */ ED_MOVE_TO_BEG, /* ^ */
723 /* 95 */ VI_HISTORY_WORD, /* _ */
724 /* 96 */ ED_UNASSIGNED, /* ` */
725 /* 97 */ VI_ADD, /* a */
726 /* 98 */ VI_PREV_WORD, /* b */
727 /* 99 */ VI_CHANGE_META, /* c */
728 /* 100 */ VI_DELETE_META, /* d */
729 /* 101 */ VI_END_WORD, /* e */
730 /* 102 */ VI_NEXT_CHAR, /* f */
731 /* 103 */ ED_UNASSIGNED, /* g */
732 /* 104 */ ED_PREV_CHAR, /* h */
733 /* 105 */ VI_INSERT, /* i */
734 /* 106 */ ED_NEXT_HISTORY, /* j */
735 /* 107 */ ED_PREV_HISTORY, /* k */
736 /* 108 */ ED_NEXT_CHAR, /* l */
737 /* 109 */ ED_UNASSIGNED, /* m */
738 /* 110 */ VI_REPEAT_SEARCH_NEXT, /* n */
739 /* 111 */ ED_UNASSIGNED, /* o */
740 /* 112 */ VI_PASTE_NEXT, /* p */
741 /* 113 */ ED_UNASSIGNED, /* q */
742 /* 114 */ VI_REPLACE_CHAR, /* r */
743 /* 115 */ VI_SUBSTITUTE_CHAR, /* s */
744 /* 116 */ VI_TO_NEXT_CHAR, /* t */
745 /* 117 */ VI_UNDO, /* u */
746 /* 118 */ VI_HISTEDIT, /* v */
747 /* 119 */ VI_NEXT_WORD, /* w */
748 /* 120 */ ED_DELETE_NEXT_CHAR, /* x */
749 /* 121 */ VI_YANK, /* y */
750 /* 122 */ ED_UNASSIGNED, /* z */
751 /* 123 */ ED_UNASSIGNED, /* { */
752 /* 124 */ VI_TO_COLUMN, /* | */
753 /* 125 */ ED_UNASSIGNED, /* } */
754 /* 126 */ VI_CHANGE_CASE, /* ~ */
755 /* 127 */ ED_DELETE_PREV_CHAR, /* ^? */
756 /* 128 */ ED_UNASSIGNED, /* M-^@ */
757 /* 129 */ ED_UNASSIGNED, /* M-^A */
758 /* 130 */ ED_UNASSIGNED, /* M-^B */
759 /* 131 */ ED_UNASSIGNED, /* M-^C */
760 /* 132 */ ED_UNASSIGNED, /* M-^D */
761 /* 133 */ ED_UNASSIGNED, /* M-^E */
762 /* 134 */ ED_UNASSIGNED, /* M-^F */
763 /* 135 */ ED_UNASSIGNED, /* M-^G */
764 /* 136 */ ED_UNASSIGNED, /* M-^H */
765 /* 137 */ ED_UNASSIGNED, /* M-^I */
766 /* 138 */ ED_UNASSIGNED, /* M-^J */
767 /* 139 */ ED_UNASSIGNED, /* M-^K */
768 /* 140 */ ED_UNASSIGNED, /* M-^L */
769 /* 141 */ ED_UNASSIGNED, /* M-^M */
770 /* 142 */ ED_UNASSIGNED, /* M-^N */
771 /* 143 */ ED_UNASSIGNED, /* M-^O */
772 /* 144 */ ED_UNASSIGNED, /* M-^P */
773 /* 145 */ ED_UNASSIGNED, /* M-^Q */
774 /* 146 */ ED_UNASSIGNED, /* M-^R */
775 /* 147 */ ED_UNASSIGNED, /* M-^S */
776 /* 148 */ ED_UNASSIGNED, /* M-^T */
777 /* 149 */ ED_UNASSIGNED, /* M-^U */
778 /* 150 */ ED_UNASSIGNED, /* M-^V */
779 /* 151 */ ED_UNASSIGNED, /* M-^W */
780 /* 152 */ ED_UNASSIGNED, /* M-^X */
781 /* 153 */ ED_UNASSIGNED, /* M-^Y */
782 /* 154 */ ED_UNASSIGNED, /* M-^Z */
783 /* 155 */ ED_UNASSIGNED, /* M-^[ */
784 /* 156 */ ED_UNASSIGNED, /* M-^\ */
785 /* 157 */ ED_UNASSIGNED, /* M-^] */
786 /* 158 */ ED_UNASSIGNED, /* M-^^ */
787 /* 159 */ ED_UNASSIGNED, /* M-^_ */
788 /* 160 */ ED_UNASSIGNED, /* M-SPACE */
789 /* 161 */ ED_UNASSIGNED, /* M-! */
790 /* 162 */ ED_UNASSIGNED, /* M-" */
791 /* 163 */ ED_UNASSIGNED, /* M-# */
792 /* 164 */ ED_UNASSIGNED, /* M-$ */
793 /* 165 */ ED_UNASSIGNED, /* M-% */
794 /* 166 */ ED_UNASSIGNED, /* M-& */
795 /* 167 */ ED_UNASSIGNED, /* M-' */
796 /* 168 */ ED_UNASSIGNED, /* M-( */
797 /* 169 */ ED_UNASSIGNED, /* M-) */
798 /* 170 */ ED_UNASSIGNED, /* M-* */
799 /* 171 */ ED_UNASSIGNED, /* M-+ */
800 /* 172 */ ED_UNASSIGNED, /* M-, */
801 /* 173 */ ED_UNASSIGNED, /* M-- */
802 /* 174 */ ED_UNASSIGNED, /* M-. */
803 /* 175 */ ED_UNASSIGNED, /* M-/ */
804 /* 176 */ ED_UNASSIGNED, /* M-0 */
805 /* 177 */ ED_UNASSIGNED, /* M-1 */
806 /* 178 */ ED_UNASSIGNED, /* M-2 */
807 /* 179 */ ED_UNASSIGNED, /* M-3 */
808 /* 180 */ ED_UNASSIGNED, /* M-4 */
809 /* 181 */ ED_UNASSIGNED, /* M-5 */
810 /* 182 */ ED_UNASSIGNED, /* M-6 */
811 /* 183 */ ED_UNASSIGNED, /* M-7 */
812 /* 184 */ ED_UNASSIGNED, /* M-8 */
813 /* 185 */ ED_UNASSIGNED, /* M-9 */
814 /* 186 */ ED_UNASSIGNED, /* M-: */
815 /* 187 */ ED_UNASSIGNED, /* M-; */
816 /* 188 */ ED_UNASSIGNED, /* M-< */
817 /* 189 */ ED_UNASSIGNED, /* M-= */
818 /* 190 */ ED_UNASSIGNED, /* M-> */
819 /* 191 */ ED_UNASSIGNED, /* M-? */
820 /* 192 */ ED_UNASSIGNED, /* M-@ */
821 /* 193 */ ED_UNASSIGNED, /* M-A */
822 /* 194 */ ED_UNASSIGNED, /* M-B */
823 /* 195 */ ED_UNASSIGNED, /* M-C */
824 /* 196 */ ED_UNASSIGNED, /* M-D */
825 /* 197 */ ED_UNASSIGNED, /* M-E */
826 /* 198 */ ED_UNASSIGNED, /* M-F */
827 /* 199 */ ED_UNASSIGNED, /* M-G */
828 /* 200 */ ED_UNASSIGNED, /* M-H */
829 /* 201 */ ED_UNASSIGNED, /* M-I */
830 /* 202 */ ED_UNASSIGNED, /* M-J */
831 /* 203 */ ED_UNASSIGNED, /* M-K */
832 /* 204 */ ED_UNASSIGNED, /* M-L */
833 /* 205 */ ED_UNASSIGNED, /* M-M */
834 /* 206 */ ED_UNASSIGNED, /* M-N */
835 /* 207 */ ED_SEQUENCE_LEAD_IN, /* M-O */
836 /* 208 */ ED_UNASSIGNED, /* M-P */
837 /* 209 */ ED_UNASSIGNED, /* M-Q */
838 /* 210 */ ED_UNASSIGNED, /* M-R */
839 /* 211 */ ED_UNASSIGNED, /* M-S */
840 /* 212 */ ED_UNASSIGNED, /* M-T */
841 /* 213 */ ED_UNASSIGNED, /* M-U */
842 /* 214 */ ED_UNASSIGNED, /* M-V */
843 /* 215 */ ED_UNASSIGNED, /* M-W */
844 /* 216 */ ED_UNASSIGNED, /* M-X */
845 /* 217 */ ED_UNASSIGNED, /* M-Y */
846 /* 218 */ ED_UNASSIGNED, /* M-Z */
847 /* 219 */ ED_SEQUENCE_LEAD_IN, /* M-[ */
848 /* 220 */ ED_UNASSIGNED, /* M-\ */
849 /* 221 */ ED_UNASSIGNED, /* M-] */
850 /* 222 */ ED_UNASSIGNED, /* M-^ */
851 /* 223 */ ED_UNASSIGNED, /* M-_ */
852 /* 224 */ ED_UNASSIGNED, /* M-` */
853 /* 225 */ ED_UNASSIGNED, /* M-a */
854 /* 226 */ ED_UNASSIGNED, /* M-b */
855 /* 227 */ ED_UNASSIGNED, /* M-c */
856 /* 228 */ ED_UNASSIGNED, /* M-d */
857 /* 229 */ ED_UNASSIGNED, /* M-e */
858 /* 230 */ ED_UNASSIGNED, /* M-f */
859 /* 231 */ ED_UNASSIGNED, /* M-g */
860 /* 232 */ ED_UNASSIGNED, /* M-h */
861 /* 233 */ ED_UNASSIGNED, /* M-i */
862 /* 234 */ ED_UNASSIGNED, /* M-j */
863 /* 235 */ ED_UNASSIGNED, /* M-k */
864 /* 236 */ ED_UNASSIGNED, /* M-l */
865 /* 237 */ ED_UNASSIGNED, /* M-m */
866 /* 238 */ ED_UNASSIGNED, /* M-n */
867 /* 239 */ ED_UNASSIGNED, /* M-o */
868 /* 240 */ ED_UNASSIGNED, /* M-p */
869 /* 241 */ ED_UNASSIGNED, /* M-q */
870 /* 242 */ ED_UNASSIGNED, /* M-r */
871 /* 243 */ ED_UNASSIGNED, /* M-s */
872 /* 244 */ ED_UNASSIGNED, /* M-t */
873 /* 245 */ ED_UNASSIGNED, /* M-u */
874 /* 246 */ ED_UNASSIGNED, /* M-v */
875 /* 247 */ ED_UNASSIGNED, /* M-w */
876 /* 248 */ ED_UNASSIGNED, /* M-x */
877 /* 249 */ ED_UNASSIGNED, /* M-y */
878 /* 250 */ ED_UNASSIGNED, /* M-z */
879 /* 251 */ ED_UNASSIGNED, /* M-{ */
880 /* 252 */ ED_UNASSIGNED, /* M-| */
881 /* 253 */ ED_UNASSIGNED, /* M-} */
882 /* 254 */ ED_UNASSIGNED, /* M-~ */
883 /* 255 */ ED_UNASSIGNED /* M-^? */
887 /* map_init():
888 * Initialize and allocate the maps
890 protected int
891 map_init(EditLine *el)
895 * Make sure those are correct before starting.
897 #ifdef MAP_DEBUG
898 if (sizeof(el_map_emacs) != N_KEYS * sizeof(el_action_t))
899 EL_ABORT((el->errfile, "Emacs map incorrect\n"));
900 if (sizeof(el_map_vi_command) != N_KEYS * sizeof(el_action_t))
901 EL_ABORT((el->errfile, "Vi command map incorrect\n"));
902 if (sizeof(el_map_vi_insert) != N_KEYS * sizeof(el_action_t))
903 EL_ABORT((el->errfile, "Vi insert map incorrect\n"));
904 #endif
906 el->el_map.alt = (el_action_t *)el_malloc(sizeof(el_action_t) * N_KEYS);
907 if (el->el_map.alt == NULL)
908 return (-1);
909 el->el_map.key = (el_action_t *)el_malloc(sizeof(el_action_t) * N_KEYS);
910 if (el->el_map.key == NULL)
911 return (-1);
912 el->el_map.emacs = el_map_emacs;
913 el->el_map.vic = el_map_vi_command;
914 el->el_map.vii = el_map_vi_insert;
915 el->el_map.help = (el_bindings_t *) el_malloc(sizeof(el_bindings_t) *
916 EL_NUM_FCNS);
917 if (el->el_map.help == NULL)
918 return (-1);
919 (void) memcpy(el->el_map.help, help__get(),
920 sizeof(el_bindings_t) * EL_NUM_FCNS);
921 el->el_map.func = (el_func_t *)el_malloc(sizeof(el_func_t) *
922 EL_NUM_FCNS);
923 if (el->el_map.func == NULL)
924 return (-1);
925 memcpy(el->el_map.func, func__get(), sizeof(el_func_t) * EL_NUM_FCNS);
926 el->el_map.nfunc = EL_NUM_FCNS;
928 #ifdef VIDEFAULT
929 map_init_vi(el);
930 #else
931 map_init_emacs(el);
932 #endif /* VIDEFAULT */
933 return (0);
937 /* map_end():
938 * Free the space taken by the editor maps
940 protected void
941 map_end(EditLine *el)
944 el_free((ptr_t) el->el_map.alt);
945 el->el_map.alt = NULL;
946 el_free((ptr_t) el->el_map.key);
947 el->el_map.key = NULL;
948 el->el_map.emacs = NULL;
949 el->el_map.vic = NULL;
950 el->el_map.vii = NULL;
951 el_free((ptr_t) el->el_map.help);
952 el->el_map.help = NULL;
953 el_free((ptr_t) el->el_map.func);
954 el->el_map.func = NULL;
958 /* map_init_nls():
959 * Find all the printable keys and bind them to self insert
961 private void
962 map_init_nls(EditLine *el)
964 int i;
966 el_action_t *map = el->el_map.key;
968 for (i = 0200; i <= 0377; i++)
969 if (Isprint(i))
970 map[i] = ED_INSERT;
974 /* map_init_meta():
975 * Bind all the meta keys to the appropriate ESC-<key> sequence
977 private void
978 map_init_meta(EditLine *el)
980 Char buf[3];
981 int i;
982 el_action_t *map = el->el_map.key;
983 el_action_t *alt = el->el_map.alt;
985 for (i = 0; i <= 0377 && map[i] != EM_META_NEXT; i++)
986 continue;
988 if (i > 0377) {
989 for (i = 0; i <= 0377 && alt[i] != EM_META_NEXT; i++)
990 continue;
991 if (i > 0377) {
992 i = 033;
993 if (el->el_map.type == MAP_VI)
994 map = alt;
995 } else
996 map = alt;
998 buf[0] = (Char) i;
999 buf[2] = 0;
1000 for (i = 0200; i <= 0377; i++)
1001 switch (map[i]) {
1002 case ED_INSERT:
1003 case ED_UNASSIGNED:
1004 case ED_SEQUENCE_LEAD_IN:
1005 break;
1006 default:
1007 buf[1] = i & 0177;
1008 key_add(el, buf, key_map_cmd(el, (int) map[i]), XK_CMD);
1009 break;
1011 map[(int) buf[0]] = ED_SEQUENCE_LEAD_IN;
1015 /* map_init_vi():
1016 * Initialize the vi bindings
1018 protected void
1019 map_init_vi(EditLine *el)
1021 int i;
1022 el_action_t *key = el->el_map.key;
1023 el_action_t *alt = el->el_map.alt;
1024 const el_action_t *vii = el->el_map.vii;
1025 const el_action_t *vic = el->el_map.vic;
1027 el->el_map.type = MAP_VI;
1028 el->el_map.current = el->el_map.key;
1030 key_reset(el);
1032 for (i = 0; i < N_KEYS; i++) {
1033 key[i] = vii[i];
1034 alt[i] = vic[i];
1037 map_init_meta(el);
1038 map_init_nls(el);
1040 tty_bind_char(el, 1);
1041 term_bind_arrow(el);
1045 /* map_init_emacs():
1046 * Initialize the emacs bindings
1048 protected void
1049 map_init_emacs(EditLine *el)
1051 int i;
1052 Char buf[3];
1053 el_action_t *key = el->el_map.key;
1054 el_action_t *alt = el->el_map.alt;
1055 const el_action_t *emacs = el->el_map.emacs;
1057 el->el_map.type = MAP_EMACS;
1058 el->el_map.current = el->el_map.key;
1059 key_reset(el);
1061 for (i = 0; i < N_KEYS; i++) {
1062 key[i] = emacs[i];
1063 alt[i] = ED_UNASSIGNED;
1066 map_init_meta(el);
1067 map_init_nls(el);
1069 buf[0] = CONTROL('X');
1070 buf[1] = CONTROL('X');
1071 buf[2] = 0;
1072 key_add(el, buf, key_map_cmd(el, EM_EXCHANGE_MARK), XK_CMD);
1074 tty_bind_char(el, 1);
1075 term_bind_arrow(el);
1079 /* map_set_editor():
1080 * Set the editor
1082 protected int
1083 map_set_editor(EditLine *el, Char *editor)
1086 if (Strcmp(editor, STR("emacs")) == 0) {
1087 map_init_emacs(el);
1088 return (0);
1090 if (Strcmp(editor, STR("vi")) == 0) {
1091 map_init_vi(el);
1092 return (0);
1094 return (-1);
1098 /* map_get_editor():
1099 * Retrieve the editor
1101 protected int
1102 map_get_editor(EditLine *el, const Char **editor)
1105 if (editor == NULL)
1106 return (-1);
1107 switch (el->el_map.type) {
1108 case MAP_EMACS:
1109 *editor = STR("emacs");
1110 return (0);
1111 case MAP_VI:
1112 *editor = STR("vi");
1113 return (0);
1115 return (-1);
1119 /* map_print_key():
1120 * Print the function description for 1 key
1122 private void
1123 map_print_key(EditLine *el, el_action_t *map, const Char *in)
1125 char outbuf[EL_BUFSIZ];
1126 el_bindings_t *bp, *ep;
1128 if (in[0] == '\0' || in[1] == '\0') {
1129 (void) key__decode_str(in, outbuf, sizeof(outbuf), "");
1130 ep = &el->el_map.help[el->el_map.nfunc];
1131 for (bp = el->el_map.help; bp < ep; bp++)
1132 if (bp->func == map[(unsigned char) *in]) {
1133 (void) fprintf(el->el_outfile,
1134 "%s\t->\t" FSTR "\n", outbuf, bp->name);
1135 return;
1137 } else
1138 key_print(el, in);
1142 /* map_print_some_keys():
1143 * Print keys from first to last
1145 private void
1146 map_print_some_keys(EditLine *el, el_action_t *map, Int first, Int last)
1148 el_bindings_t *bp, *ep;
1149 Char firstbuf[2], lastbuf[2];
1150 char unparsbuf[EL_BUFSIZ], extrabuf[EL_BUFSIZ];
1152 firstbuf[0] = first;
1153 firstbuf[1] = 0;
1154 lastbuf[0] = last;
1155 lastbuf[1] = 0;
1156 if (map[first] == ED_UNASSIGNED) {
1157 if (first == last) {
1158 (void) key__decode_str(firstbuf, unparsbuf,
1159 sizeof(unparsbuf), STRQQ);
1160 (void) fprintf(el->el_outfile,
1161 "%-15s-> is undefined\n", unparsbuf);
1163 return;
1165 ep = &el->el_map.help[el->el_map.nfunc];
1166 for (bp = el->el_map.help; bp < ep; bp++) {
1167 if (bp->func == map[first]) {
1168 if (first == last) {
1169 (void) key__decode_str(firstbuf, unparsbuf,
1170 sizeof(unparsbuf), STRQQ);
1171 (void) fprintf(el->el_outfile, "%-15s-> " FSTR "\n",
1172 unparsbuf, bp->name);
1173 } else {
1174 (void) key__decode_str(firstbuf, unparsbuf,
1175 sizeof(unparsbuf), STRQQ);
1176 (void) key__decode_str(lastbuf, extrabuf,
1177 sizeof(extrabuf), STRQQ);
1178 (void) fprintf(el->el_outfile,
1179 "%-4s to %-7s-> " FSTR "\n",
1180 unparsbuf, extrabuf, bp->name);
1182 return;
1185 #ifdef MAP_DEBUG
1186 if (map == el->el_map.key) {
1187 (void) key__decode_str(firstbuf, unparsbuf,
1188 sizeof(unparsbuf), STRQQ);
1189 (void) fprintf(el->el_outfile,
1190 "BUG!!! %s isn't bound to anything.\n", unparsbuf);
1191 (void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n",
1192 first, el->el_map.key[first]);
1193 } else {
1194 (void) key__decode_str(firstbuf, unparsbuf,
1195 sizeof(unparsbuf), STRQQ);
1196 (void) fprintf(el->el_outfile,
1197 "BUG!!! %s isn't bound to anything.\n", unparsbuf);
1198 (void) fprintf(el->el_outfile, "el->el_map.alt[%d] == %d\n",
1199 first, el->el_map.alt[first]);
1201 #endif
1202 EL_ABORT((el->el_errfile, "Error printing keys\n"));
1206 /* map_print_all_keys():
1207 * Print the function description for all keys.
1209 private void
1210 map_print_all_keys(EditLine *el)
1212 int prev, i;
1214 (void) fprintf(el->el_outfile, "Standard key bindings\n");
1215 prev = 0;
1216 for (i = 0; i < N_KEYS; i++) {
1217 if (el->el_map.key[prev] == el->el_map.key[i])
1218 continue;
1219 map_print_some_keys(el, el->el_map.key, prev, i - 1);
1220 prev = i;
1222 map_print_some_keys(el, el->el_map.key, prev, i - 1);
1224 (void) fprintf(el->el_outfile, "Alternative key bindings\n");
1225 prev = 0;
1226 for (i = 0; i < N_KEYS; i++) {
1227 if (el->el_map.alt[prev] == el->el_map.alt[i])
1228 continue;
1229 map_print_some_keys(el, el->el_map.alt, prev, i - 1);
1230 prev = i;
1232 map_print_some_keys(el, el->el_map.alt, prev, i - 1);
1234 (void) fprintf(el->el_outfile, "Multi-character bindings\n");
1235 key_print(el, STR(""));
1236 (void) fprintf(el->el_outfile, "Arrow key bindings\n");
1237 term_print_arrow(el, STR(""));
1241 /* map_bind():
1242 * Add/remove/change bindings
1244 protected int
1245 map_bind(EditLine *el, int argc, const Char **argv)
1247 el_action_t *map;
1248 int ntype, rem;
1249 const Char *p;
1250 Char inbuf[EL_BUFSIZ];
1251 Char outbuf[EL_BUFSIZ];
1252 const Char *in = NULL;
1253 Char *out = NULL;
1254 el_bindings_t *bp, *ep;
1255 int cmd;
1256 int key;
1258 if (argv == NULL)
1259 return (-1);
1261 map = el->el_map.key;
1262 ntype = XK_CMD;
1263 key = rem = 0;
1264 for (argc = 1; (p = argv[argc]) != NULL; argc++)
1265 if (p[0] == '-')
1266 switch (p[1]) {
1267 case 'a':
1268 map = el->el_map.alt;
1269 break;
1271 case 's':
1272 ntype = XK_STR;
1273 break;
1274 #ifdef notyet
1275 case 'c':
1276 ntype = XK_EXE;
1277 break;
1278 #endif
1279 case 'k':
1280 key = 1;
1281 break;
1283 case 'r':
1284 rem = 1;
1285 break;
1287 case 'v':
1288 map_init_vi(el);
1289 return (0);
1291 case 'e':
1292 map_init_emacs(el);
1293 return (0);
1295 case 'l':
1296 ep = &el->el_map.help[el->el_map.nfunc];
1297 for (bp = el->el_map.help; bp < ep; bp++)
1298 (void) fprintf(el->el_outfile,
1299 "" FSTR "\n\t" FSTR "\n",
1300 bp->name, bp->description);
1301 return (0);
1302 default:
1303 (void) fprintf(el->el_errfile,
1304 "" FSTR ": Invalid switch `%c'.\n",
1305 argv[0], p[1]);
1307 else
1308 break;
1310 if (argv[argc] == NULL) {
1311 map_print_all_keys(el);
1312 return (0);
1314 if (key)
1315 in = argv[argc++];
1316 else if ((in = parse__string(inbuf, argv[argc++])) == NULL) {
1317 (void) fprintf(el->el_errfile,
1318 "" FSTR ": Invalid \\ or ^ in instring.\n",
1319 argv[0]);
1320 return (-1);
1322 if (rem) {
1323 if (key) {
1324 (void) term_clear_arrow(el, in);
1325 return (-1);
1327 if (in[1])
1328 (void) key_delete(el, in);
1329 else if (map[(unsigned char) *in] == ED_SEQUENCE_LEAD_IN)
1330 (void) key_delete(el, in);
1331 else
1332 map[(unsigned char) *in] = ED_UNASSIGNED;
1333 return (0);
1335 if (argv[argc] == NULL) {
1336 if (key)
1337 term_print_arrow(el, in);
1338 else
1339 map_print_key(el, map, in);
1340 return (0);
1342 #ifdef notyet
1343 if (argv[argc + 1] != NULL) {
1344 bindkey_usage();
1345 return (-1);
1347 #endif
1349 switch (ntype) {
1350 case XK_STR:
1351 case XK_EXE:
1352 if ((out = parse__string(outbuf, argv[argc])) == NULL) {
1353 (void) fprintf(el->el_errfile,
1354 "" FSTR ": Invalid \\ or ^ in outstring.\n", argv[0]);
1355 return (-1);
1357 if (key)
1358 term_set_arrow(el, in, key_map_str(el, out), ntype);
1359 else
1360 key_add(el, in, key_map_str(el, out), ntype);
1361 map[(unsigned char) *in] = ED_SEQUENCE_LEAD_IN;
1362 break;
1364 case XK_CMD:
1365 if ((cmd = parse_cmd(el, argv[argc])) == -1) {
1366 (void) fprintf(el->el_errfile,
1367 "" FSTR ": Invalid command `" FSTR "'.\n",
1368 argv[0], argv[argc]);
1369 return (-1);
1371 if (key)
1372 term_set_arrow(el, in, key_map_str(el, out), ntype);
1373 else {
1374 if (in[1]) {
1375 key_add(el, in, key_map_cmd(el, cmd), ntype);
1376 map[(unsigned char) *in] = ED_SEQUENCE_LEAD_IN;
1377 } else {
1378 key_clear(el, map, in);
1379 map[(unsigned char) *in] = cmd;
1382 break;
1384 default:
1385 EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
1386 break;
1388 return (0);
1392 /* map_addfunc():
1393 * add a user defined function
1395 protected int
1396 map_addfunc(EditLine *el, const Char *name, const Char *help, el_func_t func)
1398 void *p;
1399 int nf = el->el_map.nfunc + 1;
1401 if (name == NULL || help == NULL || func == NULL)
1402 return (-1);
1404 if ((p = el_realloc(el->el_map.func, nf * sizeof(el_func_t))) == NULL)
1405 return (-1);
1406 el->el_map.func = (el_func_t *) p;
1407 if ((p = el_realloc(el->el_map.help, nf * sizeof(el_bindings_t)))
1408 == NULL)
1409 return (-1);
1410 el->el_map.help = (el_bindings_t *) p;
1412 nf = el->el_map.nfunc;
1413 el->el_map.func[nf] = func;
1415 el->el_map.help[nf].name = name;
1416 el->el_map.help[nf].func = nf;
1417 el->el_map.help[nf].description = help;
1418 el->el_map.nfunc++;
1420 return (0);