1*0a6a1f1dSLionel Sambuc /* $NetBSD: map.c,v 1.35 2015/05/14 10:44:15 christos Exp $ */
23e1db26aSLionel Sambuc
33e1db26aSLionel Sambuc /*-
43e1db26aSLionel Sambuc * Copyright (c) 1992, 1993
53e1db26aSLionel Sambuc * The Regents of the University of California. All rights reserved.
63e1db26aSLionel Sambuc *
73e1db26aSLionel Sambuc * This code is derived from software contributed to Berkeley by
83e1db26aSLionel Sambuc * Christos Zoulas of Cornell University.
93e1db26aSLionel Sambuc *
103e1db26aSLionel Sambuc * Redistribution and use in source and binary forms, with or without
113e1db26aSLionel Sambuc * modification, are permitted provided that the following conditions
123e1db26aSLionel Sambuc * are met:
133e1db26aSLionel Sambuc * 1. Redistributions of source code must retain the above copyright
143e1db26aSLionel Sambuc * notice, this list of conditions and the following disclaimer.
153e1db26aSLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
163e1db26aSLionel Sambuc * notice, this list of conditions and the following disclaimer in the
173e1db26aSLionel Sambuc * documentation and/or other materials provided with the distribution.
183e1db26aSLionel Sambuc * 3. Neither the name of the University nor the names of its contributors
193e1db26aSLionel Sambuc * may be used to endorse or promote products derived from this software
203e1db26aSLionel Sambuc * without specific prior written permission.
213e1db26aSLionel Sambuc *
223e1db26aSLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
233e1db26aSLionel Sambuc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
243e1db26aSLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
253e1db26aSLionel Sambuc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
263e1db26aSLionel Sambuc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
273e1db26aSLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
283e1db26aSLionel Sambuc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
293e1db26aSLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
303e1db26aSLionel Sambuc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
313e1db26aSLionel Sambuc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
323e1db26aSLionel Sambuc * SUCH DAMAGE.
333e1db26aSLionel Sambuc */
343e1db26aSLionel Sambuc
353e1db26aSLionel Sambuc #include "config.h"
363e1db26aSLionel Sambuc #if !defined(lint) && !defined(SCCSID)
373e1db26aSLionel Sambuc #if 0
383e1db26aSLionel Sambuc static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
393e1db26aSLionel Sambuc #else
40*0a6a1f1dSLionel Sambuc __RCSID("$NetBSD: map.c,v 1.35 2015/05/14 10:44:15 christos Exp $");
413e1db26aSLionel Sambuc #endif
423e1db26aSLionel Sambuc #endif /* not lint && not SCCSID */
433e1db26aSLionel Sambuc
443e1db26aSLionel Sambuc /*
453e1db26aSLionel Sambuc * map.c: Editor function definitions
463e1db26aSLionel Sambuc */
473e1db26aSLionel Sambuc #include <stdlib.h>
483e1db26aSLionel Sambuc #include "el.h"
493e1db26aSLionel Sambuc
503e1db26aSLionel Sambuc private void map_print_key(EditLine *, el_action_t *, const Char *);
513e1db26aSLionel Sambuc private void map_print_some_keys(EditLine *, el_action_t *, Int, Int);
523e1db26aSLionel Sambuc private void map_print_all_keys(EditLine *);
533e1db26aSLionel Sambuc private void map_init_nls(EditLine *);
543e1db26aSLionel Sambuc private void map_init_meta(EditLine *);
553e1db26aSLionel Sambuc
563e1db26aSLionel Sambuc /* keymap tables ; should be N_KEYS*sizeof(KEYCMD) bytes long */
573e1db26aSLionel Sambuc
583e1db26aSLionel Sambuc
593e1db26aSLionel Sambuc private const el_action_t el_map_emacs[] = {
603e1db26aSLionel Sambuc /* 0 */ EM_SET_MARK, /* ^@ */
613e1db26aSLionel Sambuc /* 1 */ ED_MOVE_TO_BEG, /* ^A */
623e1db26aSLionel Sambuc /* 2 */ ED_PREV_CHAR, /* ^B */
633e1db26aSLionel Sambuc /* 3 */ ED_TTY_SIGINT, /* ^C */
643e1db26aSLionel Sambuc /* 4 */ EM_DELETE_OR_LIST, /* ^D */
653e1db26aSLionel Sambuc /* 5 */ ED_MOVE_TO_END, /* ^E */
663e1db26aSLionel Sambuc /* 6 */ ED_NEXT_CHAR, /* ^F */
673e1db26aSLionel Sambuc /* 7 */ ED_UNASSIGNED, /* ^G */
683e1db26aSLionel Sambuc /* 8 */ EM_DELETE_PREV_CHAR, /* ^H */
693e1db26aSLionel Sambuc /* 9 */ ED_UNASSIGNED, /* ^I */
703e1db26aSLionel Sambuc /* 10 */ ED_NEWLINE, /* ^J */
713e1db26aSLionel Sambuc /* 11 */ ED_KILL_LINE, /* ^K */
723e1db26aSLionel Sambuc /* 12 */ ED_CLEAR_SCREEN, /* ^L */
733e1db26aSLionel Sambuc /* 13 */ ED_NEWLINE, /* ^M */
743e1db26aSLionel Sambuc /* 14 */ ED_NEXT_HISTORY, /* ^N */
753e1db26aSLionel Sambuc /* 15 */ ED_TTY_FLUSH_OUTPUT, /* ^O */
763e1db26aSLionel Sambuc /* 16 */ ED_PREV_HISTORY, /* ^P */
773e1db26aSLionel Sambuc /* 17 */ ED_TTY_START_OUTPUT, /* ^Q */
783e1db26aSLionel Sambuc /* 18 */ ED_REDISPLAY, /* ^R */
793e1db26aSLionel Sambuc /* 19 */ ED_TTY_STOP_OUTPUT, /* ^S */
803e1db26aSLionel Sambuc /* 20 */ ED_TRANSPOSE_CHARS, /* ^T */
813e1db26aSLionel Sambuc /* 21 */ EM_KILL_LINE, /* ^U */
823e1db26aSLionel Sambuc /* 22 */ ED_QUOTED_INSERT, /* ^V */
833e1db26aSLionel Sambuc /* 23 */ EM_KILL_REGION, /* ^W */
843e1db26aSLionel Sambuc /* 24 */ ED_SEQUENCE_LEAD_IN, /* ^X */
853e1db26aSLionel Sambuc /* 25 */ EM_YANK, /* ^Y */
863e1db26aSLionel Sambuc /* 26 */ ED_TTY_SIGTSTP, /* ^Z */
873e1db26aSLionel Sambuc /* 27 */ EM_META_NEXT, /* ^[ */
883e1db26aSLionel Sambuc /* 28 */ ED_TTY_SIGQUIT, /* ^\ */
893e1db26aSLionel Sambuc /* 29 */ ED_TTY_DSUSP, /* ^] */
903e1db26aSLionel Sambuc /* 30 */ ED_UNASSIGNED, /* ^^ */
913e1db26aSLionel Sambuc /* 31 */ ED_UNASSIGNED, /* ^_ */
923e1db26aSLionel Sambuc /* 32 */ ED_INSERT, /* SPACE */
933e1db26aSLionel Sambuc /* 33 */ ED_INSERT, /* ! */
943e1db26aSLionel Sambuc /* 34 */ ED_INSERT, /* " */
953e1db26aSLionel Sambuc /* 35 */ ED_INSERT, /* # */
963e1db26aSLionel Sambuc /* 36 */ ED_INSERT, /* $ */
973e1db26aSLionel Sambuc /* 37 */ ED_INSERT, /* % */
983e1db26aSLionel Sambuc /* 38 */ ED_INSERT, /* & */
993e1db26aSLionel Sambuc /* 39 */ ED_INSERT, /* ' */
1003e1db26aSLionel Sambuc /* 40 */ ED_INSERT, /* ( */
1013e1db26aSLionel Sambuc /* 41 */ ED_INSERT, /* ) */
1023e1db26aSLionel Sambuc /* 42 */ ED_INSERT, /* * */
1033e1db26aSLionel Sambuc /* 43 */ ED_INSERT, /* + */
1043e1db26aSLionel Sambuc /* 44 */ ED_INSERT, /* , */
1053e1db26aSLionel Sambuc /* 45 */ ED_INSERT, /* - */
1063e1db26aSLionel Sambuc /* 46 */ ED_INSERT, /* . */
1073e1db26aSLionel Sambuc /* 47 */ ED_INSERT, /* / */
1083e1db26aSLionel Sambuc /* 48 */ ED_DIGIT, /* 0 */
1093e1db26aSLionel Sambuc /* 49 */ ED_DIGIT, /* 1 */
1103e1db26aSLionel Sambuc /* 50 */ ED_DIGIT, /* 2 */
1113e1db26aSLionel Sambuc /* 51 */ ED_DIGIT, /* 3 */
1123e1db26aSLionel Sambuc /* 52 */ ED_DIGIT, /* 4 */
1133e1db26aSLionel Sambuc /* 53 */ ED_DIGIT, /* 5 */
1143e1db26aSLionel Sambuc /* 54 */ ED_DIGIT, /* 6 */
1153e1db26aSLionel Sambuc /* 55 */ ED_DIGIT, /* 7 */
1163e1db26aSLionel Sambuc /* 56 */ ED_DIGIT, /* 8 */
1173e1db26aSLionel Sambuc /* 57 */ ED_DIGIT, /* 9 */
1183e1db26aSLionel Sambuc /* 58 */ ED_INSERT, /* : */
1193e1db26aSLionel Sambuc /* 59 */ ED_INSERT, /* ; */
1203e1db26aSLionel Sambuc /* 60 */ ED_INSERT, /* < */
1213e1db26aSLionel Sambuc /* 61 */ ED_INSERT, /* = */
1223e1db26aSLionel Sambuc /* 62 */ ED_INSERT, /* > */
1233e1db26aSLionel Sambuc /* 63 */ ED_INSERT, /* ? */
1243e1db26aSLionel Sambuc /* 64 */ ED_INSERT, /* @ */
1253e1db26aSLionel Sambuc /* 65 */ ED_INSERT, /* A */
1263e1db26aSLionel Sambuc /* 66 */ ED_INSERT, /* B */
1273e1db26aSLionel Sambuc /* 67 */ ED_INSERT, /* C */
1283e1db26aSLionel Sambuc /* 68 */ ED_INSERT, /* D */
1293e1db26aSLionel Sambuc /* 69 */ ED_INSERT, /* E */
1303e1db26aSLionel Sambuc /* 70 */ ED_INSERT, /* F */
1313e1db26aSLionel Sambuc /* 71 */ ED_INSERT, /* G */
1323e1db26aSLionel Sambuc /* 72 */ ED_INSERT, /* H */
1333e1db26aSLionel Sambuc /* 73 */ ED_INSERT, /* I */
1343e1db26aSLionel Sambuc /* 74 */ ED_INSERT, /* J */
1353e1db26aSLionel Sambuc /* 75 */ ED_INSERT, /* K */
1363e1db26aSLionel Sambuc /* 76 */ ED_INSERT, /* L */
1373e1db26aSLionel Sambuc /* 77 */ ED_INSERT, /* M */
1383e1db26aSLionel Sambuc /* 78 */ ED_INSERT, /* N */
1393e1db26aSLionel Sambuc /* 79 */ ED_INSERT, /* O */
1403e1db26aSLionel Sambuc /* 80 */ ED_INSERT, /* P */
1413e1db26aSLionel Sambuc /* 81 */ ED_INSERT, /* Q */
1423e1db26aSLionel Sambuc /* 82 */ ED_INSERT, /* R */
1433e1db26aSLionel Sambuc /* 83 */ ED_INSERT, /* S */
1443e1db26aSLionel Sambuc /* 84 */ ED_INSERT, /* T */
1453e1db26aSLionel Sambuc /* 85 */ ED_INSERT, /* U */
1463e1db26aSLionel Sambuc /* 86 */ ED_INSERT, /* V */
1473e1db26aSLionel Sambuc /* 87 */ ED_INSERT, /* W */
1483e1db26aSLionel Sambuc /* 88 */ ED_INSERT, /* X */
1493e1db26aSLionel Sambuc /* 89 */ ED_INSERT, /* Y */
1503e1db26aSLionel Sambuc /* 90 */ ED_INSERT, /* Z */
1513e1db26aSLionel Sambuc /* 91 */ ED_INSERT, /* [ */
1523e1db26aSLionel Sambuc /* 92 */ ED_INSERT, /* \ */
1533e1db26aSLionel Sambuc /* 93 */ ED_INSERT, /* ] */
1543e1db26aSLionel Sambuc /* 94 */ ED_INSERT, /* ^ */
1553e1db26aSLionel Sambuc /* 95 */ ED_INSERT, /* _ */
1563e1db26aSLionel Sambuc /* 96 */ ED_INSERT, /* ` */
1573e1db26aSLionel Sambuc /* 97 */ ED_INSERT, /* a */
1583e1db26aSLionel Sambuc /* 98 */ ED_INSERT, /* b */
1593e1db26aSLionel Sambuc /* 99 */ ED_INSERT, /* c */
1603e1db26aSLionel Sambuc /* 100 */ ED_INSERT, /* d */
1613e1db26aSLionel Sambuc /* 101 */ ED_INSERT, /* e */
1623e1db26aSLionel Sambuc /* 102 */ ED_INSERT, /* f */
1633e1db26aSLionel Sambuc /* 103 */ ED_INSERT, /* g */
1643e1db26aSLionel Sambuc /* 104 */ ED_INSERT, /* h */
1653e1db26aSLionel Sambuc /* 105 */ ED_INSERT, /* i */
1663e1db26aSLionel Sambuc /* 106 */ ED_INSERT, /* j */
1673e1db26aSLionel Sambuc /* 107 */ ED_INSERT, /* k */
1683e1db26aSLionel Sambuc /* 108 */ ED_INSERT, /* l */
1693e1db26aSLionel Sambuc /* 109 */ ED_INSERT, /* m */
1703e1db26aSLionel Sambuc /* 110 */ ED_INSERT, /* n */
1713e1db26aSLionel Sambuc /* 111 */ ED_INSERT, /* o */
1723e1db26aSLionel Sambuc /* 112 */ ED_INSERT, /* p */
1733e1db26aSLionel Sambuc /* 113 */ ED_INSERT, /* q */
1743e1db26aSLionel Sambuc /* 114 */ ED_INSERT, /* r */
1753e1db26aSLionel Sambuc /* 115 */ ED_INSERT, /* s */
1763e1db26aSLionel Sambuc /* 116 */ ED_INSERT, /* t */
1773e1db26aSLionel Sambuc /* 117 */ ED_INSERT, /* u */
1783e1db26aSLionel Sambuc /* 118 */ ED_INSERT, /* v */
1793e1db26aSLionel Sambuc /* 119 */ ED_INSERT, /* w */
1803e1db26aSLionel Sambuc /* 120 */ ED_INSERT, /* x */
1813e1db26aSLionel Sambuc /* 121 */ ED_INSERT, /* y */
1823e1db26aSLionel Sambuc /* 122 */ ED_INSERT, /* z */
1833e1db26aSLionel Sambuc /* 123 */ ED_INSERT, /* { */
1843e1db26aSLionel Sambuc /* 124 */ ED_INSERT, /* | */
1853e1db26aSLionel Sambuc /* 125 */ ED_INSERT, /* } */
1863e1db26aSLionel Sambuc /* 126 */ ED_INSERT, /* ~ */
1873e1db26aSLionel Sambuc /* 127 */ EM_DELETE_PREV_CHAR, /* ^? */
1883e1db26aSLionel Sambuc /* 128 */ ED_UNASSIGNED, /* M-^@ */
1893e1db26aSLionel Sambuc /* 129 */ ED_UNASSIGNED, /* M-^A */
1903e1db26aSLionel Sambuc /* 130 */ ED_UNASSIGNED, /* M-^B */
1913e1db26aSLionel Sambuc /* 131 */ ED_UNASSIGNED, /* M-^C */
1923e1db26aSLionel Sambuc /* 132 */ ED_UNASSIGNED, /* M-^D */
1933e1db26aSLionel Sambuc /* 133 */ ED_UNASSIGNED, /* M-^E */
1943e1db26aSLionel Sambuc /* 134 */ ED_UNASSIGNED, /* M-^F */
1953e1db26aSLionel Sambuc /* 135 */ ED_UNASSIGNED, /* M-^G */
1963e1db26aSLionel Sambuc /* 136 */ ED_DELETE_PREV_WORD, /* M-^H */
1973e1db26aSLionel Sambuc /* 137 */ ED_UNASSIGNED, /* M-^I */
1983e1db26aSLionel Sambuc /* 138 */ ED_UNASSIGNED, /* M-^J */
1993e1db26aSLionel Sambuc /* 139 */ ED_UNASSIGNED, /* M-^K */
2003e1db26aSLionel Sambuc /* 140 */ ED_CLEAR_SCREEN, /* M-^L */
2013e1db26aSLionel Sambuc /* 141 */ ED_UNASSIGNED, /* M-^M */
2023e1db26aSLionel Sambuc /* 142 */ ED_UNASSIGNED, /* M-^N */
2033e1db26aSLionel Sambuc /* 143 */ ED_UNASSIGNED, /* M-^O */
2043e1db26aSLionel Sambuc /* 144 */ ED_UNASSIGNED, /* M-^P */
2053e1db26aSLionel Sambuc /* 145 */ ED_UNASSIGNED, /* M-^Q */
2063e1db26aSLionel Sambuc /* 146 */ ED_UNASSIGNED, /* M-^R */
2073e1db26aSLionel Sambuc /* 147 */ ED_UNASSIGNED, /* M-^S */
2083e1db26aSLionel Sambuc /* 148 */ ED_UNASSIGNED, /* M-^T */
2093e1db26aSLionel Sambuc /* 149 */ ED_UNASSIGNED, /* M-^U */
2103e1db26aSLionel Sambuc /* 150 */ ED_UNASSIGNED, /* M-^V */
2113e1db26aSLionel Sambuc /* 151 */ ED_UNASSIGNED, /* M-^W */
2123e1db26aSLionel Sambuc /* 152 */ ED_UNASSIGNED, /* M-^X */
2133e1db26aSLionel Sambuc /* 153 */ ED_UNASSIGNED, /* M-^Y */
2143e1db26aSLionel Sambuc /* 154 */ ED_UNASSIGNED, /* M-^Z */
2153e1db26aSLionel Sambuc /* 155 */ ED_UNASSIGNED, /* M-^[ */
2163e1db26aSLionel Sambuc /* 156 */ ED_UNASSIGNED, /* M-^\ */
2173e1db26aSLionel Sambuc /* 157 */ ED_UNASSIGNED, /* M-^] */
2183e1db26aSLionel Sambuc /* 158 */ ED_UNASSIGNED, /* M-^^ */
2193e1db26aSLionel Sambuc /* 159 */ EM_COPY_PREV_WORD, /* M-^_ */
2203e1db26aSLionel Sambuc /* 160 */ ED_UNASSIGNED, /* M-SPACE */
2213e1db26aSLionel Sambuc /* 161 */ ED_UNASSIGNED, /* M-! */
2223e1db26aSLionel Sambuc /* 162 */ ED_UNASSIGNED, /* M-" */
2233e1db26aSLionel Sambuc /* 163 */ ED_UNASSIGNED, /* M-# */
2243e1db26aSLionel Sambuc /* 164 */ ED_UNASSIGNED, /* M-$ */
2253e1db26aSLionel Sambuc /* 165 */ ED_UNASSIGNED, /* M-% */
2263e1db26aSLionel Sambuc /* 166 */ ED_UNASSIGNED, /* M-& */
2273e1db26aSLionel Sambuc /* 167 */ ED_UNASSIGNED, /* M-' */
2283e1db26aSLionel Sambuc /* 168 */ ED_UNASSIGNED, /* M-( */
2293e1db26aSLionel Sambuc /* 169 */ ED_UNASSIGNED, /* M-) */
2303e1db26aSLionel Sambuc /* 170 */ ED_UNASSIGNED, /* M-* */
2313e1db26aSLionel Sambuc /* 171 */ ED_UNASSIGNED, /* M-+ */
2323e1db26aSLionel Sambuc /* 172 */ ED_UNASSIGNED, /* M-, */
2333e1db26aSLionel Sambuc /* 173 */ ED_UNASSIGNED, /* M-- */
2343e1db26aSLionel Sambuc /* 174 */ ED_UNASSIGNED, /* M-. */
2353e1db26aSLionel Sambuc /* 175 */ ED_UNASSIGNED, /* M-/ */
2363e1db26aSLionel Sambuc /* 176 */ ED_ARGUMENT_DIGIT, /* M-0 */
2373e1db26aSLionel Sambuc /* 177 */ ED_ARGUMENT_DIGIT, /* M-1 */
2383e1db26aSLionel Sambuc /* 178 */ ED_ARGUMENT_DIGIT, /* M-2 */
2393e1db26aSLionel Sambuc /* 179 */ ED_ARGUMENT_DIGIT, /* M-3 */
2403e1db26aSLionel Sambuc /* 180 */ ED_ARGUMENT_DIGIT, /* M-4 */
2413e1db26aSLionel Sambuc /* 181 */ ED_ARGUMENT_DIGIT, /* M-5 */
2423e1db26aSLionel Sambuc /* 182 */ ED_ARGUMENT_DIGIT, /* M-6 */
2433e1db26aSLionel Sambuc /* 183 */ ED_ARGUMENT_DIGIT, /* M-7 */
2443e1db26aSLionel Sambuc /* 184 */ ED_ARGUMENT_DIGIT, /* M-8 */
2453e1db26aSLionel Sambuc /* 185 */ ED_ARGUMENT_DIGIT, /* M-9 */
2463e1db26aSLionel Sambuc /* 186 */ ED_UNASSIGNED, /* M-: */
2473e1db26aSLionel Sambuc /* 187 */ ED_UNASSIGNED, /* M-; */
2483e1db26aSLionel Sambuc /* 188 */ ED_UNASSIGNED, /* M-< */
2493e1db26aSLionel Sambuc /* 189 */ ED_UNASSIGNED, /* M-= */
2503e1db26aSLionel Sambuc /* 190 */ ED_UNASSIGNED, /* M-> */
2513e1db26aSLionel Sambuc /* 191 */ ED_UNASSIGNED, /* M-? */
2523e1db26aSLionel Sambuc /* 192 */ ED_UNASSIGNED, /* M-@ */
2533e1db26aSLionel Sambuc /* 193 */ ED_UNASSIGNED, /* M-A */
2543e1db26aSLionel Sambuc /* 194 */ ED_PREV_WORD, /* M-B */
2553e1db26aSLionel Sambuc /* 195 */ EM_CAPITOL_CASE, /* M-C */
2563e1db26aSLionel Sambuc /* 196 */ EM_DELETE_NEXT_WORD, /* M-D */
2573e1db26aSLionel Sambuc /* 197 */ ED_UNASSIGNED, /* M-E */
2583e1db26aSLionel Sambuc /* 198 */ EM_NEXT_WORD, /* M-F */
2593e1db26aSLionel Sambuc /* 199 */ ED_UNASSIGNED, /* M-G */
2603e1db26aSLionel Sambuc /* 200 */ ED_UNASSIGNED, /* M-H */
2613e1db26aSLionel Sambuc /* 201 */ ED_UNASSIGNED, /* M-I */
2623e1db26aSLionel Sambuc /* 202 */ ED_UNASSIGNED, /* M-J */
2633e1db26aSLionel Sambuc /* 203 */ ED_UNASSIGNED, /* M-K */
2643e1db26aSLionel Sambuc /* 204 */ EM_LOWER_CASE, /* M-L */
2653e1db26aSLionel Sambuc /* 205 */ ED_UNASSIGNED, /* M-M */
2663e1db26aSLionel Sambuc /* 206 */ ED_SEARCH_NEXT_HISTORY, /* M-N */
2673e1db26aSLionel Sambuc /* 207 */ ED_SEQUENCE_LEAD_IN, /* M-O */
2683e1db26aSLionel Sambuc /* 208 */ ED_SEARCH_PREV_HISTORY, /* M-P */
2693e1db26aSLionel Sambuc /* 209 */ ED_UNASSIGNED, /* M-Q */
2703e1db26aSLionel Sambuc /* 210 */ ED_UNASSIGNED, /* M-R */
2713e1db26aSLionel Sambuc /* 211 */ ED_UNASSIGNED, /* M-S */
2723e1db26aSLionel Sambuc /* 212 */ ED_UNASSIGNED, /* M-T */
2733e1db26aSLionel Sambuc /* 213 */ EM_UPPER_CASE, /* M-U */
2743e1db26aSLionel Sambuc /* 214 */ ED_UNASSIGNED, /* M-V */
2753e1db26aSLionel Sambuc /* 215 */ EM_COPY_REGION, /* M-W */
2763e1db26aSLionel Sambuc /* 216 */ ED_COMMAND, /* M-X */
2773e1db26aSLionel Sambuc /* 217 */ ED_UNASSIGNED, /* M-Y */
2783e1db26aSLionel Sambuc /* 218 */ ED_UNASSIGNED, /* M-Z */
2793e1db26aSLionel Sambuc /* 219 */ ED_SEQUENCE_LEAD_IN, /* M-[ */
2803e1db26aSLionel Sambuc /* 220 */ ED_UNASSIGNED, /* M-\ */
2813e1db26aSLionel Sambuc /* 221 */ ED_UNASSIGNED, /* M-] */
2823e1db26aSLionel Sambuc /* 222 */ ED_UNASSIGNED, /* M-^ */
2833e1db26aSLionel Sambuc /* 223 */ ED_UNASSIGNED, /* M-_ */
2843e1db26aSLionel Sambuc /* 223 */ ED_UNASSIGNED, /* M-` */
2853e1db26aSLionel Sambuc /* 224 */ ED_UNASSIGNED, /* M-a */
2863e1db26aSLionel Sambuc /* 225 */ ED_PREV_WORD, /* M-b */
2873e1db26aSLionel Sambuc /* 226 */ EM_CAPITOL_CASE, /* M-c */
2883e1db26aSLionel Sambuc /* 227 */ EM_DELETE_NEXT_WORD, /* M-d */
2893e1db26aSLionel Sambuc /* 228 */ ED_UNASSIGNED, /* M-e */
2903e1db26aSLionel Sambuc /* 229 */ EM_NEXT_WORD, /* M-f */
2913e1db26aSLionel Sambuc /* 230 */ ED_UNASSIGNED, /* M-g */
2923e1db26aSLionel Sambuc /* 231 */ ED_UNASSIGNED, /* M-h */
2933e1db26aSLionel Sambuc /* 232 */ ED_UNASSIGNED, /* M-i */
2943e1db26aSLionel Sambuc /* 233 */ ED_UNASSIGNED, /* M-j */
2953e1db26aSLionel Sambuc /* 234 */ ED_UNASSIGNED, /* M-k */
2963e1db26aSLionel Sambuc /* 235 */ EM_LOWER_CASE, /* M-l */
2973e1db26aSLionel Sambuc /* 236 */ ED_UNASSIGNED, /* M-m */
2983e1db26aSLionel Sambuc /* 237 */ ED_SEARCH_NEXT_HISTORY, /* M-n */
2993e1db26aSLionel Sambuc /* 238 */ ED_UNASSIGNED, /* M-o */
3003e1db26aSLionel Sambuc /* 239 */ ED_SEARCH_PREV_HISTORY, /* M-p */
3013e1db26aSLionel Sambuc /* 240 */ ED_UNASSIGNED, /* M-q */
3023e1db26aSLionel Sambuc /* 241 */ ED_UNASSIGNED, /* M-r */
3033e1db26aSLionel Sambuc /* 242 */ ED_UNASSIGNED, /* M-s */
3043e1db26aSLionel Sambuc /* 243 */ ED_UNASSIGNED, /* M-t */
3053e1db26aSLionel Sambuc /* 244 */ EM_UPPER_CASE, /* M-u */
3063e1db26aSLionel Sambuc /* 245 */ ED_UNASSIGNED, /* M-v */
3073e1db26aSLionel Sambuc /* 246 */ EM_COPY_REGION, /* M-w */
3083e1db26aSLionel Sambuc /* 247 */ ED_COMMAND, /* M-x */
3093e1db26aSLionel Sambuc /* 248 */ ED_UNASSIGNED, /* M-y */
3103e1db26aSLionel Sambuc /* 249 */ ED_UNASSIGNED, /* M-z */
3113e1db26aSLionel Sambuc /* 250 */ ED_UNASSIGNED, /* M-{ */
3123e1db26aSLionel Sambuc /* 251 */ ED_UNASSIGNED, /* M-| */
3133e1db26aSLionel Sambuc /* 252 */ ED_UNASSIGNED, /* M-} */
3143e1db26aSLionel Sambuc /* 253 */ ED_UNASSIGNED, /* M-~ */
3153e1db26aSLionel Sambuc /* 254 */ ED_DELETE_PREV_WORD /* M-^? */
3163e1db26aSLionel Sambuc /* 255 */
3173e1db26aSLionel Sambuc };
3183e1db26aSLionel Sambuc
3193e1db26aSLionel Sambuc
3203e1db26aSLionel Sambuc /*
3213e1db26aSLionel Sambuc * keymap table for vi. Each index into above tbl; should be
3223e1db26aSLionel Sambuc * N_KEYS entries long. Vi mode uses a sticky-extend to do command mode:
3233e1db26aSLionel Sambuc * insert mode characters are in the normal keymap, and command mode
3243e1db26aSLionel Sambuc * in the extended keymap.
3253e1db26aSLionel Sambuc */
3263e1db26aSLionel Sambuc private const el_action_t el_map_vi_insert[] = {
3273e1db26aSLionel Sambuc #ifdef KSHVI
3283e1db26aSLionel Sambuc /* 0 */ ED_UNASSIGNED, /* ^@ */
3293e1db26aSLionel Sambuc /* 1 */ ED_INSERT, /* ^A */
3303e1db26aSLionel Sambuc /* 2 */ ED_INSERT, /* ^B */
3313e1db26aSLionel Sambuc /* 3 */ ED_INSERT, /* ^C */
3323e1db26aSLionel Sambuc /* 4 */ VI_LIST_OR_EOF, /* ^D */
3333e1db26aSLionel Sambuc /* 5 */ ED_INSERT, /* ^E */
3343e1db26aSLionel Sambuc /* 6 */ ED_INSERT, /* ^F */
3353e1db26aSLionel Sambuc /* 7 */ ED_INSERT, /* ^G */
3363e1db26aSLionel Sambuc /* 8 */ VI_DELETE_PREV_CHAR, /* ^H */ /* BackSpace key */
3373e1db26aSLionel Sambuc /* 9 */ ED_INSERT, /* ^I */ /* Tab Key */
3383e1db26aSLionel Sambuc /* 10 */ ED_NEWLINE, /* ^J */
3393e1db26aSLionel Sambuc /* 11 */ ED_INSERT, /* ^K */
3403e1db26aSLionel Sambuc /* 12 */ ED_INSERT, /* ^L */
3413e1db26aSLionel Sambuc /* 13 */ ED_NEWLINE, /* ^M */
3423e1db26aSLionel Sambuc /* 14 */ ED_INSERT, /* ^N */
3433e1db26aSLionel Sambuc /* 15 */ ED_INSERT, /* ^O */
3443e1db26aSLionel Sambuc /* 16 */ ED_INSERT, /* ^P */
3453e1db26aSLionel Sambuc /* 17 */ ED_TTY_START_OUTPUT, /* ^Q */
3463e1db26aSLionel Sambuc /* 18 */ ED_INSERT, /* ^R */
3473e1db26aSLionel Sambuc /* 19 */ ED_TTY_STOP_OUTPUT, /* ^S */
3483e1db26aSLionel Sambuc /* 20 */ ED_INSERT, /* ^T */
3493e1db26aSLionel Sambuc /* 21 */ VI_KILL_LINE_PREV, /* ^U */
3503e1db26aSLionel Sambuc /* 22 */ ED_QUOTED_INSERT, /* ^V */
3513e1db26aSLionel Sambuc /* 23 */ ED_DELETE_PREV_WORD, /* ^W */
3523e1db26aSLionel Sambuc /* ED_DELETE_PREV_WORD: Only until strt edit pos */
3533e1db26aSLionel Sambuc /* 24 */ ED_INSERT, /* ^X */
3543e1db26aSLionel Sambuc /* 25 */ ED_INSERT, /* ^Y */
3553e1db26aSLionel Sambuc /* 26 */ ED_INSERT, /* ^Z */
3563e1db26aSLionel Sambuc /* 27 */ VI_COMMAND_MODE, /* ^[ */ /* [ Esc ] key */
3573e1db26aSLionel Sambuc /* 28 */ ED_TTY_SIGQUIT, /* ^\ */
3583e1db26aSLionel Sambuc /* 29 */ ED_INSERT, /* ^] */
3593e1db26aSLionel Sambuc /* 30 */ ED_INSERT, /* ^^ */
3603e1db26aSLionel Sambuc /* 31 */ ED_INSERT, /* ^_ */
3613e1db26aSLionel Sambuc #else /* !KSHVI */
3623e1db26aSLionel Sambuc /*
3633e1db26aSLionel Sambuc * NOTE: These mappings do NOT Correspond well
3643e1db26aSLionel Sambuc * to the KSH VI editing assignments.
3653e1db26aSLionel Sambuc * On the other and they are convenient and
3663e1db26aSLionel Sambuc * many people have have gotten used to them.
3673e1db26aSLionel Sambuc */
3683e1db26aSLionel Sambuc /* 0 */ ED_UNASSIGNED, /* ^@ */
3693e1db26aSLionel Sambuc /* 1 */ ED_MOVE_TO_BEG, /* ^A */
3703e1db26aSLionel Sambuc /* 2 */ ED_PREV_CHAR, /* ^B */
3713e1db26aSLionel Sambuc /* 3 */ ED_TTY_SIGINT, /* ^C */
3723e1db26aSLionel Sambuc /* 4 */ VI_LIST_OR_EOF, /* ^D */
3733e1db26aSLionel Sambuc /* 5 */ ED_MOVE_TO_END, /* ^E */
3743e1db26aSLionel Sambuc /* 6 */ ED_NEXT_CHAR, /* ^F */
3753e1db26aSLionel Sambuc /* 7 */ ED_UNASSIGNED, /* ^G */
3763e1db26aSLionel Sambuc /* 8 */ VI_DELETE_PREV_CHAR, /* ^H */ /* BackSpace key */
3773e1db26aSLionel Sambuc /* 9 */ ED_UNASSIGNED, /* ^I */ /* Tab Key */
3783e1db26aSLionel Sambuc /* 10 */ ED_NEWLINE, /* ^J */
3793e1db26aSLionel Sambuc /* 11 */ ED_KILL_LINE, /* ^K */
3803e1db26aSLionel Sambuc /* 12 */ ED_CLEAR_SCREEN, /* ^L */
3813e1db26aSLionel Sambuc /* 13 */ ED_NEWLINE, /* ^M */
3823e1db26aSLionel Sambuc /* 14 */ ED_NEXT_HISTORY, /* ^N */
3833e1db26aSLionel Sambuc /* 15 */ ED_TTY_FLUSH_OUTPUT, /* ^O */
3843e1db26aSLionel Sambuc /* 16 */ ED_PREV_HISTORY, /* ^P */
3853e1db26aSLionel Sambuc /* 17 */ ED_TTY_START_OUTPUT, /* ^Q */
3863e1db26aSLionel Sambuc /* 18 */ ED_REDISPLAY, /* ^R */
3873e1db26aSLionel Sambuc /* 19 */ ED_TTY_STOP_OUTPUT, /* ^S */
3883e1db26aSLionel Sambuc /* 20 */ ED_TRANSPOSE_CHARS, /* ^T */
3893e1db26aSLionel Sambuc /* 21 */ VI_KILL_LINE_PREV, /* ^U */
3903e1db26aSLionel Sambuc /* 22 */ ED_QUOTED_INSERT, /* ^V */
3913e1db26aSLionel Sambuc /* 23 */ ED_DELETE_PREV_WORD, /* ^W */
3923e1db26aSLionel Sambuc /* 24 */ ED_UNASSIGNED, /* ^X */
3933e1db26aSLionel Sambuc /* 25 */ ED_TTY_DSUSP, /* ^Y */
3943e1db26aSLionel Sambuc /* 26 */ ED_TTY_SIGTSTP, /* ^Z */
3953e1db26aSLionel Sambuc /* 27 */ VI_COMMAND_MODE, /* ^[ */
3963e1db26aSLionel Sambuc /* 28 */ ED_TTY_SIGQUIT, /* ^\ */
3973e1db26aSLionel Sambuc /* 29 */ ED_UNASSIGNED, /* ^] */
3983e1db26aSLionel Sambuc /* 30 */ ED_UNASSIGNED, /* ^^ */
3993e1db26aSLionel Sambuc /* 31 */ ED_UNASSIGNED, /* ^_ */
4003e1db26aSLionel Sambuc #endif /* KSHVI */
4013e1db26aSLionel Sambuc /* 32 */ ED_INSERT, /* SPACE */
4023e1db26aSLionel Sambuc /* 33 */ ED_INSERT, /* ! */
4033e1db26aSLionel Sambuc /* 34 */ ED_INSERT, /* " */
4043e1db26aSLionel Sambuc /* 35 */ ED_INSERT, /* # */
4053e1db26aSLionel Sambuc /* 36 */ ED_INSERT, /* $ */
4063e1db26aSLionel Sambuc /* 37 */ ED_INSERT, /* % */
4073e1db26aSLionel Sambuc /* 38 */ ED_INSERT, /* & */
4083e1db26aSLionel Sambuc /* 39 */ ED_INSERT, /* ' */
4093e1db26aSLionel Sambuc /* 40 */ ED_INSERT, /* ( */
4103e1db26aSLionel Sambuc /* 41 */ ED_INSERT, /* ) */
4113e1db26aSLionel Sambuc /* 42 */ ED_INSERT, /* * */
4123e1db26aSLionel Sambuc /* 43 */ ED_INSERT, /* + */
4133e1db26aSLionel Sambuc /* 44 */ ED_INSERT, /* , */
4143e1db26aSLionel Sambuc /* 45 */ ED_INSERT, /* - */
4153e1db26aSLionel Sambuc /* 46 */ ED_INSERT, /* . */
4163e1db26aSLionel Sambuc /* 47 */ ED_INSERT, /* / */
4173e1db26aSLionel Sambuc /* 48 */ ED_INSERT, /* 0 */
4183e1db26aSLionel Sambuc /* 49 */ ED_INSERT, /* 1 */
4193e1db26aSLionel Sambuc /* 50 */ ED_INSERT, /* 2 */
4203e1db26aSLionel Sambuc /* 51 */ ED_INSERT, /* 3 */
4213e1db26aSLionel Sambuc /* 52 */ ED_INSERT, /* 4 */
4223e1db26aSLionel Sambuc /* 53 */ ED_INSERT, /* 5 */
4233e1db26aSLionel Sambuc /* 54 */ ED_INSERT, /* 6 */
4243e1db26aSLionel Sambuc /* 55 */ ED_INSERT, /* 7 */
4253e1db26aSLionel Sambuc /* 56 */ ED_INSERT, /* 8 */
4263e1db26aSLionel Sambuc /* 57 */ ED_INSERT, /* 9 */
4273e1db26aSLionel Sambuc /* 58 */ ED_INSERT, /* : */
4283e1db26aSLionel Sambuc /* 59 */ ED_INSERT, /* ; */
4293e1db26aSLionel Sambuc /* 60 */ ED_INSERT, /* < */
4303e1db26aSLionel Sambuc /* 61 */ ED_INSERT, /* = */
4313e1db26aSLionel Sambuc /* 62 */ ED_INSERT, /* > */
4323e1db26aSLionel Sambuc /* 63 */ ED_INSERT, /* ? */
4333e1db26aSLionel Sambuc /* 64 */ ED_INSERT, /* @ */
4343e1db26aSLionel Sambuc /* 65 */ ED_INSERT, /* A */
4353e1db26aSLionel Sambuc /* 66 */ ED_INSERT, /* B */
4363e1db26aSLionel Sambuc /* 67 */ ED_INSERT, /* C */
4373e1db26aSLionel Sambuc /* 68 */ ED_INSERT, /* D */
4383e1db26aSLionel Sambuc /* 69 */ ED_INSERT, /* E */
4393e1db26aSLionel Sambuc /* 70 */ ED_INSERT, /* F */
4403e1db26aSLionel Sambuc /* 71 */ ED_INSERT, /* G */
4413e1db26aSLionel Sambuc /* 72 */ ED_INSERT, /* H */
4423e1db26aSLionel Sambuc /* 73 */ ED_INSERT, /* I */
4433e1db26aSLionel Sambuc /* 74 */ ED_INSERT, /* J */
4443e1db26aSLionel Sambuc /* 75 */ ED_INSERT, /* K */
4453e1db26aSLionel Sambuc /* 76 */ ED_INSERT, /* L */
4463e1db26aSLionel Sambuc /* 77 */ ED_INSERT, /* M */
4473e1db26aSLionel Sambuc /* 78 */ ED_INSERT, /* N */
4483e1db26aSLionel Sambuc /* 79 */ ED_INSERT, /* O */
4493e1db26aSLionel Sambuc /* 80 */ ED_INSERT, /* P */
4503e1db26aSLionel Sambuc /* 81 */ ED_INSERT, /* Q */
4513e1db26aSLionel Sambuc /* 82 */ ED_INSERT, /* R */
4523e1db26aSLionel Sambuc /* 83 */ ED_INSERT, /* S */
4533e1db26aSLionel Sambuc /* 84 */ ED_INSERT, /* T */
4543e1db26aSLionel Sambuc /* 85 */ ED_INSERT, /* U */
4553e1db26aSLionel Sambuc /* 86 */ ED_INSERT, /* V */
4563e1db26aSLionel Sambuc /* 87 */ ED_INSERT, /* W */
4573e1db26aSLionel Sambuc /* 88 */ ED_INSERT, /* X */
4583e1db26aSLionel Sambuc /* 89 */ ED_INSERT, /* Y */
4593e1db26aSLionel Sambuc /* 90 */ ED_INSERT, /* Z */
4603e1db26aSLionel Sambuc /* 91 */ ED_INSERT, /* [ */
4613e1db26aSLionel Sambuc /* 92 */ ED_INSERT, /* \ */
4623e1db26aSLionel Sambuc /* 93 */ ED_INSERT, /* ] */
4633e1db26aSLionel Sambuc /* 94 */ ED_INSERT, /* ^ */
4643e1db26aSLionel Sambuc /* 95 */ ED_INSERT, /* _ */
4653e1db26aSLionel Sambuc /* 96 */ ED_INSERT, /* ` */
4663e1db26aSLionel Sambuc /* 97 */ ED_INSERT, /* a */
4673e1db26aSLionel Sambuc /* 98 */ ED_INSERT, /* b */
4683e1db26aSLionel Sambuc /* 99 */ ED_INSERT, /* c */
4693e1db26aSLionel Sambuc /* 100 */ ED_INSERT, /* d */
4703e1db26aSLionel Sambuc /* 101 */ ED_INSERT, /* e */
4713e1db26aSLionel Sambuc /* 102 */ ED_INSERT, /* f */
4723e1db26aSLionel Sambuc /* 103 */ ED_INSERT, /* g */
4733e1db26aSLionel Sambuc /* 104 */ ED_INSERT, /* h */
4743e1db26aSLionel Sambuc /* 105 */ ED_INSERT, /* i */
4753e1db26aSLionel Sambuc /* 106 */ ED_INSERT, /* j */
4763e1db26aSLionel Sambuc /* 107 */ ED_INSERT, /* k */
4773e1db26aSLionel Sambuc /* 108 */ ED_INSERT, /* l */
4783e1db26aSLionel Sambuc /* 109 */ ED_INSERT, /* m */
4793e1db26aSLionel Sambuc /* 110 */ ED_INSERT, /* n */
4803e1db26aSLionel Sambuc /* 111 */ ED_INSERT, /* o */
4813e1db26aSLionel Sambuc /* 112 */ ED_INSERT, /* p */
4823e1db26aSLionel Sambuc /* 113 */ ED_INSERT, /* q */
4833e1db26aSLionel Sambuc /* 114 */ ED_INSERT, /* r */
4843e1db26aSLionel Sambuc /* 115 */ ED_INSERT, /* s */
4853e1db26aSLionel Sambuc /* 116 */ ED_INSERT, /* t */
4863e1db26aSLionel Sambuc /* 117 */ ED_INSERT, /* u */
4873e1db26aSLionel Sambuc /* 118 */ ED_INSERT, /* v */
4883e1db26aSLionel Sambuc /* 119 */ ED_INSERT, /* w */
4893e1db26aSLionel Sambuc /* 120 */ ED_INSERT, /* x */
4903e1db26aSLionel Sambuc /* 121 */ ED_INSERT, /* y */
4913e1db26aSLionel Sambuc /* 122 */ ED_INSERT, /* z */
4923e1db26aSLionel Sambuc /* 123 */ ED_INSERT, /* { */
4933e1db26aSLionel Sambuc /* 124 */ ED_INSERT, /* | */
4943e1db26aSLionel Sambuc /* 125 */ ED_INSERT, /* } */
4953e1db26aSLionel Sambuc /* 126 */ ED_INSERT, /* ~ */
4963e1db26aSLionel Sambuc /* 127 */ VI_DELETE_PREV_CHAR, /* ^? */
4973e1db26aSLionel Sambuc /* 128 */ ED_INSERT, /* M-^@ */
4983e1db26aSLionel Sambuc /* 129 */ ED_INSERT, /* M-^A */
4993e1db26aSLionel Sambuc /* 130 */ ED_INSERT, /* M-^B */
5003e1db26aSLionel Sambuc /* 131 */ ED_INSERT, /* M-^C */
5013e1db26aSLionel Sambuc /* 132 */ ED_INSERT, /* M-^D */
5023e1db26aSLionel Sambuc /* 133 */ ED_INSERT, /* M-^E */
5033e1db26aSLionel Sambuc /* 134 */ ED_INSERT, /* M-^F */
5043e1db26aSLionel Sambuc /* 135 */ ED_INSERT, /* M-^G */
5053e1db26aSLionel Sambuc /* 136 */ ED_INSERT, /* M-^H */
5063e1db26aSLionel Sambuc /* 137 */ ED_INSERT, /* M-^I */
5073e1db26aSLionel Sambuc /* 138 */ ED_INSERT, /* M-^J */
5083e1db26aSLionel Sambuc /* 139 */ ED_INSERT, /* M-^K */
5093e1db26aSLionel Sambuc /* 140 */ ED_INSERT, /* M-^L */
5103e1db26aSLionel Sambuc /* 141 */ ED_INSERT, /* M-^M */
5113e1db26aSLionel Sambuc /* 142 */ ED_INSERT, /* M-^N */
5123e1db26aSLionel Sambuc /* 143 */ ED_INSERT, /* M-^O */
5133e1db26aSLionel Sambuc /* 144 */ ED_INSERT, /* M-^P */
5143e1db26aSLionel Sambuc /* 145 */ ED_INSERT, /* M-^Q */
5153e1db26aSLionel Sambuc /* 146 */ ED_INSERT, /* M-^R */
5163e1db26aSLionel Sambuc /* 147 */ ED_INSERT, /* M-^S */
5173e1db26aSLionel Sambuc /* 148 */ ED_INSERT, /* M-^T */
5183e1db26aSLionel Sambuc /* 149 */ ED_INSERT, /* M-^U */
5193e1db26aSLionel Sambuc /* 150 */ ED_INSERT, /* M-^V */
5203e1db26aSLionel Sambuc /* 151 */ ED_INSERT, /* M-^W */
5213e1db26aSLionel Sambuc /* 152 */ ED_INSERT, /* M-^X */
5223e1db26aSLionel Sambuc /* 153 */ ED_INSERT, /* M-^Y */
5233e1db26aSLionel Sambuc /* 154 */ ED_INSERT, /* M-^Z */
5243e1db26aSLionel Sambuc /* 155 */ ED_INSERT, /* M-^[ */
5253e1db26aSLionel Sambuc /* 156 */ ED_INSERT, /* M-^\ */
5263e1db26aSLionel Sambuc /* 157 */ ED_INSERT, /* M-^] */
5273e1db26aSLionel Sambuc /* 158 */ ED_INSERT, /* M-^^ */
5283e1db26aSLionel Sambuc /* 159 */ ED_INSERT, /* M-^_ */
5293e1db26aSLionel Sambuc /* 160 */ ED_INSERT, /* M-SPACE */
5303e1db26aSLionel Sambuc /* 161 */ ED_INSERT, /* M-! */
5313e1db26aSLionel Sambuc /* 162 */ ED_INSERT, /* M-" */
5323e1db26aSLionel Sambuc /* 163 */ ED_INSERT, /* M-# */
5333e1db26aSLionel Sambuc /* 164 */ ED_INSERT, /* M-$ */
5343e1db26aSLionel Sambuc /* 165 */ ED_INSERT, /* M-% */
5353e1db26aSLionel Sambuc /* 166 */ ED_INSERT, /* M-& */
5363e1db26aSLionel Sambuc /* 167 */ ED_INSERT, /* M-' */
5373e1db26aSLionel Sambuc /* 168 */ ED_INSERT, /* M-( */
5383e1db26aSLionel Sambuc /* 169 */ ED_INSERT, /* M-) */
5393e1db26aSLionel Sambuc /* 170 */ ED_INSERT, /* M-* */
5403e1db26aSLionel Sambuc /* 171 */ ED_INSERT, /* M-+ */
5413e1db26aSLionel Sambuc /* 172 */ ED_INSERT, /* M-, */
5423e1db26aSLionel Sambuc /* 173 */ ED_INSERT, /* M-- */
5433e1db26aSLionel Sambuc /* 174 */ ED_INSERT, /* M-. */
5443e1db26aSLionel Sambuc /* 175 */ ED_INSERT, /* M-/ */
5453e1db26aSLionel Sambuc /* 176 */ ED_INSERT, /* M-0 */
5463e1db26aSLionel Sambuc /* 177 */ ED_INSERT, /* M-1 */
5473e1db26aSLionel Sambuc /* 178 */ ED_INSERT, /* M-2 */
5483e1db26aSLionel Sambuc /* 179 */ ED_INSERT, /* M-3 */
5493e1db26aSLionel Sambuc /* 180 */ ED_INSERT, /* M-4 */
5503e1db26aSLionel Sambuc /* 181 */ ED_INSERT, /* M-5 */
5513e1db26aSLionel Sambuc /* 182 */ ED_INSERT, /* M-6 */
5523e1db26aSLionel Sambuc /* 183 */ ED_INSERT, /* M-7 */
5533e1db26aSLionel Sambuc /* 184 */ ED_INSERT, /* M-8 */
5543e1db26aSLionel Sambuc /* 185 */ ED_INSERT, /* M-9 */
5553e1db26aSLionel Sambuc /* 186 */ ED_INSERT, /* M-: */
5563e1db26aSLionel Sambuc /* 187 */ ED_INSERT, /* M-; */
5573e1db26aSLionel Sambuc /* 188 */ ED_INSERT, /* M-< */
5583e1db26aSLionel Sambuc /* 189 */ ED_INSERT, /* M-= */
5593e1db26aSLionel Sambuc /* 190 */ ED_INSERT, /* M-> */
5603e1db26aSLionel Sambuc /* 191 */ ED_INSERT, /* M-? */
5613e1db26aSLionel Sambuc /* 192 */ ED_INSERT, /* M-@ */
5623e1db26aSLionel Sambuc /* 193 */ ED_INSERT, /* M-A */
5633e1db26aSLionel Sambuc /* 194 */ ED_INSERT, /* M-B */
5643e1db26aSLionel Sambuc /* 195 */ ED_INSERT, /* M-C */
5653e1db26aSLionel Sambuc /* 196 */ ED_INSERT, /* M-D */
5663e1db26aSLionel Sambuc /* 197 */ ED_INSERT, /* M-E */
5673e1db26aSLionel Sambuc /* 198 */ ED_INSERT, /* M-F */
5683e1db26aSLionel Sambuc /* 199 */ ED_INSERT, /* M-G */
5693e1db26aSLionel Sambuc /* 200 */ ED_INSERT, /* M-H */
5703e1db26aSLionel Sambuc /* 201 */ ED_INSERT, /* M-I */
5713e1db26aSLionel Sambuc /* 202 */ ED_INSERT, /* M-J */
5723e1db26aSLionel Sambuc /* 203 */ ED_INSERT, /* M-K */
5733e1db26aSLionel Sambuc /* 204 */ ED_INSERT, /* M-L */
5743e1db26aSLionel Sambuc /* 205 */ ED_INSERT, /* M-M */
5753e1db26aSLionel Sambuc /* 206 */ ED_INSERT, /* M-N */
5763e1db26aSLionel Sambuc /* 207 */ ED_INSERT, /* M-O */
5773e1db26aSLionel Sambuc /* 208 */ ED_INSERT, /* M-P */
5783e1db26aSLionel Sambuc /* 209 */ ED_INSERT, /* M-Q */
5793e1db26aSLionel Sambuc /* 210 */ ED_INSERT, /* M-R */
5803e1db26aSLionel Sambuc /* 211 */ ED_INSERT, /* M-S */
5813e1db26aSLionel Sambuc /* 212 */ ED_INSERT, /* M-T */
5823e1db26aSLionel Sambuc /* 213 */ ED_INSERT, /* M-U */
5833e1db26aSLionel Sambuc /* 214 */ ED_INSERT, /* M-V */
5843e1db26aSLionel Sambuc /* 215 */ ED_INSERT, /* M-W */
5853e1db26aSLionel Sambuc /* 216 */ ED_INSERT, /* M-X */
5863e1db26aSLionel Sambuc /* 217 */ ED_INSERT, /* M-Y */
5873e1db26aSLionel Sambuc /* 218 */ ED_INSERT, /* M-Z */
5883e1db26aSLionel Sambuc /* 219 */ ED_INSERT, /* M-[ */
5893e1db26aSLionel Sambuc /* 220 */ ED_INSERT, /* M-\ */
5903e1db26aSLionel Sambuc /* 221 */ ED_INSERT, /* M-] */
5913e1db26aSLionel Sambuc /* 222 */ ED_INSERT, /* M-^ */
5923e1db26aSLionel Sambuc /* 223 */ ED_INSERT, /* M-_ */
5933e1db26aSLionel Sambuc /* 224 */ ED_INSERT, /* M-` */
5943e1db26aSLionel Sambuc /* 225 */ ED_INSERT, /* M-a */
5953e1db26aSLionel Sambuc /* 226 */ ED_INSERT, /* M-b */
5963e1db26aSLionel Sambuc /* 227 */ ED_INSERT, /* M-c */
5973e1db26aSLionel Sambuc /* 228 */ ED_INSERT, /* M-d */
5983e1db26aSLionel Sambuc /* 229 */ ED_INSERT, /* M-e */
5993e1db26aSLionel Sambuc /* 230 */ ED_INSERT, /* M-f */
6003e1db26aSLionel Sambuc /* 231 */ ED_INSERT, /* M-g */
6013e1db26aSLionel Sambuc /* 232 */ ED_INSERT, /* M-h */
6023e1db26aSLionel Sambuc /* 233 */ ED_INSERT, /* M-i */
6033e1db26aSLionel Sambuc /* 234 */ ED_INSERT, /* M-j */
6043e1db26aSLionel Sambuc /* 235 */ ED_INSERT, /* M-k */
6053e1db26aSLionel Sambuc /* 236 */ ED_INSERT, /* M-l */
6063e1db26aSLionel Sambuc /* 237 */ ED_INSERT, /* M-m */
6073e1db26aSLionel Sambuc /* 238 */ ED_INSERT, /* M-n */
6083e1db26aSLionel Sambuc /* 239 */ ED_INSERT, /* M-o */
6093e1db26aSLionel Sambuc /* 240 */ ED_INSERT, /* M-p */
6103e1db26aSLionel Sambuc /* 241 */ ED_INSERT, /* M-q */
6113e1db26aSLionel Sambuc /* 242 */ ED_INSERT, /* M-r */
6123e1db26aSLionel Sambuc /* 243 */ ED_INSERT, /* M-s */
6133e1db26aSLionel Sambuc /* 244 */ ED_INSERT, /* M-t */
6143e1db26aSLionel Sambuc /* 245 */ ED_INSERT, /* M-u */
6153e1db26aSLionel Sambuc /* 246 */ ED_INSERT, /* M-v */
6163e1db26aSLionel Sambuc /* 247 */ ED_INSERT, /* M-w */
6173e1db26aSLionel Sambuc /* 248 */ ED_INSERT, /* M-x */
6183e1db26aSLionel Sambuc /* 249 */ ED_INSERT, /* M-y */
6193e1db26aSLionel Sambuc /* 250 */ ED_INSERT, /* M-z */
6203e1db26aSLionel Sambuc /* 251 */ ED_INSERT, /* M-{ */
6213e1db26aSLionel Sambuc /* 252 */ ED_INSERT, /* M-| */
6223e1db26aSLionel Sambuc /* 253 */ ED_INSERT, /* M-} */
6233e1db26aSLionel Sambuc /* 254 */ ED_INSERT, /* M-~ */
6243e1db26aSLionel Sambuc /* 255 */ ED_INSERT /* M-^? */
6253e1db26aSLionel Sambuc };
6263e1db26aSLionel Sambuc
6273e1db26aSLionel Sambuc private const el_action_t el_map_vi_command[] = {
6283e1db26aSLionel Sambuc /* 0 */ ED_UNASSIGNED, /* ^@ */
6293e1db26aSLionel Sambuc /* 1 */ ED_MOVE_TO_BEG, /* ^A */
6303e1db26aSLionel Sambuc /* 2 */ ED_UNASSIGNED, /* ^B */
6313e1db26aSLionel Sambuc /* 3 */ ED_TTY_SIGINT, /* ^C */
6323e1db26aSLionel Sambuc /* 4 */ ED_UNASSIGNED, /* ^D */
6333e1db26aSLionel Sambuc /* 5 */ ED_MOVE_TO_END, /* ^E */
6343e1db26aSLionel Sambuc /* 6 */ ED_UNASSIGNED, /* ^F */
6353e1db26aSLionel Sambuc /* 7 */ ED_UNASSIGNED, /* ^G */
6363e1db26aSLionel Sambuc /* 8 */ ED_DELETE_PREV_CHAR, /* ^H */
6373e1db26aSLionel Sambuc /* 9 */ ED_UNASSIGNED, /* ^I */
6383e1db26aSLionel Sambuc /* 10 */ ED_NEWLINE, /* ^J */
6393e1db26aSLionel Sambuc /* 11 */ ED_KILL_LINE, /* ^K */
6403e1db26aSLionel Sambuc /* 12 */ ED_CLEAR_SCREEN, /* ^L */
6413e1db26aSLionel Sambuc /* 13 */ ED_NEWLINE, /* ^M */
6423e1db26aSLionel Sambuc /* 14 */ ED_NEXT_HISTORY, /* ^N */
6433e1db26aSLionel Sambuc /* 15 */ ED_TTY_FLUSH_OUTPUT, /* ^O */
6443e1db26aSLionel Sambuc /* 16 */ ED_PREV_HISTORY, /* ^P */
6453e1db26aSLionel Sambuc /* 17 */ ED_TTY_START_OUTPUT, /* ^Q */
6463e1db26aSLionel Sambuc /* 18 */ ED_REDISPLAY, /* ^R */
6473e1db26aSLionel Sambuc /* 19 */ ED_TTY_STOP_OUTPUT, /* ^S */
6483e1db26aSLionel Sambuc /* 20 */ ED_UNASSIGNED, /* ^T */
6493e1db26aSLionel Sambuc /* 21 */ VI_KILL_LINE_PREV, /* ^U */
6503e1db26aSLionel Sambuc /* 22 */ ED_UNASSIGNED, /* ^V */
6513e1db26aSLionel Sambuc /* 23 */ ED_DELETE_PREV_WORD, /* ^W */
6523e1db26aSLionel Sambuc /* 24 */ ED_UNASSIGNED, /* ^X */
6533e1db26aSLionel Sambuc /* 25 */ ED_UNASSIGNED, /* ^Y */
6543e1db26aSLionel Sambuc /* 26 */ ED_UNASSIGNED, /* ^Z */
6553e1db26aSLionel Sambuc /* 27 */ EM_META_NEXT, /* ^[ */
6563e1db26aSLionel Sambuc /* 28 */ ED_TTY_SIGQUIT, /* ^\ */
6573e1db26aSLionel Sambuc /* 29 */ ED_UNASSIGNED, /* ^] */
6583e1db26aSLionel Sambuc /* 30 */ ED_UNASSIGNED, /* ^^ */
6593e1db26aSLionel Sambuc /* 31 */ ED_UNASSIGNED, /* ^_ */
6603e1db26aSLionel Sambuc /* 32 */ ED_NEXT_CHAR, /* SPACE */
6613e1db26aSLionel Sambuc /* 33 */ ED_UNASSIGNED, /* ! */
6623e1db26aSLionel Sambuc /* 34 */ ED_UNASSIGNED, /* " */
6633e1db26aSLionel Sambuc /* 35 */ VI_COMMENT_OUT, /* # */
6643e1db26aSLionel Sambuc /* 36 */ ED_MOVE_TO_END, /* $ */
6653e1db26aSLionel Sambuc /* 37 */ VI_MATCH, /* % */
6663e1db26aSLionel Sambuc /* 38 */ ED_UNASSIGNED, /* & */
6673e1db26aSLionel Sambuc /* 39 */ ED_UNASSIGNED, /* ' */
6683e1db26aSLionel Sambuc /* 40 */ ED_UNASSIGNED, /* ( */
6693e1db26aSLionel Sambuc /* 41 */ ED_UNASSIGNED, /* ) */
6703e1db26aSLionel Sambuc /* 42 */ ED_UNASSIGNED, /* * */
6713e1db26aSLionel Sambuc /* 43 */ ED_NEXT_HISTORY, /* + */
6723e1db26aSLionel Sambuc /* 44 */ VI_REPEAT_PREV_CHAR, /* , */
6733e1db26aSLionel Sambuc /* 45 */ ED_PREV_HISTORY, /* - */
6743e1db26aSLionel Sambuc /* 46 */ VI_REDO, /* . */
6753e1db26aSLionel Sambuc /* 47 */ VI_SEARCH_PREV, /* / */
6763e1db26aSLionel Sambuc /* 48 */ VI_ZERO, /* 0 */
6773e1db26aSLionel Sambuc /* 49 */ ED_ARGUMENT_DIGIT, /* 1 */
6783e1db26aSLionel Sambuc /* 50 */ ED_ARGUMENT_DIGIT, /* 2 */
6793e1db26aSLionel Sambuc /* 51 */ ED_ARGUMENT_DIGIT, /* 3 */
6803e1db26aSLionel Sambuc /* 52 */ ED_ARGUMENT_DIGIT, /* 4 */
6813e1db26aSLionel Sambuc /* 53 */ ED_ARGUMENT_DIGIT, /* 5 */
6823e1db26aSLionel Sambuc /* 54 */ ED_ARGUMENT_DIGIT, /* 6 */
6833e1db26aSLionel Sambuc /* 55 */ ED_ARGUMENT_DIGIT, /* 7 */
6843e1db26aSLionel Sambuc /* 56 */ ED_ARGUMENT_DIGIT, /* 8 */
6853e1db26aSLionel Sambuc /* 57 */ ED_ARGUMENT_DIGIT, /* 9 */
6863e1db26aSLionel Sambuc /* 58 */ ED_COMMAND, /* : */
6873e1db26aSLionel Sambuc /* 59 */ VI_REPEAT_NEXT_CHAR, /* ; */
6883e1db26aSLionel Sambuc /* 60 */ ED_UNASSIGNED, /* < */
6893e1db26aSLionel Sambuc /* 61 */ ED_UNASSIGNED, /* = */
6903e1db26aSLionel Sambuc /* 62 */ ED_UNASSIGNED, /* > */
6913e1db26aSLionel Sambuc /* 63 */ VI_SEARCH_NEXT, /* ? */
6923e1db26aSLionel Sambuc /* 64 */ VI_ALIAS, /* @ */
6933e1db26aSLionel Sambuc /* 65 */ VI_ADD_AT_EOL, /* A */
6943e1db26aSLionel Sambuc /* 66 */ VI_PREV_BIG_WORD, /* B */
6953e1db26aSLionel Sambuc /* 67 */ VI_CHANGE_TO_EOL, /* C */
6963e1db26aSLionel Sambuc /* 68 */ ED_KILL_LINE, /* D */
6973e1db26aSLionel Sambuc /* 69 */ VI_END_BIG_WORD, /* E */
6983e1db26aSLionel Sambuc /* 70 */ VI_PREV_CHAR, /* F */
6993e1db26aSLionel Sambuc /* 71 */ VI_TO_HISTORY_LINE, /* G */
7003e1db26aSLionel Sambuc /* 72 */ ED_UNASSIGNED, /* H */
7013e1db26aSLionel Sambuc /* 73 */ VI_INSERT_AT_BOL, /* I */
7023e1db26aSLionel Sambuc /* 74 */ ED_SEARCH_NEXT_HISTORY, /* J */
7033e1db26aSLionel Sambuc /* 75 */ ED_SEARCH_PREV_HISTORY, /* K */
7043e1db26aSLionel Sambuc /* 76 */ ED_UNASSIGNED, /* L */
7053e1db26aSLionel Sambuc /* 77 */ ED_UNASSIGNED, /* M */
7063e1db26aSLionel Sambuc /* 78 */ VI_REPEAT_SEARCH_PREV, /* N */
7073e1db26aSLionel Sambuc /* 79 */ ED_SEQUENCE_LEAD_IN, /* O */
7083e1db26aSLionel Sambuc /* 80 */ VI_PASTE_PREV, /* P */
7093e1db26aSLionel Sambuc /* 81 */ ED_UNASSIGNED, /* Q */
7103e1db26aSLionel Sambuc /* 82 */ VI_REPLACE_MODE, /* R */
7113e1db26aSLionel Sambuc /* 83 */ VI_SUBSTITUTE_LINE, /* S */
7123e1db26aSLionel Sambuc /* 84 */ VI_TO_PREV_CHAR, /* T */
7133e1db26aSLionel Sambuc /* 85 */ VI_UNDO_LINE, /* U */
7143e1db26aSLionel Sambuc /* 86 */ ED_UNASSIGNED, /* V */
7153e1db26aSLionel Sambuc /* 87 */ VI_NEXT_BIG_WORD, /* W */
7163e1db26aSLionel Sambuc /* 88 */ ED_DELETE_PREV_CHAR, /* X */
7173e1db26aSLionel Sambuc /* 89 */ VI_YANK_END, /* Y */
7183e1db26aSLionel Sambuc /* 90 */ ED_UNASSIGNED, /* Z */
7193e1db26aSLionel Sambuc /* 91 */ ED_SEQUENCE_LEAD_IN, /* [ */
7203e1db26aSLionel Sambuc /* 92 */ ED_UNASSIGNED, /* \ */
7213e1db26aSLionel Sambuc /* 93 */ ED_UNASSIGNED, /* ] */
7223e1db26aSLionel Sambuc /* 94 */ ED_MOVE_TO_BEG, /* ^ */
7233e1db26aSLionel Sambuc /* 95 */ VI_HISTORY_WORD, /* _ */
7243e1db26aSLionel Sambuc /* 96 */ ED_UNASSIGNED, /* ` */
7253e1db26aSLionel Sambuc /* 97 */ VI_ADD, /* a */
7263e1db26aSLionel Sambuc /* 98 */ VI_PREV_WORD, /* b */
7273e1db26aSLionel Sambuc /* 99 */ VI_CHANGE_META, /* c */
7283e1db26aSLionel Sambuc /* 100 */ VI_DELETE_META, /* d */
7293e1db26aSLionel Sambuc /* 101 */ VI_END_WORD, /* e */
7303e1db26aSLionel Sambuc /* 102 */ VI_NEXT_CHAR, /* f */
7313e1db26aSLionel Sambuc /* 103 */ ED_UNASSIGNED, /* g */
7323e1db26aSLionel Sambuc /* 104 */ ED_PREV_CHAR, /* h */
7333e1db26aSLionel Sambuc /* 105 */ VI_INSERT, /* i */
7343e1db26aSLionel Sambuc /* 106 */ ED_NEXT_HISTORY, /* j */
7353e1db26aSLionel Sambuc /* 107 */ ED_PREV_HISTORY, /* k */
7363e1db26aSLionel Sambuc /* 108 */ ED_NEXT_CHAR, /* l */
7373e1db26aSLionel Sambuc /* 109 */ ED_UNASSIGNED, /* m */
7383e1db26aSLionel Sambuc /* 110 */ VI_REPEAT_SEARCH_NEXT, /* n */
7393e1db26aSLionel Sambuc /* 111 */ ED_UNASSIGNED, /* o */
7403e1db26aSLionel Sambuc /* 112 */ VI_PASTE_NEXT, /* p */
7413e1db26aSLionel Sambuc /* 113 */ ED_UNASSIGNED, /* q */
7423e1db26aSLionel Sambuc /* 114 */ VI_REPLACE_CHAR, /* r */
7433e1db26aSLionel Sambuc /* 115 */ VI_SUBSTITUTE_CHAR, /* s */
7443e1db26aSLionel Sambuc /* 116 */ VI_TO_NEXT_CHAR, /* t */
7453e1db26aSLionel Sambuc /* 117 */ VI_UNDO, /* u */
7463e1db26aSLionel Sambuc /* 118 */ VI_HISTEDIT, /* v */
7473e1db26aSLionel Sambuc /* 119 */ VI_NEXT_WORD, /* w */
7483e1db26aSLionel Sambuc /* 120 */ ED_DELETE_NEXT_CHAR, /* x */
7493e1db26aSLionel Sambuc /* 121 */ VI_YANK, /* y */
7503e1db26aSLionel Sambuc /* 122 */ ED_UNASSIGNED, /* z */
7513e1db26aSLionel Sambuc /* 123 */ ED_UNASSIGNED, /* { */
7523e1db26aSLionel Sambuc /* 124 */ VI_TO_COLUMN, /* | */
7533e1db26aSLionel Sambuc /* 125 */ ED_UNASSIGNED, /* } */
7543e1db26aSLionel Sambuc /* 126 */ VI_CHANGE_CASE, /* ~ */
7553e1db26aSLionel Sambuc /* 127 */ ED_DELETE_PREV_CHAR, /* ^? */
7563e1db26aSLionel Sambuc /* 128 */ ED_UNASSIGNED, /* M-^@ */
7573e1db26aSLionel Sambuc /* 129 */ ED_UNASSIGNED, /* M-^A */
7583e1db26aSLionel Sambuc /* 130 */ ED_UNASSIGNED, /* M-^B */
7593e1db26aSLionel Sambuc /* 131 */ ED_UNASSIGNED, /* M-^C */
7603e1db26aSLionel Sambuc /* 132 */ ED_UNASSIGNED, /* M-^D */
7613e1db26aSLionel Sambuc /* 133 */ ED_UNASSIGNED, /* M-^E */
7623e1db26aSLionel Sambuc /* 134 */ ED_UNASSIGNED, /* M-^F */
7633e1db26aSLionel Sambuc /* 135 */ ED_UNASSIGNED, /* M-^G */
7643e1db26aSLionel Sambuc /* 136 */ ED_UNASSIGNED, /* M-^H */
7653e1db26aSLionel Sambuc /* 137 */ ED_UNASSIGNED, /* M-^I */
7663e1db26aSLionel Sambuc /* 138 */ ED_UNASSIGNED, /* M-^J */
7673e1db26aSLionel Sambuc /* 139 */ ED_UNASSIGNED, /* M-^K */
7683e1db26aSLionel Sambuc /* 140 */ ED_UNASSIGNED, /* M-^L */
7693e1db26aSLionel Sambuc /* 141 */ ED_UNASSIGNED, /* M-^M */
7703e1db26aSLionel Sambuc /* 142 */ ED_UNASSIGNED, /* M-^N */
7713e1db26aSLionel Sambuc /* 143 */ ED_UNASSIGNED, /* M-^O */
7723e1db26aSLionel Sambuc /* 144 */ ED_UNASSIGNED, /* M-^P */
7733e1db26aSLionel Sambuc /* 145 */ ED_UNASSIGNED, /* M-^Q */
7743e1db26aSLionel Sambuc /* 146 */ ED_UNASSIGNED, /* M-^R */
7753e1db26aSLionel Sambuc /* 147 */ ED_UNASSIGNED, /* M-^S */
7763e1db26aSLionel Sambuc /* 148 */ ED_UNASSIGNED, /* M-^T */
7773e1db26aSLionel Sambuc /* 149 */ ED_UNASSIGNED, /* M-^U */
7783e1db26aSLionel Sambuc /* 150 */ ED_UNASSIGNED, /* M-^V */
7793e1db26aSLionel Sambuc /* 151 */ ED_UNASSIGNED, /* M-^W */
7803e1db26aSLionel Sambuc /* 152 */ ED_UNASSIGNED, /* M-^X */
7813e1db26aSLionel Sambuc /* 153 */ ED_UNASSIGNED, /* M-^Y */
7823e1db26aSLionel Sambuc /* 154 */ ED_UNASSIGNED, /* M-^Z */
7833e1db26aSLionel Sambuc /* 155 */ ED_UNASSIGNED, /* M-^[ */
7843e1db26aSLionel Sambuc /* 156 */ ED_UNASSIGNED, /* M-^\ */
7853e1db26aSLionel Sambuc /* 157 */ ED_UNASSIGNED, /* M-^] */
7863e1db26aSLionel Sambuc /* 158 */ ED_UNASSIGNED, /* M-^^ */
7873e1db26aSLionel Sambuc /* 159 */ ED_UNASSIGNED, /* M-^_ */
7883e1db26aSLionel Sambuc /* 160 */ ED_UNASSIGNED, /* M-SPACE */
7893e1db26aSLionel Sambuc /* 161 */ ED_UNASSIGNED, /* M-! */
7903e1db26aSLionel Sambuc /* 162 */ ED_UNASSIGNED, /* M-" */
7913e1db26aSLionel Sambuc /* 163 */ ED_UNASSIGNED, /* M-# */
7923e1db26aSLionel Sambuc /* 164 */ ED_UNASSIGNED, /* M-$ */
7933e1db26aSLionel Sambuc /* 165 */ ED_UNASSIGNED, /* M-% */
7943e1db26aSLionel Sambuc /* 166 */ ED_UNASSIGNED, /* M-& */
7953e1db26aSLionel Sambuc /* 167 */ ED_UNASSIGNED, /* M-' */
7963e1db26aSLionel Sambuc /* 168 */ ED_UNASSIGNED, /* M-( */
7973e1db26aSLionel Sambuc /* 169 */ ED_UNASSIGNED, /* M-) */
7983e1db26aSLionel Sambuc /* 170 */ ED_UNASSIGNED, /* M-* */
7993e1db26aSLionel Sambuc /* 171 */ ED_UNASSIGNED, /* M-+ */
8003e1db26aSLionel Sambuc /* 172 */ ED_UNASSIGNED, /* M-, */
8013e1db26aSLionel Sambuc /* 173 */ ED_UNASSIGNED, /* M-- */
8023e1db26aSLionel Sambuc /* 174 */ ED_UNASSIGNED, /* M-. */
8033e1db26aSLionel Sambuc /* 175 */ ED_UNASSIGNED, /* M-/ */
8043e1db26aSLionel Sambuc /* 176 */ ED_UNASSIGNED, /* M-0 */
8053e1db26aSLionel Sambuc /* 177 */ ED_UNASSIGNED, /* M-1 */
8063e1db26aSLionel Sambuc /* 178 */ ED_UNASSIGNED, /* M-2 */
8073e1db26aSLionel Sambuc /* 179 */ ED_UNASSIGNED, /* M-3 */
8083e1db26aSLionel Sambuc /* 180 */ ED_UNASSIGNED, /* M-4 */
8093e1db26aSLionel Sambuc /* 181 */ ED_UNASSIGNED, /* M-5 */
8103e1db26aSLionel Sambuc /* 182 */ ED_UNASSIGNED, /* M-6 */
8113e1db26aSLionel Sambuc /* 183 */ ED_UNASSIGNED, /* M-7 */
8123e1db26aSLionel Sambuc /* 184 */ ED_UNASSIGNED, /* M-8 */
8133e1db26aSLionel Sambuc /* 185 */ ED_UNASSIGNED, /* M-9 */
8143e1db26aSLionel Sambuc /* 186 */ ED_UNASSIGNED, /* M-: */
8153e1db26aSLionel Sambuc /* 187 */ ED_UNASSIGNED, /* M-; */
8163e1db26aSLionel Sambuc /* 188 */ ED_UNASSIGNED, /* M-< */
8173e1db26aSLionel Sambuc /* 189 */ ED_UNASSIGNED, /* M-= */
8183e1db26aSLionel Sambuc /* 190 */ ED_UNASSIGNED, /* M-> */
8193e1db26aSLionel Sambuc /* 191 */ ED_UNASSIGNED, /* M-? */
8203e1db26aSLionel Sambuc /* 192 */ ED_UNASSIGNED, /* M-@ */
8213e1db26aSLionel Sambuc /* 193 */ ED_UNASSIGNED, /* M-A */
8223e1db26aSLionel Sambuc /* 194 */ ED_UNASSIGNED, /* M-B */
8233e1db26aSLionel Sambuc /* 195 */ ED_UNASSIGNED, /* M-C */
8243e1db26aSLionel Sambuc /* 196 */ ED_UNASSIGNED, /* M-D */
8253e1db26aSLionel Sambuc /* 197 */ ED_UNASSIGNED, /* M-E */
8263e1db26aSLionel Sambuc /* 198 */ ED_UNASSIGNED, /* M-F */
8273e1db26aSLionel Sambuc /* 199 */ ED_UNASSIGNED, /* M-G */
8283e1db26aSLionel Sambuc /* 200 */ ED_UNASSIGNED, /* M-H */
8293e1db26aSLionel Sambuc /* 201 */ ED_UNASSIGNED, /* M-I */
8303e1db26aSLionel Sambuc /* 202 */ ED_UNASSIGNED, /* M-J */
8313e1db26aSLionel Sambuc /* 203 */ ED_UNASSIGNED, /* M-K */
8323e1db26aSLionel Sambuc /* 204 */ ED_UNASSIGNED, /* M-L */
8333e1db26aSLionel Sambuc /* 205 */ ED_UNASSIGNED, /* M-M */
8343e1db26aSLionel Sambuc /* 206 */ ED_UNASSIGNED, /* M-N */
8353e1db26aSLionel Sambuc /* 207 */ ED_SEQUENCE_LEAD_IN, /* M-O */
8363e1db26aSLionel Sambuc /* 208 */ ED_UNASSIGNED, /* M-P */
8373e1db26aSLionel Sambuc /* 209 */ ED_UNASSIGNED, /* M-Q */
8383e1db26aSLionel Sambuc /* 210 */ ED_UNASSIGNED, /* M-R */
8393e1db26aSLionel Sambuc /* 211 */ ED_UNASSIGNED, /* M-S */
8403e1db26aSLionel Sambuc /* 212 */ ED_UNASSIGNED, /* M-T */
8413e1db26aSLionel Sambuc /* 213 */ ED_UNASSIGNED, /* M-U */
8423e1db26aSLionel Sambuc /* 214 */ ED_UNASSIGNED, /* M-V */
8433e1db26aSLionel Sambuc /* 215 */ ED_UNASSIGNED, /* M-W */
8443e1db26aSLionel Sambuc /* 216 */ ED_UNASSIGNED, /* M-X */
8453e1db26aSLionel Sambuc /* 217 */ ED_UNASSIGNED, /* M-Y */
8463e1db26aSLionel Sambuc /* 218 */ ED_UNASSIGNED, /* M-Z */
8473e1db26aSLionel Sambuc /* 219 */ ED_SEQUENCE_LEAD_IN, /* M-[ */
8483e1db26aSLionel Sambuc /* 220 */ ED_UNASSIGNED, /* M-\ */
8493e1db26aSLionel Sambuc /* 221 */ ED_UNASSIGNED, /* M-] */
8503e1db26aSLionel Sambuc /* 222 */ ED_UNASSIGNED, /* M-^ */
8513e1db26aSLionel Sambuc /* 223 */ ED_UNASSIGNED, /* M-_ */
8523e1db26aSLionel Sambuc /* 224 */ ED_UNASSIGNED, /* M-` */
8533e1db26aSLionel Sambuc /* 225 */ ED_UNASSIGNED, /* M-a */
8543e1db26aSLionel Sambuc /* 226 */ ED_UNASSIGNED, /* M-b */
8553e1db26aSLionel Sambuc /* 227 */ ED_UNASSIGNED, /* M-c */
8563e1db26aSLionel Sambuc /* 228 */ ED_UNASSIGNED, /* M-d */
8573e1db26aSLionel Sambuc /* 229 */ ED_UNASSIGNED, /* M-e */
8583e1db26aSLionel Sambuc /* 230 */ ED_UNASSIGNED, /* M-f */
8593e1db26aSLionel Sambuc /* 231 */ ED_UNASSIGNED, /* M-g */
8603e1db26aSLionel Sambuc /* 232 */ ED_UNASSIGNED, /* M-h */
8613e1db26aSLionel Sambuc /* 233 */ ED_UNASSIGNED, /* M-i */
8623e1db26aSLionel Sambuc /* 234 */ ED_UNASSIGNED, /* M-j */
8633e1db26aSLionel Sambuc /* 235 */ ED_UNASSIGNED, /* M-k */
8643e1db26aSLionel Sambuc /* 236 */ ED_UNASSIGNED, /* M-l */
8653e1db26aSLionel Sambuc /* 237 */ ED_UNASSIGNED, /* M-m */
8663e1db26aSLionel Sambuc /* 238 */ ED_UNASSIGNED, /* M-n */
8673e1db26aSLionel Sambuc /* 239 */ ED_UNASSIGNED, /* M-o */
8683e1db26aSLionel Sambuc /* 240 */ ED_UNASSIGNED, /* M-p */
8693e1db26aSLionel Sambuc /* 241 */ ED_UNASSIGNED, /* M-q */
8703e1db26aSLionel Sambuc /* 242 */ ED_UNASSIGNED, /* M-r */
8713e1db26aSLionel Sambuc /* 243 */ ED_UNASSIGNED, /* M-s */
8723e1db26aSLionel Sambuc /* 244 */ ED_UNASSIGNED, /* M-t */
8733e1db26aSLionel Sambuc /* 245 */ ED_UNASSIGNED, /* M-u */
8743e1db26aSLionel Sambuc /* 246 */ ED_UNASSIGNED, /* M-v */
8753e1db26aSLionel Sambuc /* 247 */ ED_UNASSIGNED, /* M-w */
8763e1db26aSLionel Sambuc /* 248 */ ED_UNASSIGNED, /* M-x */
8773e1db26aSLionel Sambuc /* 249 */ ED_UNASSIGNED, /* M-y */
8783e1db26aSLionel Sambuc /* 250 */ ED_UNASSIGNED, /* M-z */
8793e1db26aSLionel Sambuc /* 251 */ ED_UNASSIGNED, /* M-{ */
8803e1db26aSLionel Sambuc /* 252 */ ED_UNASSIGNED, /* M-| */
8813e1db26aSLionel Sambuc /* 253 */ ED_UNASSIGNED, /* M-} */
8823e1db26aSLionel Sambuc /* 254 */ ED_UNASSIGNED, /* M-~ */
8833e1db26aSLionel Sambuc /* 255 */ ED_UNASSIGNED /* M-^? */
8843e1db26aSLionel Sambuc };
8853e1db26aSLionel Sambuc
8863e1db26aSLionel Sambuc
8873e1db26aSLionel Sambuc /* map_init():
8883e1db26aSLionel Sambuc * Initialize and allocate the maps
8893e1db26aSLionel Sambuc */
8903e1db26aSLionel Sambuc protected int
map_init(EditLine * el)8913e1db26aSLionel Sambuc map_init(EditLine *el)
8923e1db26aSLionel Sambuc {
8933e1db26aSLionel Sambuc
8943e1db26aSLionel Sambuc /*
8953e1db26aSLionel Sambuc * Make sure those are correct before starting.
8963e1db26aSLionel Sambuc */
8973e1db26aSLionel Sambuc #ifdef MAP_DEBUG
8983e1db26aSLionel Sambuc if (sizeof(el_map_emacs) != N_KEYS * sizeof(el_action_t))
8993e1db26aSLionel Sambuc EL_ABORT((el->errfile, "Emacs map incorrect\n"));
9003e1db26aSLionel Sambuc if (sizeof(el_map_vi_command) != N_KEYS * sizeof(el_action_t))
9013e1db26aSLionel Sambuc EL_ABORT((el->errfile, "Vi command map incorrect\n"));
9023e1db26aSLionel Sambuc if (sizeof(el_map_vi_insert) != N_KEYS * sizeof(el_action_t))
9033e1db26aSLionel Sambuc EL_ABORT((el->errfile, "Vi insert map incorrect\n"));
9043e1db26aSLionel Sambuc #endif
9053e1db26aSLionel Sambuc
9063e1db26aSLionel Sambuc el->el_map.alt = el_malloc(sizeof(*el->el_map.alt) * N_KEYS);
9073e1db26aSLionel Sambuc if (el->el_map.alt == NULL)
9083e1db26aSLionel Sambuc return -1;
9093e1db26aSLionel Sambuc el->el_map.key = el_malloc(sizeof(*el->el_map.key) * N_KEYS);
9103e1db26aSLionel Sambuc if (el->el_map.key == NULL)
9113e1db26aSLionel Sambuc return -1;
9123e1db26aSLionel Sambuc el->el_map.emacs = el_map_emacs;
9133e1db26aSLionel Sambuc el->el_map.vic = el_map_vi_command;
9143e1db26aSLionel Sambuc el->el_map.vii = el_map_vi_insert;
9153e1db26aSLionel Sambuc el->el_map.help = el_malloc(sizeof(*el->el_map.help) * EL_NUM_FCNS);
9163e1db26aSLionel Sambuc if (el->el_map.help == NULL)
9173e1db26aSLionel Sambuc return -1;
9183e1db26aSLionel Sambuc (void) memcpy(el->el_map.help, help__get(),
9193e1db26aSLionel Sambuc sizeof(*el->el_map.help) * EL_NUM_FCNS);
9203e1db26aSLionel Sambuc el->el_map.func = el_malloc(sizeof(*el->el_map.func) * EL_NUM_FCNS);
9213e1db26aSLionel Sambuc if (el->el_map.func == NULL)
9223e1db26aSLionel Sambuc return -1;
9233e1db26aSLionel Sambuc memcpy(el->el_map.func, func__get(), sizeof(*el->el_map.func)
9243e1db26aSLionel Sambuc * EL_NUM_FCNS);
9253e1db26aSLionel Sambuc el->el_map.nfunc = EL_NUM_FCNS;
9263e1db26aSLionel Sambuc
9273e1db26aSLionel Sambuc #ifdef VIDEFAULT
9283e1db26aSLionel Sambuc map_init_vi(el);
9293e1db26aSLionel Sambuc #else
9303e1db26aSLionel Sambuc map_init_emacs(el);
9313e1db26aSLionel Sambuc #endif /* VIDEFAULT */
9323e1db26aSLionel Sambuc return 0;
9333e1db26aSLionel Sambuc }
9343e1db26aSLionel Sambuc
9353e1db26aSLionel Sambuc
9363e1db26aSLionel Sambuc /* map_end():
9373e1db26aSLionel Sambuc * Free the space taken by the editor maps
9383e1db26aSLionel Sambuc */
9393e1db26aSLionel Sambuc protected void
map_end(EditLine * el)9403e1db26aSLionel Sambuc map_end(EditLine *el)
9413e1db26aSLionel Sambuc {
9423e1db26aSLionel Sambuc
9433e1db26aSLionel Sambuc el_free(el->el_map.alt);
9443e1db26aSLionel Sambuc el->el_map.alt = NULL;
9453e1db26aSLionel Sambuc el_free(el->el_map.key);
9463e1db26aSLionel Sambuc el->el_map.key = NULL;
9473e1db26aSLionel Sambuc el->el_map.emacs = NULL;
9483e1db26aSLionel Sambuc el->el_map.vic = NULL;
9493e1db26aSLionel Sambuc el->el_map.vii = NULL;
9503e1db26aSLionel Sambuc el_free(el->el_map.help);
9513e1db26aSLionel Sambuc el->el_map.help = NULL;
9523e1db26aSLionel Sambuc el_free(el->el_map.func);
9533e1db26aSLionel Sambuc el->el_map.func = NULL;
9543e1db26aSLionel Sambuc }
9553e1db26aSLionel Sambuc
9563e1db26aSLionel Sambuc
9573e1db26aSLionel Sambuc /* map_init_nls():
9583e1db26aSLionel Sambuc * Find all the printable keys and bind them to self insert
9593e1db26aSLionel Sambuc */
9603e1db26aSLionel Sambuc private void
map_init_nls(EditLine * el)9613e1db26aSLionel Sambuc map_init_nls(EditLine *el)
9623e1db26aSLionel Sambuc {
9633e1db26aSLionel Sambuc int i;
9643e1db26aSLionel Sambuc
9653e1db26aSLionel Sambuc el_action_t *map = el->el_map.key;
9663e1db26aSLionel Sambuc
9673e1db26aSLionel Sambuc for (i = 0200; i <= 0377; i++)
9683e1db26aSLionel Sambuc if (Isprint(i))
9693e1db26aSLionel Sambuc map[i] = ED_INSERT;
9703e1db26aSLionel Sambuc }
9713e1db26aSLionel Sambuc
9723e1db26aSLionel Sambuc
9733e1db26aSLionel Sambuc /* map_init_meta():
9743e1db26aSLionel Sambuc * Bind all the meta keys to the appropriate ESC-<key> sequence
9753e1db26aSLionel Sambuc */
9763e1db26aSLionel Sambuc private void
map_init_meta(EditLine * el)9773e1db26aSLionel Sambuc map_init_meta(EditLine *el)
9783e1db26aSLionel Sambuc {
9793e1db26aSLionel Sambuc Char buf[3];
9803e1db26aSLionel Sambuc int i;
9813e1db26aSLionel Sambuc el_action_t *map = el->el_map.key;
9823e1db26aSLionel Sambuc el_action_t *alt = el->el_map.alt;
9833e1db26aSLionel Sambuc
9843e1db26aSLionel Sambuc for (i = 0; i <= 0377 && map[i] != EM_META_NEXT; i++)
9853e1db26aSLionel Sambuc continue;
9863e1db26aSLionel Sambuc
9873e1db26aSLionel Sambuc if (i > 0377) {
9883e1db26aSLionel Sambuc for (i = 0; i <= 0377 && alt[i] != EM_META_NEXT; i++)
9893e1db26aSLionel Sambuc continue;
9903e1db26aSLionel Sambuc if (i > 0377) {
9913e1db26aSLionel Sambuc i = 033;
9923e1db26aSLionel Sambuc if (el->el_map.type == MAP_VI)
9933e1db26aSLionel Sambuc map = alt;
9943e1db26aSLionel Sambuc } else
9953e1db26aSLionel Sambuc map = alt;
9963e1db26aSLionel Sambuc }
9973e1db26aSLionel Sambuc buf[0] = (Char) i;
9983e1db26aSLionel Sambuc buf[2] = 0;
9993e1db26aSLionel Sambuc for (i = 0200; i <= 0377; i++)
10003e1db26aSLionel Sambuc switch (map[i]) {
10013e1db26aSLionel Sambuc case ED_INSERT:
10023e1db26aSLionel Sambuc case ED_UNASSIGNED:
10033e1db26aSLionel Sambuc case ED_SEQUENCE_LEAD_IN:
10043e1db26aSLionel Sambuc break;
10053e1db26aSLionel Sambuc default:
10063e1db26aSLionel Sambuc buf[1] = i & 0177;
10073e1db26aSLionel Sambuc keymacro_add(el, buf, keymacro_map_cmd(el, (int) map[i]), XK_CMD);
10083e1db26aSLionel Sambuc break;
10093e1db26aSLionel Sambuc }
10103e1db26aSLionel Sambuc map[(int) buf[0]] = ED_SEQUENCE_LEAD_IN;
10113e1db26aSLionel Sambuc }
10123e1db26aSLionel Sambuc
10133e1db26aSLionel Sambuc
10143e1db26aSLionel Sambuc /* map_init_vi():
10153e1db26aSLionel Sambuc * Initialize the vi bindings
10163e1db26aSLionel Sambuc */
10173e1db26aSLionel Sambuc protected void
map_init_vi(EditLine * el)10183e1db26aSLionel Sambuc map_init_vi(EditLine *el)
10193e1db26aSLionel Sambuc {
10203e1db26aSLionel Sambuc int i;
10213e1db26aSLionel Sambuc el_action_t *key = el->el_map.key;
10223e1db26aSLionel Sambuc el_action_t *alt = el->el_map.alt;
10233e1db26aSLionel Sambuc const el_action_t *vii = el->el_map.vii;
10243e1db26aSLionel Sambuc const el_action_t *vic = el->el_map.vic;
10253e1db26aSLionel Sambuc
10263e1db26aSLionel Sambuc el->el_map.type = MAP_VI;
10273e1db26aSLionel Sambuc el->el_map.current = el->el_map.key;
10283e1db26aSLionel Sambuc
10293e1db26aSLionel Sambuc keymacro_reset(el);
10303e1db26aSLionel Sambuc
10313e1db26aSLionel Sambuc for (i = 0; i < N_KEYS; i++) {
10323e1db26aSLionel Sambuc key[i] = vii[i];
10333e1db26aSLionel Sambuc alt[i] = vic[i];
10343e1db26aSLionel Sambuc }
10353e1db26aSLionel Sambuc
10363e1db26aSLionel Sambuc map_init_meta(el);
10373e1db26aSLionel Sambuc map_init_nls(el);
10383e1db26aSLionel Sambuc
10393e1db26aSLionel Sambuc tty_bind_char(el, 1);
10403e1db26aSLionel Sambuc terminal_bind_arrow(el);
10413e1db26aSLionel Sambuc }
10423e1db26aSLionel Sambuc
10433e1db26aSLionel Sambuc
10443e1db26aSLionel Sambuc /* map_init_emacs():
10453e1db26aSLionel Sambuc * Initialize the emacs bindings
10463e1db26aSLionel Sambuc */
10473e1db26aSLionel Sambuc protected void
map_init_emacs(EditLine * el)10483e1db26aSLionel Sambuc map_init_emacs(EditLine *el)
10493e1db26aSLionel Sambuc {
10503e1db26aSLionel Sambuc int i;
10513e1db26aSLionel Sambuc Char buf[3];
10523e1db26aSLionel Sambuc el_action_t *key = el->el_map.key;
10533e1db26aSLionel Sambuc el_action_t *alt = el->el_map.alt;
10543e1db26aSLionel Sambuc const el_action_t *emacs = el->el_map.emacs;
10553e1db26aSLionel Sambuc
10563e1db26aSLionel Sambuc el->el_map.type = MAP_EMACS;
10573e1db26aSLionel Sambuc el->el_map.current = el->el_map.key;
10583e1db26aSLionel Sambuc keymacro_reset(el);
10593e1db26aSLionel Sambuc
10603e1db26aSLionel Sambuc for (i = 0; i < N_KEYS; i++) {
10613e1db26aSLionel Sambuc key[i] = emacs[i];
10623e1db26aSLionel Sambuc alt[i] = ED_UNASSIGNED;
10633e1db26aSLionel Sambuc }
10643e1db26aSLionel Sambuc
10653e1db26aSLionel Sambuc map_init_meta(el);
10663e1db26aSLionel Sambuc map_init_nls(el);
10673e1db26aSLionel Sambuc
10683e1db26aSLionel Sambuc buf[0] = CONTROL('X');
10693e1db26aSLionel Sambuc buf[1] = CONTROL('X');
10703e1db26aSLionel Sambuc buf[2] = 0;
10713e1db26aSLionel Sambuc keymacro_add(el, buf, keymacro_map_cmd(el, EM_EXCHANGE_MARK), XK_CMD);
10723e1db26aSLionel Sambuc
10733e1db26aSLionel Sambuc tty_bind_char(el, 1);
10743e1db26aSLionel Sambuc terminal_bind_arrow(el);
10753e1db26aSLionel Sambuc }
10763e1db26aSLionel Sambuc
10773e1db26aSLionel Sambuc
10783e1db26aSLionel Sambuc /* map_set_editor():
10793e1db26aSLionel Sambuc * Set the editor
10803e1db26aSLionel Sambuc */
10813e1db26aSLionel Sambuc protected int
map_set_editor(EditLine * el,Char * editor)10823e1db26aSLionel Sambuc map_set_editor(EditLine *el, Char *editor)
10833e1db26aSLionel Sambuc {
10843e1db26aSLionel Sambuc
10853e1db26aSLionel Sambuc if (Strcmp(editor, STR("emacs")) == 0) {
10863e1db26aSLionel Sambuc map_init_emacs(el);
10873e1db26aSLionel Sambuc return 0;
10883e1db26aSLionel Sambuc }
10893e1db26aSLionel Sambuc if (Strcmp(editor, STR("vi")) == 0) {
10903e1db26aSLionel Sambuc map_init_vi(el);
10913e1db26aSLionel Sambuc return 0;
10923e1db26aSLionel Sambuc }
10933e1db26aSLionel Sambuc return -1;
10943e1db26aSLionel Sambuc }
10953e1db26aSLionel Sambuc
10963e1db26aSLionel Sambuc
10973e1db26aSLionel Sambuc /* map_get_editor():
10983e1db26aSLionel Sambuc * Retrieve the editor
10993e1db26aSLionel Sambuc */
11003e1db26aSLionel Sambuc protected int
map_get_editor(EditLine * el,const Char ** editor)11013e1db26aSLionel Sambuc map_get_editor(EditLine *el, const Char **editor)
11023e1db26aSLionel Sambuc {
11033e1db26aSLionel Sambuc
11043e1db26aSLionel Sambuc if (editor == NULL)
11053e1db26aSLionel Sambuc return -1;
11063e1db26aSLionel Sambuc switch (el->el_map.type) {
11073e1db26aSLionel Sambuc case MAP_EMACS:
11083e1db26aSLionel Sambuc *editor = STR("emacs");
11093e1db26aSLionel Sambuc return 0;
11103e1db26aSLionel Sambuc case MAP_VI:
11113e1db26aSLionel Sambuc *editor = STR("vi");
11123e1db26aSLionel Sambuc return 0;
11133e1db26aSLionel Sambuc }
11143e1db26aSLionel Sambuc return -1;
11153e1db26aSLionel Sambuc }
11163e1db26aSLionel Sambuc
11173e1db26aSLionel Sambuc
11183e1db26aSLionel Sambuc /* map_print_key():
11193e1db26aSLionel Sambuc * Print the function description for 1 key
11203e1db26aSLionel Sambuc */
11213e1db26aSLionel Sambuc private void
map_print_key(EditLine * el,el_action_t * map,const Char * in)11223e1db26aSLionel Sambuc map_print_key(EditLine *el, el_action_t *map, const Char *in)
11233e1db26aSLionel Sambuc {
11243e1db26aSLionel Sambuc char outbuf[EL_BUFSIZ];
11253e1db26aSLionel Sambuc el_bindings_t *bp, *ep;
11263e1db26aSLionel Sambuc
11273e1db26aSLionel Sambuc if (in[0] == '\0' || in[1] == '\0') {
11283e1db26aSLionel Sambuc (void) keymacro__decode_str(in, outbuf, sizeof(outbuf), "");
11293e1db26aSLionel Sambuc ep = &el->el_map.help[el->el_map.nfunc];
11303e1db26aSLionel Sambuc for (bp = el->el_map.help; bp < ep; bp++)
11313e1db26aSLionel Sambuc if (bp->func == map[(unsigned char) *in]) {
11323e1db26aSLionel Sambuc (void) fprintf(el->el_outfile,
11333e1db26aSLionel Sambuc "%s\t->\t" FSTR "\n", outbuf, bp->name);
11343e1db26aSLionel Sambuc return;
11353e1db26aSLionel Sambuc }
11363e1db26aSLionel Sambuc } else
11373e1db26aSLionel Sambuc keymacro_print(el, in);
11383e1db26aSLionel Sambuc }
11393e1db26aSLionel Sambuc
11403e1db26aSLionel Sambuc
11413e1db26aSLionel Sambuc /* map_print_some_keys():
11423e1db26aSLionel Sambuc * Print keys from first to last
11433e1db26aSLionel Sambuc */
11443e1db26aSLionel Sambuc private void
map_print_some_keys(EditLine * el,el_action_t * map,Int first,Int last)11453e1db26aSLionel Sambuc map_print_some_keys(EditLine *el, el_action_t *map, Int first, Int last)
11463e1db26aSLionel Sambuc {
11473e1db26aSLionel Sambuc el_bindings_t *bp, *ep;
11483e1db26aSLionel Sambuc Char firstbuf[2], lastbuf[2];
11493e1db26aSLionel Sambuc char unparsbuf[EL_BUFSIZ], extrabuf[EL_BUFSIZ];
11503e1db26aSLionel Sambuc
11513e1db26aSLionel Sambuc firstbuf[0] = first;
11523e1db26aSLionel Sambuc firstbuf[1] = 0;
11533e1db26aSLionel Sambuc lastbuf[0] = last;
11543e1db26aSLionel Sambuc lastbuf[1] = 0;
11553e1db26aSLionel Sambuc if (map[first] == ED_UNASSIGNED) {
11563e1db26aSLionel Sambuc if (first == last) {
11573e1db26aSLionel Sambuc (void) keymacro__decode_str(firstbuf, unparsbuf,
11583e1db26aSLionel Sambuc sizeof(unparsbuf), STRQQ);
11593e1db26aSLionel Sambuc (void) fprintf(el->el_outfile,
11603e1db26aSLionel Sambuc "%-15s-> is undefined\n", unparsbuf);
11613e1db26aSLionel Sambuc }
11623e1db26aSLionel Sambuc return;
11633e1db26aSLionel Sambuc }
11643e1db26aSLionel Sambuc ep = &el->el_map.help[el->el_map.nfunc];
11653e1db26aSLionel Sambuc for (bp = el->el_map.help; bp < ep; bp++) {
11663e1db26aSLionel Sambuc if (bp->func == map[first]) {
11673e1db26aSLionel Sambuc if (first == last) {
11683e1db26aSLionel Sambuc (void) keymacro__decode_str(firstbuf, unparsbuf,
11693e1db26aSLionel Sambuc sizeof(unparsbuf), STRQQ);
11703e1db26aSLionel Sambuc (void) fprintf(el->el_outfile, "%-15s-> " FSTR "\n",
11713e1db26aSLionel Sambuc unparsbuf, bp->name);
11723e1db26aSLionel Sambuc } else {
11733e1db26aSLionel Sambuc (void) keymacro__decode_str(firstbuf, unparsbuf,
11743e1db26aSLionel Sambuc sizeof(unparsbuf), STRQQ);
11753e1db26aSLionel Sambuc (void) keymacro__decode_str(lastbuf, extrabuf,
11763e1db26aSLionel Sambuc sizeof(extrabuf), STRQQ);
11773e1db26aSLionel Sambuc (void) fprintf(el->el_outfile,
11783e1db26aSLionel Sambuc "%-4s to %-7s-> " FSTR "\n",
11793e1db26aSLionel Sambuc unparsbuf, extrabuf, bp->name);
11803e1db26aSLionel Sambuc }
11813e1db26aSLionel Sambuc return;
11823e1db26aSLionel Sambuc }
11833e1db26aSLionel Sambuc }
11843e1db26aSLionel Sambuc #ifdef MAP_DEBUG
11853e1db26aSLionel Sambuc if (map == el->el_map.key) {
11863e1db26aSLionel Sambuc (void) keymacro__decode_str(firstbuf, unparsbuf,
11873e1db26aSLionel Sambuc sizeof(unparsbuf), STRQQ);
11883e1db26aSLionel Sambuc (void) fprintf(el->el_outfile,
11893e1db26aSLionel Sambuc "BUG!!! %s isn't bound to anything.\n", unparsbuf);
11903e1db26aSLionel Sambuc (void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n",
11913e1db26aSLionel Sambuc first, el->el_map.key[first]);
11923e1db26aSLionel Sambuc } else {
11933e1db26aSLionel Sambuc (void) keymacro__decode_str(firstbuf, unparsbuf,
11943e1db26aSLionel Sambuc sizeof(unparsbuf), STRQQ);
11953e1db26aSLionel Sambuc (void) fprintf(el->el_outfile,
11963e1db26aSLionel Sambuc "BUG!!! %s isn't bound to anything.\n", unparsbuf);
11973e1db26aSLionel Sambuc (void) fprintf(el->el_outfile, "el->el_map.alt[%d] == %d\n",
11983e1db26aSLionel Sambuc first, el->el_map.alt[first]);
11993e1db26aSLionel Sambuc }
12003e1db26aSLionel Sambuc #endif
12013e1db26aSLionel Sambuc EL_ABORT((el->el_errfile, "Error printing keys\n"));
12023e1db26aSLionel Sambuc }
12033e1db26aSLionel Sambuc
12043e1db26aSLionel Sambuc
12053e1db26aSLionel Sambuc /* map_print_all_keys():
12063e1db26aSLionel Sambuc * Print the function description for all keys.
12073e1db26aSLionel Sambuc */
12083e1db26aSLionel Sambuc private void
map_print_all_keys(EditLine * el)12093e1db26aSLionel Sambuc map_print_all_keys(EditLine *el)
12103e1db26aSLionel Sambuc {
12113e1db26aSLionel Sambuc int prev, i;
12123e1db26aSLionel Sambuc
12133e1db26aSLionel Sambuc (void) fprintf(el->el_outfile, "Standard key bindings\n");
12143e1db26aSLionel Sambuc prev = 0;
12153e1db26aSLionel Sambuc for (i = 0; i < N_KEYS; i++) {
12163e1db26aSLionel Sambuc if (el->el_map.key[prev] == el->el_map.key[i])
12173e1db26aSLionel Sambuc continue;
12183e1db26aSLionel Sambuc map_print_some_keys(el, el->el_map.key, prev, i - 1);
12193e1db26aSLionel Sambuc prev = i;
12203e1db26aSLionel Sambuc }
12213e1db26aSLionel Sambuc map_print_some_keys(el, el->el_map.key, prev, i - 1);
12223e1db26aSLionel Sambuc
12233e1db26aSLionel Sambuc (void) fprintf(el->el_outfile, "Alternative key bindings\n");
12243e1db26aSLionel Sambuc prev = 0;
12253e1db26aSLionel Sambuc for (i = 0; i < N_KEYS; i++) {
12263e1db26aSLionel Sambuc if (el->el_map.alt[prev] == el->el_map.alt[i])
12273e1db26aSLionel Sambuc continue;
12283e1db26aSLionel Sambuc map_print_some_keys(el, el->el_map.alt, prev, i - 1);
12293e1db26aSLionel Sambuc prev = i;
12303e1db26aSLionel Sambuc }
12313e1db26aSLionel Sambuc map_print_some_keys(el, el->el_map.alt, prev, i - 1);
12323e1db26aSLionel Sambuc
12333e1db26aSLionel Sambuc (void) fprintf(el->el_outfile, "Multi-character bindings\n");
12343e1db26aSLionel Sambuc keymacro_print(el, STR(""));
12353e1db26aSLionel Sambuc (void) fprintf(el->el_outfile, "Arrow key bindings\n");
12363e1db26aSLionel Sambuc terminal_print_arrow(el, STR(""));
12373e1db26aSLionel Sambuc }
12383e1db26aSLionel Sambuc
12393e1db26aSLionel Sambuc
12403e1db26aSLionel Sambuc /* map_bind():
12413e1db26aSLionel Sambuc * Add/remove/change bindings
12423e1db26aSLionel Sambuc */
12433e1db26aSLionel Sambuc protected int
map_bind(EditLine * el,int argc,const Char ** argv)12443e1db26aSLionel Sambuc map_bind(EditLine *el, int argc, const Char **argv)
12453e1db26aSLionel Sambuc {
12463e1db26aSLionel Sambuc el_action_t *map;
12473e1db26aSLionel Sambuc int ntype, rem;
12483e1db26aSLionel Sambuc const Char *p;
12493e1db26aSLionel Sambuc Char inbuf[EL_BUFSIZ];
12503e1db26aSLionel Sambuc Char outbuf[EL_BUFSIZ];
12513e1db26aSLionel Sambuc const Char *in = NULL;
125284d9c625SLionel Sambuc Char *out;
12533e1db26aSLionel Sambuc el_bindings_t *bp, *ep;
12543e1db26aSLionel Sambuc int cmd;
12553e1db26aSLionel Sambuc int key;
12563e1db26aSLionel Sambuc
12573e1db26aSLionel Sambuc if (argv == NULL)
12583e1db26aSLionel Sambuc return -1;
12593e1db26aSLionel Sambuc
12603e1db26aSLionel Sambuc map = el->el_map.key;
12613e1db26aSLionel Sambuc ntype = XK_CMD;
12623e1db26aSLionel Sambuc key = rem = 0;
12633e1db26aSLionel Sambuc for (argc = 1; (p = argv[argc]) != NULL; argc++)
12643e1db26aSLionel Sambuc if (p[0] == '-')
12653e1db26aSLionel Sambuc switch (p[1]) {
12663e1db26aSLionel Sambuc case 'a':
12673e1db26aSLionel Sambuc map = el->el_map.alt;
12683e1db26aSLionel Sambuc break;
12693e1db26aSLionel Sambuc
12703e1db26aSLionel Sambuc case 's':
12713e1db26aSLionel Sambuc ntype = XK_STR;
12723e1db26aSLionel Sambuc break;
12733e1db26aSLionel Sambuc #ifdef notyet
12743e1db26aSLionel Sambuc case 'c':
12753e1db26aSLionel Sambuc ntype = XK_EXE;
12763e1db26aSLionel Sambuc break;
12773e1db26aSLionel Sambuc #endif
12783e1db26aSLionel Sambuc case 'k':
12793e1db26aSLionel Sambuc key = 1;
12803e1db26aSLionel Sambuc break;
12813e1db26aSLionel Sambuc
12823e1db26aSLionel Sambuc case 'r':
12833e1db26aSLionel Sambuc rem = 1;
12843e1db26aSLionel Sambuc break;
12853e1db26aSLionel Sambuc
12863e1db26aSLionel Sambuc case 'v':
12873e1db26aSLionel Sambuc map_init_vi(el);
12883e1db26aSLionel Sambuc return 0;
12893e1db26aSLionel Sambuc
12903e1db26aSLionel Sambuc case 'e':
12913e1db26aSLionel Sambuc map_init_emacs(el);
12923e1db26aSLionel Sambuc return 0;
12933e1db26aSLionel Sambuc
12943e1db26aSLionel Sambuc case 'l':
12953e1db26aSLionel Sambuc ep = &el->el_map.help[el->el_map.nfunc];
12963e1db26aSLionel Sambuc for (bp = el->el_map.help; bp < ep; bp++)
12973e1db26aSLionel Sambuc (void) fprintf(el->el_outfile,
12983e1db26aSLionel Sambuc "" FSTR "\n\t" FSTR "\n",
12993e1db26aSLionel Sambuc bp->name, bp->description);
13003e1db26aSLionel Sambuc return 0;
13013e1db26aSLionel Sambuc default:
13023e1db26aSLionel Sambuc (void) fprintf(el->el_errfile,
1303*0a6a1f1dSLionel Sambuc "" FSTR ": Invalid switch `" FCHAR "'.\n",
1304*0a6a1f1dSLionel Sambuc argv[0], (Int)p[1]);
13053e1db26aSLionel Sambuc }
13063e1db26aSLionel Sambuc else
13073e1db26aSLionel Sambuc break;
13083e1db26aSLionel Sambuc
13093e1db26aSLionel Sambuc if (argv[argc] == NULL) {
13103e1db26aSLionel Sambuc map_print_all_keys(el);
13113e1db26aSLionel Sambuc return 0;
13123e1db26aSLionel Sambuc }
13133e1db26aSLionel Sambuc if (key)
13143e1db26aSLionel Sambuc in = argv[argc++];
13153e1db26aSLionel Sambuc else if ((in = parse__string(inbuf, argv[argc++])) == NULL) {
13163e1db26aSLionel Sambuc (void) fprintf(el->el_errfile,
13173e1db26aSLionel Sambuc "" FSTR ": Invalid \\ or ^ in instring.\n",
13183e1db26aSLionel Sambuc argv[0]);
13193e1db26aSLionel Sambuc return -1;
13203e1db26aSLionel Sambuc }
13213e1db26aSLionel Sambuc if (rem) {
13223e1db26aSLionel Sambuc if (key) {
13233e1db26aSLionel Sambuc (void) terminal_clear_arrow(el, in);
13243e1db26aSLionel Sambuc return -1;
13253e1db26aSLionel Sambuc }
13263e1db26aSLionel Sambuc if (in[1])
13273e1db26aSLionel Sambuc (void) keymacro_delete(el, in);
13283e1db26aSLionel Sambuc else if (map[(unsigned char) *in] == ED_SEQUENCE_LEAD_IN)
13293e1db26aSLionel Sambuc (void) keymacro_delete(el, in);
13303e1db26aSLionel Sambuc else
13313e1db26aSLionel Sambuc map[(unsigned char) *in] = ED_UNASSIGNED;
13323e1db26aSLionel Sambuc return 0;
13333e1db26aSLionel Sambuc }
13343e1db26aSLionel Sambuc if (argv[argc] == NULL) {
13353e1db26aSLionel Sambuc if (key)
13363e1db26aSLionel Sambuc terminal_print_arrow(el, in);
13373e1db26aSLionel Sambuc else
13383e1db26aSLionel Sambuc map_print_key(el, map, in);
13393e1db26aSLionel Sambuc return 0;
13403e1db26aSLionel Sambuc }
13413e1db26aSLionel Sambuc #ifdef notyet
13423e1db26aSLionel Sambuc if (argv[argc + 1] != NULL) {
13433e1db26aSLionel Sambuc bindkeymacro_usage();
13443e1db26aSLionel Sambuc return -1;
13453e1db26aSLionel Sambuc }
13463e1db26aSLionel Sambuc #endif
13473e1db26aSLionel Sambuc
13483e1db26aSLionel Sambuc switch (ntype) {
13493e1db26aSLionel Sambuc case XK_STR:
13503e1db26aSLionel Sambuc case XK_EXE:
13513e1db26aSLionel Sambuc if ((out = parse__string(outbuf, argv[argc])) == NULL) {
13523e1db26aSLionel Sambuc (void) fprintf(el->el_errfile,
13533e1db26aSLionel Sambuc "" FSTR ": Invalid \\ or ^ in outstring.\n", argv[0]);
13543e1db26aSLionel Sambuc return -1;
13553e1db26aSLionel Sambuc }
13563e1db26aSLionel Sambuc if (key)
13573e1db26aSLionel Sambuc terminal_set_arrow(el, in, keymacro_map_str(el, out), ntype);
13583e1db26aSLionel Sambuc else
13593e1db26aSLionel Sambuc keymacro_add(el, in, keymacro_map_str(el, out), ntype);
13603e1db26aSLionel Sambuc map[(unsigned char) *in] = ED_SEQUENCE_LEAD_IN;
13613e1db26aSLionel Sambuc break;
13623e1db26aSLionel Sambuc
13633e1db26aSLionel Sambuc case XK_CMD:
13643e1db26aSLionel Sambuc if ((cmd = parse_cmd(el, argv[argc])) == -1) {
13653e1db26aSLionel Sambuc (void) fprintf(el->el_errfile,
13663e1db26aSLionel Sambuc "" FSTR ": Invalid command `" FSTR "'.\n",
13673e1db26aSLionel Sambuc argv[0], argv[argc]);
13683e1db26aSLionel Sambuc return -1;
13693e1db26aSLionel Sambuc }
13703e1db26aSLionel Sambuc if (key)
137184d9c625SLionel Sambuc terminal_set_arrow(el, in, keymacro_map_cmd(el, cmd), ntype);
13723e1db26aSLionel Sambuc else {
13733e1db26aSLionel Sambuc if (in[1]) {
13743e1db26aSLionel Sambuc keymacro_add(el, in, keymacro_map_cmd(el, cmd), ntype);
13753e1db26aSLionel Sambuc map[(unsigned char) *in] = ED_SEQUENCE_LEAD_IN;
13763e1db26aSLionel Sambuc } else {
13773e1db26aSLionel Sambuc keymacro_clear(el, map, in);
13783e1db26aSLionel Sambuc map[(unsigned char) *in] = (el_action_t)cmd;
13793e1db26aSLionel Sambuc }
13803e1db26aSLionel Sambuc }
13813e1db26aSLionel Sambuc break;
13823e1db26aSLionel Sambuc
13833e1db26aSLionel Sambuc /* coverity[dead_error_begin] */
13843e1db26aSLionel Sambuc default:
13853e1db26aSLionel Sambuc EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
13863e1db26aSLionel Sambuc break;
13873e1db26aSLionel Sambuc }
13883e1db26aSLionel Sambuc return 0;
13893e1db26aSLionel Sambuc }
13903e1db26aSLionel Sambuc
13913e1db26aSLionel Sambuc
13923e1db26aSLionel Sambuc /* map_addfunc():
13933e1db26aSLionel Sambuc * add a user defined function
13943e1db26aSLionel Sambuc */
13953e1db26aSLionel Sambuc protected int
map_addfunc(EditLine * el,const Char * name,const Char * help,el_func_t func)13963e1db26aSLionel Sambuc map_addfunc(EditLine *el, const Char *name, const Char *help, el_func_t func)
13973e1db26aSLionel Sambuc {
13983e1db26aSLionel Sambuc void *p;
1399*0a6a1f1dSLionel Sambuc size_t nf = el->el_map.nfunc + 1;
14003e1db26aSLionel Sambuc
14013e1db26aSLionel Sambuc if (name == NULL || help == NULL || func == NULL)
14023e1db26aSLionel Sambuc return -1;
14033e1db26aSLionel Sambuc
14043e1db26aSLionel Sambuc if ((p = el_realloc(el->el_map.func, nf *
14053e1db26aSLionel Sambuc sizeof(*el->el_map.func))) == NULL)
14063e1db26aSLionel Sambuc return -1;
14073e1db26aSLionel Sambuc el->el_map.func = p;
14083e1db26aSLionel Sambuc if ((p = el_realloc(el->el_map.help, nf * sizeof(*el->el_map.help)))
14093e1db26aSLionel Sambuc == NULL)
14103e1db26aSLionel Sambuc return -1;
14113e1db26aSLionel Sambuc el->el_map.help = p;
14123e1db26aSLionel Sambuc
14133e1db26aSLionel Sambuc nf = (size_t)el->el_map.nfunc;
14143e1db26aSLionel Sambuc el->el_map.func[nf] = func;
14153e1db26aSLionel Sambuc
14163e1db26aSLionel Sambuc el->el_map.help[nf].name = name;
14173e1db26aSLionel Sambuc el->el_map.help[nf].func = (int)nf;
14183e1db26aSLionel Sambuc el->el_map.help[nf].description = help;
14193e1db26aSLionel Sambuc el->el_map.nfunc++;
14203e1db26aSLionel Sambuc
14213e1db26aSLionel Sambuc return 0;
14223e1db26aSLionel Sambuc }
1423