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