"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libedit/map.c" between
tnftp-20151004.tar.gz and tnftp-20200705.tar.gz

About: tnftp is an enhanced ftp client (prior name "lukemftp").

map.c  (tnftp-20151004):map.c  (tnftp-20200705)
/* $NetBSD: map.c,v 1.5 2005/06/09 16:48:58 lukem Exp $ */ /* $NetBSD: map.c,v 1.8 2020/07/04 13:43:21 lukem Exp $ */
/* from NetBSD: map.c,v 1.20 2004/08/13 12:10:39 mycroft Exp */ /* from NetBSD: map.c,v 1.53 2020/03/30 06:54:37 ryo Exp */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
* *
* This code is derived from software contributed to Berkeley by * This code is derived from software contributed to Berkeley by
* Christos Zoulas of Cornell University. * Christos Zoulas of Cornell University.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
skipping to change at line 36 skipping to change at line 36
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include "tnftp.h" #include "config.h"
#include "sys.h"
#if 0 /* tnftp */
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID(" NetBSD: map.c,v 1.53 2020/03/30 06:54:37 ryo Exp ");
#endif
#endif /* not lint && not SCCSID */
#endif /* tnftp */
/* /*
* map.c: Editor function definitions * map.c: Editor function definitions
*/ */
#if 0 /* tnftp */
#include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#include "el.h" #include <string.h>
#endif /* tnftp */
#define N_KEYS 256
private void map_print_key(EditLine *, el_action_t *, const char *); #include "el.h"
private void map_print_some_keys(EditLine *, el_action_t *, int, int); #include "common.h"
private void map_print_all_keys(EditLine *); #include "emacs.h"
private void map_init_nls(EditLine *); #include "vi.h"
private void map_init_meta(EditLine *); #include "fcns.h"
#include "func.h"
#include "help.h"
#include "parse.h"
static void map_print_key(EditLine *, el_action_t *, const wchar_t *);
static void map_print_some_keys(EditLine *, el_action_t *, wint_t, wint_t);
static void map_print_all_keys(EditLine *);
static void map_init_nls(EditLine *);
static void map_init_meta(EditLine *);
/* keymap tables ; should be N_KEYS*sizeof(KEYCMD) bytes long */ /* keymap tables ; should be N_KEYS*sizeof(KEYCMD) bytes long */
private const el_action_t el_map_emacs[] = { static const el_action_t el_map_emacs[] = {
/* 0 */ EM_SET_MARK, /* ^@ */ /* 0 */ EM_SET_MARK, /* ^@ */
/* 1 */ ED_MOVE_TO_BEG, /* ^A */ /* 1 */ ED_MOVE_TO_BEG, /* ^A */
/* 2 */ ED_PREV_CHAR, /* ^B */ /* 2 */ ED_PREV_CHAR, /* ^B */
/* 3 */ ED_TTY_SIGINT, /* ^C */ /* 3 */ ED_IGNORE, /* ^C */
/* 4 */ EM_DELETE_OR_LIST, /* ^D */ /* 4 */ EM_DELETE_OR_LIST, /* ^D */
/* 5 */ ED_MOVE_TO_END, /* ^E */ /* 5 */ ED_MOVE_TO_END, /* ^E */
/* 6 */ ED_NEXT_CHAR, /* ^F */ /* 6 */ ED_NEXT_CHAR, /* ^F */
/* 7 */ ED_UNASSIGNED, /* ^G */ /* 7 */ ED_UNASSIGNED, /* ^G */
/* 8 */ EM_DELETE_PREV_CHAR, /* ^H */ /* 8 */ EM_DELETE_PREV_CHAR, /* ^H */
/* 9 */ ED_UNASSIGNED, /* ^I */ /* 9 */ ED_UNASSIGNED, /* ^I */
/* 10 */ ED_NEWLINE, /* ^J */ /* 10 */ ED_NEWLINE, /* ^J */
/* 11 */ ED_KILL_LINE, /* ^K */ /* 11 */ ED_KILL_LINE, /* ^K */
/* 12 */ ED_CLEAR_SCREEN, /* ^L */ /* 12 */ ED_CLEAR_SCREEN, /* ^L */
/* 13 */ ED_NEWLINE, /* ^M */ /* 13 */ ED_NEWLINE, /* ^M */
/* 14 */ ED_NEXT_HISTORY, /* ^N */ /* 14 */ ED_NEXT_HISTORY, /* ^N */
/* 15 */ ED_TTY_FLUSH_OUTPUT, /* ^O */ /* 15 */ ED_IGNORE, /* ^O */
/* 16 */ ED_PREV_HISTORY, /* ^P */ /* 16 */ ED_PREV_HISTORY, /* ^P */
/* 17 */ ED_TTY_START_OUTPUT, /* ^Q */ /* 17 */ ED_IGNORE, /* ^Q */
/* 18 */ ED_REDISPLAY, /* ^R */ /* 18 */ ED_REDISPLAY, /* ^R */
/* 19 */ ED_TTY_STOP_OUTPUT, /* ^S */ /* 19 */ ED_IGNORE, /* ^S */
/* 20 */ ED_TRANSPOSE_CHARS, /* ^T */ /* 20 */ ED_TRANSPOSE_CHARS, /* ^T */
/* 21 */ EM_KILL_LINE, /* ^U */ /* 21 */ EM_KILL_LINE, /* ^U */
/* 22 */ ED_QUOTED_INSERT, /* ^V */ /* 22 */ ED_QUOTED_INSERT, /* ^V */
/* 23 */ EM_KILL_REGION, /* ^W */ /* 23 */ EM_KILL_REGION, /* ^W */
/* 24 */ ED_SEQUENCE_LEAD_IN, /* ^X */ /* 24 */ ED_SEQUENCE_LEAD_IN, /* ^X */
/* 25 */ EM_YANK, /* ^Y */ /* 25 */ EM_YANK, /* ^Y */
/* 26 */ ED_TTY_SIGTSTP, /* ^Z */ /* 26 */ ED_IGNORE, /* ^Z */
/* 27 */ EM_META_NEXT, /* ^[ */ /* 27 */ EM_META_NEXT, /* ^[ */
/* 28 */ ED_TTY_SIGQUIT, /* ^\ */ /* 28 */ ED_IGNORE, /* ^\ */
/* 29 */ ED_TTY_DSUSP, /* ^] */ /* 29 */ ED_IGNORE, /* ^] */
/* 30 */ ED_UNASSIGNED, /* ^^ */ /* 30 */ ED_UNASSIGNED, /* ^^ */
/* 31 */ ED_UNASSIGNED, /* ^_ */ /* 31 */ ED_UNASSIGNED, /* ^_ */
/* 32 */ ED_INSERT, /* SPACE */ /* 32 */ ED_INSERT, /* SPACE */
/* 33 */ ED_INSERT, /* ! */ /* 33 */ ED_INSERT, /* ! */
/* 34 */ ED_INSERT, /* " */ /* 34 */ ED_INSERT, /* " */
/* 35 */ ED_INSERT, /* # */ /* 35 */ ED_INSERT, /* # */
/* 36 */ ED_INSERT, /* $ */ /* 36 */ ED_INSERT, /* $ */
/* 37 */ ED_INSERT, /* % */ /* 37 */ ED_INSERT, /* % */
/* 38 */ ED_INSERT, /* & */ /* 38 */ ED_INSERT, /* & */
/* 39 */ ED_INSERT, /* ' */ /* 39 */ ED_INSERT, /* ' */
skipping to change at line 321 skipping to change at line 340
/* 254 */ ED_DELETE_PREV_WORD /* M-^? */ /* 254 */ ED_DELETE_PREV_WORD /* M-^? */
/* 255 */ /* 255 */
}; };
/* /*
* keymap table for vi. Each index into above tbl; should be * keymap table for vi. Each index into above tbl; should be
* N_KEYS entries long. Vi mode uses a sticky-extend to do command mode: * N_KEYS entries long. Vi mode uses a sticky-extend to do command mode:
* insert mode characters are in the normal keymap, and command mode * insert mode characters are in the normal keymap, and command mode
* in the extended keymap. * in the extended keymap.
*/ */
private const el_action_t el_map_vi_insert[] = { static const el_action_t el_map_vi_insert[] = {
#ifdef KSHVI #ifdef KSHVI
/* 0 */ ED_UNASSIGNED, /* ^@ */ /* 0 */ ED_UNASSIGNED, /* ^@ */
/* 1 */ ED_INSERT, /* ^A */ /* 1 */ ED_INSERT, /* ^A */
/* 2 */ ED_INSERT, /* ^B */ /* 2 */ ED_INSERT, /* ^B */
/* 3 */ ED_INSERT, /* ^C */ /* 3 */ ED_INSERT, /* ^C */
/* 4 */ VI_LIST_OR_EOF, /* ^D */ /* 4 */ VI_LIST_OR_EOF, /* ^D */
/* 5 */ ED_INSERT, /* ^E */ /* 5 */ ED_INSERT, /* ^E */
/* 6 */ ED_INSERT, /* ^F */ /* 6 */ ED_INSERT, /* ^F */
/* 7 */ ED_INSERT, /* ^G */ /* 7 */ ED_INSERT, /* ^G */
/* 8 */ VI_DELETE_PREV_CHAR, /* ^H */ /* BackSpace key */ /* 8 */ VI_DELETE_PREV_CHAR, /* ^H */ /* BackSpace key */
/* 9 */ ED_INSERT, /* ^I */ /* Tab Key */ /* 9 */ ED_INSERT, /* ^I */ /* Tab Key */
/* 10 */ ED_NEWLINE, /* ^J */ /* 10 */ ED_NEWLINE, /* ^J */
/* 11 */ ED_INSERT, /* ^K */ /* 11 */ ED_INSERT, /* ^K */
/* 12 */ ED_INSERT, /* ^L */ /* 12 */ ED_INSERT, /* ^L */
/* 13 */ ED_NEWLINE, /* ^M */ /* 13 */ ED_NEWLINE, /* ^M */
/* 14 */ ED_INSERT, /* ^N */ /* 14 */ ED_INSERT, /* ^N */
/* 15 */ ED_INSERT, /* ^O */ /* 15 */ ED_INSERT, /* ^O */
/* 16 */ ED_INSERT, /* ^P */ /* 16 */ ED_INSERT, /* ^P */
/* 17 */ ED_TTY_START_OUTPUT, /* ^Q */ /* 17 */ ED_IGNORE, /* ^Q */
/* 18 */ ED_INSERT, /* ^R */ /* 18 */ ED_INSERT, /* ^R */
/* 19 */ ED_TTY_STOP_OUTPUT, /* ^S */ /* 19 */ ED_IGNORE, /* ^S */
/* 20 */ ED_INSERT, /* ^T */ /* 20 */ ED_INSERT, /* ^T */
/* 21 */ VI_KILL_LINE_PREV, /* ^U */ /* 21 */ VI_KILL_LINE_PREV, /* ^U */
/* 22 */ ED_QUOTED_INSERT, /* ^V */ /* 22 */ ED_QUOTED_INSERT, /* ^V */
/* 23 */ ED_DELETE_PREV_WORD, /* ^W */ /* 23 */ ED_DELETE_PREV_WORD, /* ^W */
/* ED_DELETE_PREV_WORD: Only until strt edit pos */ /* ED_DELETE_PREV_WORD: Only until strt edit pos */
/* 24 */ ED_INSERT, /* ^X */ /* 24 */ ED_INSERT, /* ^X */
/* 25 */ ED_INSERT, /* ^Y */ /* 25 */ ED_INSERT, /* ^Y */
/* 26 */ ED_INSERT, /* ^Z */ /* 26 */ ED_INSERT, /* ^Z */
/* 27 */ VI_COMMAND_MODE, /* ^[ */ /* [ Esc ] key */ /* 27 */ VI_COMMAND_MODE, /* ^[ */ /* [ Esc ] key */
/* 28 */ ED_TTY_SIGQUIT, /* ^\ */ /* 28 */ ED_IGNORE, /* ^\ */
/* 29 */ ED_INSERT, /* ^] */ /* 29 */ ED_INSERT, /* ^] */
/* 30 */ ED_INSERT, /* ^^ */ /* 30 */ ED_INSERT, /* ^^ */
/* 31 */ ED_INSERT, /* ^_ */ /* 31 */ ED_INSERT, /* ^_ */
#else /* !KSHVI */ #else /* !KSHVI */
/* /*
* NOTE: These mappings do NOT Correspond well * NOTE: These mappings do NOT Correspond well
* to the KSH VI editing assignments. * to the KSH VI editing assignments.
* On the other and they are convenient and * On the other and they are convenient and
* many people have have gotten used to them. * many people have have gotten used to them.
*/ */
/* 0 */ ED_UNASSIGNED, /* ^@ */ /* 0 */ ED_UNASSIGNED, /* ^@ */
/* 1 */ ED_MOVE_TO_BEG, /* ^A */ /* 1 */ ED_MOVE_TO_BEG, /* ^A */
/* 2 */ ED_PREV_CHAR, /* ^B */ /* 2 */ ED_PREV_CHAR, /* ^B */
/* 3 */ ED_TTY_SIGINT, /* ^C */ /* 3 */ ED_IGNORE, /* ^C */
/* 4 */ VI_LIST_OR_EOF, /* ^D */ /* 4 */ VI_LIST_OR_EOF, /* ^D */
/* 5 */ ED_MOVE_TO_END, /* ^E */ /* 5 */ ED_MOVE_TO_END, /* ^E */
/* 6 */ ED_NEXT_CHAR, /* ^F */ /* 6 */ ED_NEXT_CHAR, /* ^F */
/* 7 */ ED_UNASSIGNED, /* ^G */ /* 7 */ ED_UNASSIGNED, /* ^G */
/* 8 */ VI_DELETE_PREV_CHAR, /* ^H */ /* BackSpace key */ /* 8 */ VI_DELETE_PREV_CHAR, /* ^H */ /* BackSpace key */
/* 9 */ ED_UNASSIGNED, /* ^I */ /* Tab Key */ /* 9 */ ED_UNASSIGNED, /* ^I */ /* Tab Key */
/* 10 */ ED_NEWLINE, /* ^J */ /* 10 */ ED_NEWLINE, /* ^J */
/* 11 */ ED_KILL_LINE, /* ^K */ /* 11 */ ED_KILL_LINE, /* ^K */
/* 12 */ ED_CLEAR_SCREEN, /* ^L */ /* 12 */ ED_CLEAR_SCREEN, /* ^L */
/* 13 */ ED_NEWLINE, /* ^M */ /* 13 */ ED_NEWLINE, /* ^M */
/* 14 */ ED_NEXT_HISTORY, /* ^N */ /* 14 */ ED_NEXT_HISTORY, /* ^N */
/* 15 */ ED_TTY_FLUSH_OUTPUT, /* ^O */ /* 15 */ ED_IGNORE, /* ^O */
/* 16 */ ED_PREV_HISTORY, /* ^P */ /* 16 */ ED_PREV_HISTORY, /* ^P */
/* 17 */ ED_TTY_START_OUTPUT, /* ^Q */ /* 17 */ ED_IGNORE, /* ^Q */
/* 18 */ ED_REDISPLAY, /* ^R */ /* 18 */ ED_REDISPLAY, /* ^R */
/* 19 */ ED_TTY_STOP_OUTPUT, /* ^S */ /* 19 */ ED_IGNORE, /* ^S */
/* 20 */ ED_TRANSPOSE_CHARS, /* ^T */ /* 20 */ ED_TRANSPOSE_CHARS, /* ^T */
/* 21 */ VI_KILL_LINE_PREV, /* ^U */ /* 21 */ VI_KILL_LINE_PREV, /* ^U */
/* 22 */ ED_QUOTED_INSERT, /* ^V */ /* 22 */ ED_QUOTED_INSERT, /* ^V */
/* 23 */ ED_DELETE_PREV_WORD, /* ^W */ /* 23 */ ED_DELETE_PREV_WORD, /* ^W */
/* 24 */ ED_UNASSIGNED, /* ^X */ /* 24 */ ED_UNASSIGNED, /* ^X */
/* 25 */ ED_TTY_DSUSP, /* ^Y */ /* 25 */ ED_IGNORE, /* ^Y */
/* 26 */ ED_TTY_SIGTSTP, /* ^Z */ /* 26 */ ED_IGNORE, /* ^Z */
/* 27 */ VI_COMMAND_MODE, /* ^[ */ /* 27 */ VI_COMMAND_MODE, /* ^[ */
/* 28 */ ED_TTY_SIGQUIT, /* ^\ */ /* 28 */ ED_IGNORE, /* ^\ */
/* 29 */ ED_UNASSIGNED, /* ^] */ /* 29 */ ED_UNASSIGNED, /* ^] */
/* 30 */ ED_UNASSIGNED, /* ^^ */ /* 30 */ ED_UNASSIGNED, /* ^^ */
/* 31 */ ED_UNASSIGNED, /* ^_ */ /* 31 */ ED_UNASSIGNED, /* ^_ */
#endif /* KSHVI */ #endif /* KSHVI */
/* 32 */ ED_INSERT, /* SPACE */ /* 32 */ ED_INSERT, /* SPACE */
/* 33 */ ED_INSERT, /* ! */ /* 33 */ ED_INSERT, /* ! */
/* 34 */ ED_INSERT, /* " */ /* 34 */ ED_INSERT, /* " */
/* 35 */ ED_INSERT, /* # */ /* 35 */ ED_INSERT, /* # */
/* 36 */ ED_INSERT, /* $ */ /* 36 */ ED_INSERT, /* $ */
/* 37 */ ED_INSERT, /* % */ /* 37 */ ED_INSERT, /* % */
skipping to change at line 622 skipping to change at line 641
/* 248 */ ED_INSERT, /* M-x */ /* 248 */ ED_INSERT, /* M-x */
/* 249 */ ED_INSERT, /* M-y */ /* 249 */ ED_INSERT, /* M-y */
/* 250 */ ED_INSERT, /* M-z */ /* 250 */ ED_INSERT, /* M-z */
/* 251 */ ED_INSERT, /* M-{ */ /* 251 */ ED_INSERT, /* M-{ */
/* 252 */ ED_INSERT, /* M-| */ /* 252 */ ED_INSERT, /* M-| */
/* 253 */ ED_INSERT, /* M-} */ /* 253 */ ED_INSERT, /* M-} */
/* 254 */ ED_INSERT, /* M-~ */ /* 254 */ ED_INSERT, /* M-~ */
/* 255 */ ED_INSERT /* M-^? */ /* 255 */ ED_INSERT /* M-^? */
}; };
private const el_action_t el_map_vi_command[] = { static const el_action_t el_map_vi_command[] = {
/* 0 */ ED_UNASSIGNED, /* ^@ */ /* 0 */ ED_UNASSIGNED, /* ^@ */
/* 1 */ ED_MOVE_TO_BEG, /* ^A */ /* 1 */ ED_MOVE_TO_BEG, /* ^A */
/* 2 */ ED_UNASSIGNED, /* ^B */ /* 2 */ ED_UNASSIGNED, /* ^B */
/* 3 */ ED_TTY_SIGINT, /* ^C */ /* 3 */ ED_IGNORE, /* ^C */
/* 4 */ ED_UNASSIGNED, /* ^D */ /* 4 */ ED_UNASSIGNED, /* ^D */
/* 5 */ ED_MOVE_TO_END, /* ^E */ /* 5 */ ED_MOVE_TO_END, /* ^E */
/* 6 */ ED_UNASSIGNED, /* ^F */ /* 6 */ ED_UNASSIGNED, /* ^F */
/* 7 */ ED_UNASSIGNED, /* ^G */ /* 7 */ ED_UNASSIGNED, /* ^G */
/* 8 */ ED_DELETE_PREV_CHAR, /* ^H */ /* 8 */ ED_DELETE_PREV_CHAR, /* ^H */
/* 9 */ ED_UNASSIGNED, /* ^I */ /* 9 */ ED_UNASSIGNED, /* ^I */
/* 10 */ ED_NEWLINE, /* ^J */ /* 10 */ ED_NEWLINE, /* ^J */
/* 11 */ ED_KILL_LINE, /* ^K */ /* 11 */ ED_KILL_LINE, /* ^K */
/* 12 */ ED_CLEAR_SCREEN, /* ^L */ /* 12 */ ED_CLEAR_SCREEN, /* ^L */
/* 13 */ ED_NEWLINE, /* ^M */ /* 13 */ ED_NEWLINE, /* ^M */
/* 14 */ ED_NEXT_HISTORY, /* ^N */ /* 14 */ ED_NEXT_HISTORY, /* ^N */
/* 15 */ ED_TTY_FLUSH_OUTPUT, /* ^O */ /* 15 */ ED_IGNORE, /* ^O */
/* 16 */ ED_PREV_HISTORY, /* ^P */ /* 16 */ ED_PREV_HISTORY, /* ^P */
/* 17 */ ED_TTY_START_OUTPUT, /* ^Q */ /* 17 */ ED_IGNORE, /* ^Q */
/* 18 */ ED_REDISPLAY, /* ^R */ /* 18 */ ED_REDISPLAY, /* ^R */
/* 19 */ ED_TTY_STOP_OUTPUT, /* ^S */ /* 19 */ ED_IGNORE, /* ^S */
/* 20 */ ED_UNASSIGNED, /* ^T */ /* 20 */ ED_UNASSIGNED, /* ^T */
/* 21 */ VI_KILL_LINE_PREV, /* ^U */ /* 21 */ VI_KILL_LINE_PREV, /* ^U */
/* 22 */ ED_UNASSIGNED, /* ^V */ /* 22 */ ED_UNASSIGNED, /* ^V */
/* 23 */ ED_DELETE_PREV_WORD, /* ^W */ /* 23 */ ED_DELETE_PREV_WORD, /* ^W */
/* 24 */ ED_UNASSIGNED, /* ^X */ /* 24 */ ED_UNASSIGNED, /* ^X */
/* 25 */ ED_UNASSIGNED, /* ^Y */ /* 25 */ ED_UNASSIGNED, /* ^Y */
/* 26 */ ED_UNASSIGNED, /* ^Z */ /* 26 */ ED_UNASSIGNED, /* ^Z */
/* 27 */ EM_META_NEXT, /* ^[ */ /* 27 */ EM_META_NEXT, /* ^[ */
/* 28 */ ED_TTY_SIGQUIT, /* ^\ */ /* 28 */ ED_IGNORE, /* ^\ */
/* 29 */ ED_UNASSIGNED, /* ^] */ /* 29 */ ED_UNASSIGNED, /* ^] */
/* 30 */ ED_UNASSIGNED, /* ^^ */ /* 30 */ ED_UNASSIGNED, /* ^^ */
/* 31 */ ED_UNASSIGNED, /* ^_ */ /* 31 */ ED_UNASSIGNED, /* ^_ */
/* 32 */ ED_NEXT_CHAR, /* SPACE */ /* 32 */ ED_NEXT_CHAR, /* SPACE */
/* 33 */ ED_UNASSIGNED, /* ! */ /* 33 */ ED_UNASSIGNED, /* ! */
/* 34 */ ED_UNASSIGNED, /* " */ /* 34 */ ED_UNASSIGNED, /* " */
/* 35 */ VI_COMMENT_OUT, /* # */ /* 35 */ VI_COMMENT_OUT, /* # */
/* 36 */ ED_MOVE_TO_END, /* $ */ /* 36 */ ED_MOVE_TO_END, /* $ */
/* 37 */ VI_MATCH, /* % */ /* 37 */ VI_MATCH, /* % */
/* 38 */ ED_UNASSIGNED, /* & */ /* 38 */ ED_UNASSIGNED, /* & */
skipping to change at line 884 skipping to change at line 903
/* 251 */ ED_UNASSIGNED, /* M-{ */ /* 251 */ ED_UNASSIGNED, /* M-{ */
/* 252 */ ED_UNASSIGNED, /* M-| */ /* 252 */ ED_UNASSIGNED, /* M-| */
/* 253 */ ED_UNASSIGNED, /* M-} */ /* 253 */ ED_UNASSIGNED, /* M-} */
/* 254 */ ED_UNASSIGNED, /* M-~ */ /* 254 */ ED_UNASSIGNED, /* M-~ */
/* 255 */ ED_UNASSIGNED /* M-^? */ /* 255 */ ED_UNASSIGNED /* M-^? */
}; };
/* map_init(): /* map_init():
* Initialize and allocate the maps * Initialize and allocate the maps
*/ */
protected int libedit_private int
map_init(EditLine *el) map_init(EditLine *el)
{ {
/* /*
* Make sure those are correct before starting. * Make sure those are correct before starting.
*/ */
#ifdef MAP_DEBUG #ifdef MAP_DEBUG
if (sizeof(el_map_emacs) != N_KEYS * sizeof(el_action_t)) if (sizeof(el_map_emacs) != N_KEYS * sizeof(el_action_t))
EL_ABORT((el->errfile, "Emacs map incorrect\n")); EL_ABORT((el->el_errfile, "Emacs map incorrect\n"));
if (sizeof(el_map_vi_command) != N_KEYS * sizeof(el_action_t)) if (sizeof(el_map_vi_command) != N_KEYS * sizeof(el_action_t))
EL_ABORT((el->errfile, "Vi command map incorrect\n")); EL_ABORT((el->el_errfile, "Vi command map incorrect\n"));
if (sizeof(el_map_vi_insert) != N_KEYS * sizeof(el_action_t)) if (sizeof(el_map_vi_insert) != N_KEYS * sizeof(el_action_t))
EL_ABORT((el->errfile, "Vi insert map incorrect\n")); EL_ABORT((el->el_errfile, "Vi insert map incorrect\n"));
#endif #endif
el->el_map.alt = (el_action_t *)el_malloc(sizeof(el_action_t) * N_KEYS); el->el_map.alt = el_calloc(N_KEYS, sizeof(*el->el_map.alt));
if (el->el_map.alt == NULL) if (el->el_map.alt == NULL)
return (-1); return -1;
el->el_map.key = (el_action_t *)el_malloc(sizeof(el_action_t) * N_KEYS); el->el_map.key = el_calloc(N_KEYS, sizeof(*el->el_map.key));
if (el->el_map.key == NULL) if (el->el_map.key == NULL)
return (-1); return -1;
el->el_map.emacs = el_map_emacs; el->el_map.emacs = el_map_emacs;
el->el_map.vic = el_map_vi_command; el->el_map.vic = el_map_vi_command;
el->el_map.vii = el_map_vi_insert; el->el_map.vii = el_map_vi_insert;
el->el_map.help = (el_bindings_t *) el_malloc(sizeof(el_bindings_t) * el->el_map.help = el_calloc(EL_NUM_FCNS, sizeof(*el->el_map.help));
EL_NUM_FCNS);
if (el->el_map.help == NULL) if (el->el_map.help == NULL)
return (-1); return -1;
(void) memcpy(el->el_map.help, help__get(), (void) memcpy(el->el_map.help, el_func_help,
sizeof(el_bindings_t) * EL_NUM_FCNS); sizeof(*el->el_map.help) * EL_NUM_FCNS);
el->el_map.func = (el_func_t *)el_malloc(sizeof(el_func_t) * el->el_map.func = el_calloc(EL_NUM_FCNS, sizeof(*el->el_map.func));
EL_NUM_FCNS);
if (el->el_map.func == NULL) if (el->el_map.func == NULL)
return (-1); return -1;
memcpy(el->el_map.func, func__get(), sizeof(el_func_t) * EL_NUM_FCNS); memcpy(el->el_map.func, el_func, sizeof(*el->el_map.func)
* EL_NUM_FCNS);
el->el_map.nfunc = EL_NUM_FCNS; el->el_map.nfunc = EL_NUM_FCNS;
#ifdef VIDEFAULT #ifdef VIDEFAULT
map_init_vi(el); map_init_vi(el);
#else #else
map_init_emacs(el); map_init_emacs(el);
#endif /* VIDEFAULT */ #endif /* VIDEFAULT */
return (0); return 0;
} }
/* map_end(): /* map_end():
* Free the space taken by the editor maps * Free the space taken by the editor maps
*/ */
protected void libedit_private void
map_end(EditLine *el) map_end(EditLine *el)
{ {
el_free((ptr_t) el->el_map.alt); el_free(el->el_map.alt);
el->el_map.alt = NULL; el->el_map.alt = NULL;
el_free((ptr_t) el->el_map.key); el_free(el->el_map.key);
el->el_map.key = NULL; el->el_map.key = NULL;
el->el_map.emacs = NULL; el->el_map.emacs = NULL;
el->el_map.vic = NULL; el->el_map.vic = NULL;
el->el_map.vii = NULL; el->el_map.vii = NULL;
el_free((ptr_t) el->el_map.help); el_free(el->el_map.help);
el->el_map.help = NULL; el->el_map.help = NULL;
el_free((ptr_t) el->el_map.func); el_free(el->el_map.func);
el->el_map.func = NULL; el->el_map.func = NULL;
} }
/* map_init_nls(): /* map_init_nls():
* Find all the printable keys and bind them to self insert * Find all the printable keys and bind them to self insert
*/ */
private void static void
map_init_nls(EditLine *el) map_init_nls(EditLine *el)
{ {
int i; int i;
el_action_t *map = el->el_map.key; el_action_t *map = el->el_map.key;
for (i = 0200; i <= 0377; i++) for (i = 0200; i <= 0377; i++)
if (isprint(i)) if (iswprint(i))
map[i] = ED_INSERT; map[i] = ED_INSERT;
} }
/* map_init_meta(): /* map_init_meta():
* Bind all the meta keys to the appropriate ESC-<key> sequence * Bind all the meta keys to the appropriate ESC-<key> sequence
*/ */
private void static void
map_init_meta(EditLine *el) map_init_meta(EditLine *el)
{ {
char buf[3]; wchar_t buf[3];
int i; int i;
el_action_t *map = el->el_map.key; el_action_t *map = el->el_map.key;
el_action_t *alt = el->el_map.alt; el_action_t *alt = el->el_map.alt;
for (i = 0; i <= 0377 && map[i] != EM_META_NEXT; i++) for (i = 0; i <= 0377 && map[i] != EM_META_NEXT; i++)
continue; continue;
if (i > 0377) { if (i > 0377) {
for (i = 0; i <= 0377 && alt[i] != EM_META_NEXT; i++) for (i = 0; i <= 0377 && alt[i] != EM_META_NEXT; i++)
continue; continue;
if (i > 0377) { if (i > 0377) {
i = 033; i = 033;
if (el->el_map.type == MAP_VI) if (el->el_map.type == MAP_VI)
map = alt; map = alt;
} else } else
map = alt; map = alt;
} }
buf[0] = (char) i; buf[0] = (wchar_t)i;
buf[2] = 0; buf[2] = 0;
for (i = 0200; i <= 0377; i++) for (i = 0200; i <= 0377; i++)
switch (map[i]) { switch (map[i]) {
case ED_INSERT: case ED_INSERT:
case ED_UNASSIGNED: case ED_UNASSIGNED:
case ED_SEQUENCE_LEAD_IN: case ED_SEQUENCE_LEAD_IN:
break; break;
default: default:
buf[1] = i & 0177; buf[1] = i & 0177;
key_add(el, buf, key_map_cmd(el, (int) map[i]), XK_CMD); keymacro_add(el, buf, keymacro_map_cmd(el, (int) map[i]), XK_CMD);
break; break;
} }
map[(int) buf[0]] = ED_SEQUENCE_LEAD_IN; map[(int) buf[0]] = ED_SEQUENCE_LEAD_IN;
} }
/* map_init_vi(): /* map_init_vi():
* Initialize the vi bindings * Initialize the vi bindings
*/ */
protected void libedit_private void
map_init_vi(EditLine *el) map_init_vi(EditLine *el)
{ {
int i; int i;
el_action_t *key = el->el_map.key; el_action_t *key = el->el_map.key;
el_action_t *alt = el->el_map.alt; el_action_t *alt = el->el_map.alt;
const el_action_t *vii = el->el_map.vii; const el_action_t *vii = el->el_map.vii;
const el_action_t *vic = el->el_map.vic; const el_action_t *vic = el->el_map.vic;
el->el_map.type = MAP_VI; el->el_map.type = MAP_VI;
el->el_map.current = el->el_map.key; el->el_map.current = el->el_map.key;
key_reset(el); keymacro_reset(el);
for (i = 0; i < N_KEYS; i++) { for (i = 0; i < N_KEYS; i++) {
key[i] = vii[i]; key[i] = vii[i];
alt[i] = vic[i]; alt[i] = vic[i];
} }
map_init_meta(el); map_init_meta(el);
map_init_nls(el); map_init_nls(el);
tty_bind_char(el, 1); tty_bind_char(el, 1);
term_bind_arrow(el); terminal_bind_arrow(el);
} }
/* map_init_emacs(): /* map_init_emacs():
* Initialize the emacs bindings * Initialize the emacs bindings
*/ */
protected void libedit_private void
map_init_emacs(EditLine *el) map_init_emacs(EditLine *el)
{ {
int i; int i;
char buf[3]; wchar_t buf[3];
el_action_t *key = el->el_map.key; el_action_t *key = el->el_map.key;
el_action_t *alt = el->el_map.alt; el_action_t *alt = el->el_map.alt;
const el_action_t *emacs = el->el_map.emacs; const el_action_t *emacs = el->el_map.emacs;
el->el_map.type = MAP_EMACS; el->el_map.type = MAP_EMACS;
el->el_map.current = el->el_map.key; el->el_map.current = el->el_map.key;
key_reset(el); keymacro_reset(el);
for (i = 0; i < N_KEYS; i++) { for (i = 0; i < N_KEYS; i++) {
key[i] = emacs[i]; key[i] = emacs[i];
alt[i] = ED_UNASSIGNED; alt[i] = ED_UNASSIGNED;
} }
map_init_meta(el); map_init_meta(el);
map_init_nls(el); map_init_nls(el);
buf[0] = CONTROL('X'); buf[0] = CONTROL('X');
buf[1] = CONTROL('X'); buf[1] = CONTROL('X');
buf[2] = 0; buf[2] = 0;
key_add(el, buf, key_map_cmd(el, EM_EXCHANGE_MARK), XK_CMD); keymacro_add(el, buf, keymacro_map_cmd(el, EM_EXCHANGE_MARK), XK_CMD);
tty_bind_char(el, 1); tty_bind_char(el, 1);
term_bind_arrow(el); terminal_bind_arrow(el);
} }
/* map_set_editor(): /* map_set_editor():
* Set the editor * Set the editor
*/ */
protected int libedit_private int
map_set_editor(EditLine *el, char *editor) map_set_editor(EditLine *el, wchar_t *editor)
{ {
if (strcmp(editor, "emacs") == 0) { if (wcscmp(editor, L"emacs") == 0) {
map_init_emacs(el); map_init_emacs(el);
return (0); return 0;
} }
if (strcmp(editor, "vi") == 0) { if (wcscmp(editor, L"vi") == 0) {
map_init_vi(el); map_init_vi(el);
return (0); return 0;
} }
return (-1); return -1;
} }
/* map_get_editor(): /* map_get_editor():
* Retrieve the editor * Retrieve the editor
*/ */
protected int libedit_private int
map_get_editor(EditLine *el, const char **editor) map_get_editor(EditLine *el, const wchar_t **editor)
{ {
if (editor == NULL) if (editor == NULL)
return (-1); return -1;
switch (el->el_map.type) { switch (el->el_map.type) {
case MAP_EMACS: case MAP_EMACS:
*editor = "emacs"; *editor = L"emacs";
return (0); return 0;
case MAP_VI: case MAP_VI:
*editor = "vi"; *editor = L"vi";
return (0); return 0;
} }
return (-1); return -1;
} }
/* map_print_key(): /* map_print_key():
* Print the function description for 1 key * Print the function description for 1 key
*/ */
private void static void
map_print_key(EditLine *el, el_action_t *map, const char *in) map_print_key(EditLine *el, el_action_t *map, const wchar_t *in)
{ {
char outbuf[EL_BUFSIZ]; char outbuf[EL_BUFSIZ];
el_bindings_t *bp; el_bindings_t *bp, *ep;
if (in[0] == '\0' || in[1] == '\0') { if (in[0] == '\0' || in[1] == '\0') {
(void) key__decode_str(in, outbuf, ""); (void) keymacro__decode_str(in, outbuf, sizeof(outbuf), "");
for (bp = el->el_map.help; bp->name != NULL; bp++) ep = &el->el_map.help[el->el_map.nfunc];
for (bp = el->el_map.help; bp < ep; bp++)
if (bp->func == map[(unsigned char) *in]) { if (bp->func == map[(unsigned char) *in]) {
(void) fprintf(el->el_outfile, (void) fprintf(el->el_outfile,
"%s\t->\t%s\n", outbuf, bp->name); "%s\t->\t%ls\n", outbuf, bp->name);
return; return;
} }
} else } else
key_print(el, in); keymacro_print(el, in);
} }
/* map_print_some_keys(): /* map_print_some_keys():
* Print keys from first to last * Print keys from first to last
*/ */
private void static void
map_print_some_keys(EditLine *el, el_action_t *map, int first, int last) map_print_some_keys(EditLine *el, el_action_t *map, wint_t first, wint_t last)
{ {
el_bindings_t *bp; el_bindings_t *bp, *ep;
char firstbuf[2], lastbuf[2]; wchar_t firstbuf[2], lastbuf[2];
char unparsbuf[EL_BUFSIZ], extrabuf[EL_BUFSIZ]; char unparsbuf[EL_BUFSIZ], extrabuf[EL_BUFSIZ];
firstbuf[0] = first; firstbuf[0] = first;
firstbuf[1] = 0; firstbuf[1] = 0;
lastbuf[0] = last; lastbuf[0] = last;
lastbuf[1] = 0; lastbuf[1] = 0;
if (map[first] == ED_UNASSIGNED) { if (map[first] == ED_UNASSIGNED) {
if (first == last) if (first == last) {
(void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile, (void) fprintf(el->el_outfile,
"%-15s-> is undefined\n", "%-15s-> is undefined\n", unparsbuf);
key__decode_str(firstbuf, unparsbuf, STRQQ)); }
return; return;
} }
for (bp = el->el_map.help; bp->name != NULL; bp++) { ep = &el->el_map.help[el->el_map.nfunc];
for (bp = el->el_map.help; bp < ep; bp++) {
if (bp->func == map[first]) { if (bp->func == map[first]) {
if (first == last) { if (first == last) {
(void) fprintf(el->el_outfile, "%-15s-> %s\n", (void) keymacro__decode_str(firstbuf, unparsbuf,
key__decode_str(firstbuf, unparsbuf, STRQQ), sizeof(unparsbuf), STRQQ);
bp->name); (void) fprintf(el->el_outfile, "%-15s-> %ls\n",
unparsbuf, bp->name);
} else { } else {
(void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ);
(void) keymacro__decode_str(lastbuf, extrabuf,
sizeof(extrabuf), STRQQ);
(void) fprintf(el->el_outfile, (void) fprintf(el->el_outfile,
"%-4s to %-7s-> %s\n", "%-4s to %-7s-> %ls\n",
key__decode_str(firstbuf, unparsbuf, STRQQ), unparsbuf, extrabuf, bp->name);
key__decode_str(lastbuf, extrabuf, STRQQ),
bp->name);
} }
return; return;
} }
} }
#ifdef MAP_DEBUG #ifdef MAP_DEBUG
if (map == el->el_map.key) { if (map == el->el_map.key) {
(void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile, (void) fprintf(el->el_outfile,
"BUG!!! %s isn't bound to anything.\n", "BUG!!! %s isn't bound to anything.\n", unparsbuf);
key__decode_str(firstbuf, unparsbuf, STRQQ));
(void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n", (void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n",
first, el->el_map.key[first]); first, el->el_map.key[first]);
} else { } else {
(void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile, (void) fprintf(el->el_outfile,
"BUG!!! %s isn't bound to anything.\n", "BUG!!! %s isn't bound to anything.\n", unparsbuf);
key__decode_str(firstbuf, unparsbuf, STRQQ));
(void) fprintf(el->el_outfile, "el->el_map.alt[%d] == %d\n", (void) fprintf(el->el_outfile, "el->el_map.alt[%d] == %d\n",
first, el->el_map.alt[first]); first, el->el_map.alt[first]);
} }
#endif #endif
EL_ABORT((el->el_errfile, "Error printing keys\n")); EL_ABORT((el->el_errfile, "Error printing keys\n"));
} }
/* map_print_all_keys(): /* map_print_all_keys():
* Print the function description for all keys. * Print the function description for all keys.
*/ */
private void static void
map_print_all_keys(EditLine *el) map_print_all_keys(EditLine *el)
{ {
int prev, i; int prev, i;
(void) fprintf(el->el_outfile, "Standard key bindings\n"); (void) fprintf(el->el_outfile, "Standard key bindings\n");
prev = 0; prev = 0;
for (i = 0; i < N_KEYS; i++) { for (i = 0; i < N_KEYS; i++) {
if (el->el_map.key[prev] == el->el_map.key[i]) if (el->el_map.key[prev] == el->el_map.key[i])
continue; continue;
map_print_some_keys(el, el->el_map.key, prev, i - 1); map_print_some_keys(el, el->el_map.key, prev, i - 1);
skipping to change at line 1210 skipping to change at line 1237
prev = 0; prev = 0;
for (i = 0; i < N_KEYS; i++) { for (i = 0; i < N_KEYS; i++) {
if (el->el_map.alt[prev] == el->el_map.alt[i]) if (el->el_map.alt[prev] == el->el_map.alt[i])
continue; continue;
map_print_some_keys(el, el->el_map.alt, prev, i - 1); map_print_some_keys(el, el->el_map.alt, prev, i - 1);
prev = i; prev = i;
} }
map_print_some_keys(el, el->el_map.alt, prev, i - 1); map_print_some_keys(el, el->el_map.alt, prev, i - 1);
(void) fprintf(el->el_outfile, "Multi-character bindings\n"); (void) fprintf(el->el_outfile, "Multi-character bindings\n");
key_print(el, ""); keymacro_print(el, L"");
(void) fprintf(el->el_outfile, "Arrow key bindings\n"); (void) fprintf(el->el_outfile, "Arrow key bindings\n");
term_print_arrow(el, ""); terminal_print_arrow(el, L"");
} }
/* map_bind(): /* map_bind():
* Add/remove/change bindings * Add/remove/change bindings
*/ */
protected int libedit_private int
map_bind(EditLine *el, int argc, const char **argv) map_bind(EditLine *el, int argc, const wchar_t **argv)
{ {
el_action_t *map; el_action_t *map;
int ntype, rem; int ntype, rem;
const char *p; const wchar_t *p;
char inbuf[EL_BUFSIZ]; wchar_t inbuf[EL_BUFSIZ];
char outbuf[EL_BUFSIZ]; wchar_t outbuf[EL_BUFSIZ];
const char *in = NULL; const wchar_t *in = NULL;
char *out = NULL; wchar_t *out;
el_bindings_t *bp; el_bindings_t *bp, *ep;
int cmd; int cmd;
int key; int key;
if (argv == NULL) if (argv == NULL)
return (-1); return -1;
map = el->el_map.key; map = el->el_map.key;
ntype = XK_CMD; ntype = XK_CMD;
key = rem = 0; key = rem = 0;
for (argc = 1; (p = argv[argc]) != NULL; argc++) for (argc = 1; (p = argv[argc]) != NULL; argc++)
if (p[0] == '-') if (p[0] == '-')
switch (p[1]) { switch (p[1]) {
case 'a': case 'a':
map = el->el_map.alt; map = el->el_map.alt;
break; break;
case 's': case 's':
ntype = XK_STR; ntype = XK_STR;
break; break;
#ifdef notyet
case 'c':
ntype = XK_EXE;
break;
#endif
case 'k': case 'k':
key = 1; key = 1;
break; break;
case 'r': case 'r':
rem = 1; rem = 1;
break; break;
case 'v': case 'v':
map_init_vi(el); map_init_vi(el);
return (0); return 0;
case 'e': case 'e':
map_init_emacs(el); map_init_emacs(el);
return (0); return 0;
case 'l': case 'l':
for (bp = el->el_map.help; bp->name != NULL; ep = &el->el_map.help[el->el_map.nfunc];
bp++) for (bp = el->el_map.help; bp < ep; bp++)
(void) fprintf(el->el_outfile, (void) fprintf(el->el_outfile,
"%s\n\t%s\n", "%ls\n\t%ls\n",
bp->name, bp->description); bp->name, bp->description);
return (0); return 0;
default: default:
(void) fprintf(el->el_errfile, (void) fprintf(el->el_errfile,
"%s: Invalid switch `%c'.\n", "%ls: Invalid switch `%lc'.\n",
argv[0], p[1]); argv[0], (wint_t)p[1]);
} }
else else
break; break;
if (argv[argc] == NULL) { if (argv[argc] == NULL) {
map_print_all_keys(el); map_print_all_keys(el);
return (0); return 0;
} }
if (key) if (key)
in = argv[argc++]; in = argv[argc++];
else if ((in = parse__string(inbuf, argv[argc++])) == NULL) { else if ((in = parse__string(inbuf, argv[argc++])) == NULL) {
(void) fprintf(el->el_errfile, (void) fprintf(el->el_errfile,
"%s: Invalid \\ or ^ in instring.\n", "%ls: Invalid \\ or ^ in instring.\n",
argv[0]); argv[0]);
return (-1); return -1;
} }
if (rem) { if (rem) {
if (key) { if (key) {
(void) term_clear_arrow(el, in); (void) terminal_clear_arrow(el, in);
return (-1); return -1;
} }
if (in[1]) if (in[1])
(void) key_delete(el, in); (void) keymacro_delete(el, in);
else if (map[(unsigned char) *in] == ED_SEQUENCE_LEAD_IN) else if (map[(unsigned char) *in] == ED_SEQUENCE_LEAD_IN)
(void) key_delete(el, in); (void) keymacro_delete(el, in);
else else
map[(unsigned char) *in] = ED_UNASSIGNED; map[(unsigned char) *in] = ED_UNASSIGNED;
return (0); return 0;
} }
if (argv[argc] == NULL) { if (argv[argc] == NULL) {
if (key) if (key)
term_print_arrow(el, in); terminal_print_arrow(el, in);
else else
map_print_key(el, map, in); map_print_key(el, map, in);
return (0); return 0;
} }
#ifdef notyet #ifdef notyet
if (argv[argc + 1] != NULL) { if (argv[argc + 1] != NULL) {
bindkey_usage(); bindkeymacro_usage();
return (-1); return -1;
} }
#endif #endif
switch (ntype) { switch (ntype) {
case XK_STR: case XK_STR:
case XK_EXE:
if ((out = parse__string(outbuf, argv[argc])) == NULL) { if ((out = parse__string(outbuf, argv[argc])) == NULL) {
(void) fprintf(el->el_errfile, (void) fprintf(el->el_errfile,
"%s: Invalid \\ or ^ in outstring.\n", argv[0]); "%ls: Invalid \\ or ^ in outstring.\n", argv[0]);
return (-1); return -1;
} }
if (key) if (key)
term_set_arrow(el, in, key_map_str(el, out), ntype); terminal_set_arrow(el, in, keymacro_map_str(el, out), nty pe);
else else
key_add(el, in, key_map_str(el, out), ntype); keymacro_add(el, in, keymacro_map_str(el, out), ntype);
map[(unsigned char) *in] = ED_SEQUENCE_LEAD_IN; map[(unsigned char) *in] = ED_SEQUENCE_LEAD_IN;
break; break;
case XK_CMD: case XK_CMD:
if ((cmd = parse_cmd(el, argv[argc])) == -1) { if ((cmd = parse_cmd(el, argv[argc])) == -1) {
(void) fprintf(el->el_errfile, (void) fprintf(el->el_errfile,
"%s: Invalid command `%s'.\n", argv[0], argv[argc]); "%ls: Invalid command `%ls'.\n",
return (-1); argv[0], argv[argc]);
return -1;
} }
if (key) if (key)
term_set_arrow(el, in, key_map_str(el, out), ntype); terminal_set_arrow(el, in, keymacro_map_cmd(el, cmd), nty pe);
else { else {
if (in[1]) { if (in[1]) {
key_add(el, in, key_map_cmd(el, cmd), ntype); keymacro_add(el, in, keymacro_map_cmd(el, cmd), n type);
map[(unsigned char) *in] = ED_SEQUENCE_LEAD_IN; map[(unsigned char) *in] = ED_SEQUENCE_LEAD_IN;
} else { } else {
key_clear(el, map, in); keymacro_clear(el, map, in);
map[(unsigned char) *in] = cmd; map[(unsigned char) *in] = (el_action_t)cmd;
} }
} }
break; break;
/* coverity[dead_error_begin] */
default: default:
EL_ABORT((el->el_errfile, "Bad XK_ type\n", ntype)); EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
break; break;
} }
return (0); return 0;
} }
/* map_addfunc(): /* map_addfunc():
* add a user defined function * add a user defined function
*/ */
protected int libedit_private int
map_addfunc(EditLine *el, const char *name, const char *help, el_func_t func) map_addfunc(EditLine *el, const wchar_t *name, const wchar_t *help,
el_func_t func)
{ {
void *p; void *p;
int nf = el->el_map.nfunc + 2; size_t nf = el->el_map.nfunc + 1;
if (name == NULL || help == NULL || func == NULL) if (name == NULL || help == NULL || func == NULL)
return (-1); return -1;
if ((p = el_realloc(el->el_map.func, nf * sizeof(el_func_t))) == NULL) if ((p = el_realloc(el->el_map.func, nf *
return (-1); sizeof(*el->el_map.func))) == NULL)
el->el_map.func = (el_func_t *) p; return -1;
if ((p = el_realloc(el->el_map.help, nf * sizeof(el_bindings_t))) el->el_map.func = p;
if ((p = el_realloc(el->el_map.help, nf * sizeof(*el->el_map.help)))
== NULL) == NULL)
return (-1); return -1;
el->el_map.help = (el_bindings_t *) p; el->el_map.help = p;
nf = el->el_map.nfunc; nf = (size_t)el->el_map.nfunc;
el->el_map.func[nf] = func; el->el_map.func[nf] = func;
el->el_map.help[nf].name = name; el->el_map.help[nf].name = name;
el->el_map.help[nf].func = nf; el->el_map.help[nf].func = (int)nf;
el->el_map.help[nf].description = help; el->el_map.help[nf].description = help;
el->el_map.help[++nf].name = NULL;
el->el_map.nfunc++; el->el_map.nfunc++;
return (0); return 0;
} }
 End of changes. 129 change blocks. 
179 lines changed or deleted 203 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)