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