Rename key to keymacro to avoid conflicts with term.h. The renaming of term

to terminal was again to avoid conflicts with term.h. term.h is a moving
namespace violation.
This commit is contained in:
christos 2011-07-28 01:56:26 +00:00
parent 2f4b6c0966
commit d47f958456
10 changed files with 216 additions and 223 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.43 2011/07/28 01:05:20 christos Exp $
# $NetBSD: Makefile,v 1.44 2011/07/28 01:56:26 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 6/4/93
USE_SHLIBDIR= yes
@ -10,7 +10,7 @@ LIB= edit
LIBDPLIBS+= terminfo ${.CURDIR}/../libterminfo
OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \
hist.c key.c map.c chartype.c \
hist.c keymacro.c map.c chartype.c \
parse.c prompt.c read.c refresh.c search.c sig.c terminal.c tty.c vi.c
MAN= editline.3 editrc.5

View File

@ -1,4 +1,4 @@
/* $NetBSD: el.c,v 1.65 2011/07/28 01:04:41 christos Exp $ */
/* $NetBSD: el.c,v 1.66 2011/07/28 01:56:27 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
#else
__RCSID("$NetBSD: el.c,v 1.65 2011/07/28 01:04:41 christos Exp $");
__RCSID("$NetBSD: el.c,v 1.66 2011/07/28 01:56:27 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@ -97,7 +97,7 @@ el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr)
el_free(el);
return NULL;
}
(void) key_init(el);
(void) keymacro_init(el);
(void) map_init(el);
if (tty_init(el) == -1)
el->el_flags |= NO_TTY;
@ -125,7 +125,7 @@ el_end(EditLine *el)
el_reset(el);
terminal_end(el);
key_end(el);
keymacro_end(el);
map_end(el);
tty_end(el);
ch_end(el);

View File

@ -1,4 +1,4 @@
/* $NetBSD: el.h,v 1.23 2011/07/28 01:05:20 christos Exp $ */
/* $NetBSD: el.h,v 1.24 2011/07/28 01:56:27 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -100,7 +100,7 @@ typedef struct el_state_t {
#include "tty.h"
#include "prompt.h"
#include "key.h"
#include "keymacro.h"
#include "terminal.h"
#include "refresh.h"
#include "chared.h"
@ -136,7 +136,7 @@ struct editline {
el_prompt_t el_rprompt; /* Prompt stuff */
el_chared_t el_chared; /* Characted editor stuff */
el_map_t el_map; /* Key mapping stuff */
el_key_t el_key; /* Key binding stuff */
el_keymacro_t el_keymacro; /* Key binding stuff */
el_history_t el_history; /* History stuff */
el_search_t el_search; /* Search stuff */
el_signal_t el_signal; /* Signal handling stuff */

View File

@ -1,4 +1,4 @@
/* $NetBSD: key.c,v 1.23 2009/12/30 22:37:40 christos Exp $ */
/* $NetBSD: keymacro.c,v 1.1 2011/07/28 01:56:27 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: key.c,v 1.23 2009/12/30 22:37:40 christos Exp $");
__RCSID("$NetBSD: keymacro.c,v 1.1 2011/07/28 01:56:27 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@ -47,14 +47,14 @@ __RCSID("$NetBSD: key.c,v 1.23 2009/12/30 22:37:40 christos Exp $");
*
* An extended-key (key) is a sequence of keystrokes introduced
* with a sequence introducer and consisting of an arbitrary
* number of characters. This module maintains a map (the el->el_key.map)
* number of characters. This module maintains a map (the el->el_keymacro.map)
* to convert these extended-key sequences into input strs
* (XK_STR), editor functions (XK_CMD), or unix commands (XK_EXE).
*
* Warning:
* If key is a substr of some other keys, then the longer
* keys are lost!! That is, if the keys "abcd" and "abcef"
* are in el->el_key.map, adding the key "abc" will cause the first two
* are in el->el_keymacro.map, adding the key "abc" will cause the first two
* definitions to be lost.
*
* Restrictions:
@ -68,102 +68,102 @@ __RCSID("$NetBSD: key.c,v 1.23 2009/12/30 22:37:40 christos Exp $");
#include "el.h"
/*
* The Nodes of the el->el_key.map. The el->el_key.map is a linked list
* The Nodes of the el->el_keymacro.map. The el->el_keymacro.map is a linked list
* of these node elements
*/
struct key_node_t {
struct keymacro_node_t {
Char ch; /* single character of key */
int type; /* node type */
key_value_t val; /* command code or pointer to str, */
keymacro_value_t val; /* command code or pointer to str, */
/* if this is a leaf */
struct key_node_t *next; /* ptr to next char of this key */
struct key_node_t *sibling; /* ptr to another key with same prefix*/
struct keymacro_node_t *next; /* ptr to next char of this key */
struct keymacro_node_t *sibling; /* ptr to another key with same prefix*/
};
private int node_trav(EditLine *, key_node_t *, Char *,
key_value_t *);
private int node__try(EditLine *, key_node_t *, const Char *,
key_value_t *, int);
private key_node_t *node__get(Int);
private void node__free(key_node_t *);
private void node__put(EditLine *, key_node_t *);
private int node__delete(EditLine *, key_node_t **, const Char *);
private int node_lookup(EditLine *, const Char *, key_node_t *,
private int node_trav(EditLine *, keymacro_node_t *, Char *,
keymacro_value_t *);
private int node__try(EditLine *, keymacro_node_t *, const Char *,
keymacro_value_t *, int);
private keymacro_node_t *node__get(Int);
private void node__free(keymacro_node_t *);
private void node__put(EditLine *, keymacro_node_t *);
private int node__delete(EditLine *, keymacro_node_t **, const Char *);
private int node_lookup(EditLine *, const Char *, keymacro_node_t *,
size_t);
private int node_enum(EditLine *, key_node_t *, size_t);
private int node_enum(EditLine *, keymacro_node_t *, size_t);
#define KEY_BUFSIZ EL_BUFSIZ
/* key_init():
/* keymacro_init():
* Initialize the key maps
*/
protected int
key_init(EditLine *el)
keymacro_init(EditLine *el)
{
el->el_key.buf = el_malloc(KEY_BUFSIZ * sizeof(*el->el_key.buf));
if (el->el_key.buf == NULL)
el->el_keymacro.buf = el_malloc(KEY_BUFSIZ * sizeof(*el->el_keymacro.buf));
if (el->el_keymacro.buf == NULL)
return (-1);
el->el_key.map = NULL;
key_reset(el);
el->el_keymacro.map = NULL;
keymacro_reset(el);
return (0);
}
/* key_end():
/* keymacro_end():
* Free the key maps
*/
protected void
key_end(EditLine *el)
keymacro_end(EditLine *el)
{
el_free((ptr_t) el->el_key.buf);
el->el_key.buf = NULL;
node__free(el->el_key.map);
el_free((ptr_t) el->el_keymacro.buf);
el->el_keymacro.buf = NULL;
node__free(el->el_keymacro.map);
}
/* key_map_cmd():
/* keymacro_map_cmd():
* Associate cmd with a key value
*/
protected key_value_t *
key_map_cmd(EditLine *el, int cmd)
protected keymacro_value_t *
keymacro_map_cmd(EditLine *el, int cmd)
{
el->el_key.val.cmd = (el_action_t) cmd;
return (&el->el_key.val);
el->el_keymacro.val.cmd = (el_action_t) cmd;
return (&el->el_keymacro.val);
}
/* key_map_str():
/* keymacro_map_str():
* Associate str with a key value
*/
protected key_value_t *
key_map_str(EditLine *el, Char *str)
protected keymacro_value_t *
keymacro_map_str(EditLine *el, Char *str)
{
el->el_key.val.str = str;
return (&el->el_key.val);
el->el_keymacro.val.str = str;
return (&el->el_keymacro.val);
}
/* key_reset():
* Takes all nodes on el->el_key.map and puts them on free list. Then
* initializes el->el_key.map with arrow keys
/* keymacro_reset():
* Takes all nodes on el->el_keymacro.map and puts them on free list. Then
* initializes el->el_keymacro.map with arrow keys
* [Always bind the ansi arrow keys?]
*/
protected void
key_reset(EditLine *el)
keymacro_reset(EditLine *el)
{
node__put(el, el->el_key.map);
el->el_key.map = NULL;
node__put(el, el->el_keymacro.map);
el->el_keymacro.map = NULL;
return;
}
/* key_get():
* Calls the recursive function with entry point el->el_key.map
/* keymacro_get():
* Calls the recursive function with entry point el->el_keymacro.map
* Looks up *ch in map and then reads characters until a
* complete match is found or a mismatch occurs. Returns the
* type of the match found (XK_STR, XK_CMD, or XK_EXE).
@ -171,49 +171,49 @@ key_reset(EditLine *el)
* The last character read is returned in *ch.
*/
protected int
key_get(EditLine *el, Char *ch, key_value_t *val)
keymacro_get(EditLine *el, Char *ch, keymacro_value_t *val)
{
return (node_trav(el, el->el_key.map, ch, val));
return (node_trav(el, el->el_keymacro.map, ch, val));
}
/* key_add():
* Adds key to the el->el_key.map and associates the value in val with it.
* If key is already is in el->el_key.map, the new code is applied to the
/* keymacro_add():
* Adds key to the el->el_keymacro.map and associates the value in val with it.
* If key is already is in el->el_keymacro.map, the new code is applied to the
* existing key. Ntype specifies if code is a command, an
* out str or a unix command.
*/
protected void
key_add(EditLine *el, const Char *key, key_value_t *val, int ntype)
keymacro_add(EditLine *el, const Char *key, keymacro_value_t *val, int ntype)
{
if (key[0] == '\0') {
(void) fprintf(el->el_errfile,
"key_add: Null extended-key not allowed.\n");
"keymacro_add: Null extended-key not allowed.\n");
return;
}
if (ntype == XK_CMD && val->cmd == ED_SEQUENCE_LEAD_IN) {
(void) fprintf(el->el_errfile,
"key_add: sequence-lead-in command not allowed\n");
"keymacro_add: sequence-lead-in command not allowed\n");
return;
}
if (el->el_key.map == NULL)
if (el->el_keymacro.map == NULL)
/* tree is initially empty. Set up new node to match key[0] */
el->el_key.map = node__get(key[0]);
el->el_keymacro.map = node__get(key[0]);
/* it is properly initialized */
/* Now recurse through el->el_key.map */
(void) node__try(el, el->el_key.map, key, val, ntype);
/* Now recurse through el->el_keymacro.map */
(void) node__try(el, el->el_keymacro.map, key, val, ntype);
return;
}
/* key_clear():
/* keymacro_clear():
*
*/
protected void
key_clear(EditLine *el, el_action_t *map, const Char *in)
keymacro_clear(EditLine *el, el_action_t *map, const Char *in)
{
#ifdef WIDECHAR
if (*in > N_KEYS) /* can't be in the map */
@ -224,45 +224,45 @@ key_clear(EditLine *el, el_action_t *map, const Char *in)
el->el_map.alt[(unsigned char)*in] != ED_SEQUENCE_LEAD_IN) ||
(map == el->el_map.alt &&
el->el_map.key[(unsigned char)*in] != ED_SEQUENCE_LEAD_IN)))
(void) key_delete(el, in);
(void) keymacro_delete(el, in);
}
/* key_delete():
/* keymacro_delete():
* Delete the key and all longer keys staring with key, if
* they exists.
*/
protected int
key_delete(EditLine *el, const Char *key)
keymacro_delete(EditLine *el, const Char *key)
{
if (key[0] == '\0') {
(void) fprintf(el->el_errfile,
"key_delete: Null extended-key not allowed.\n");
"keymacro_delete: Null extended-key not allowed.\n");
return (-1);
}
if (el->el_key.map == NULL)
if (el->el_keymacro.map == NULL)
return (0);
(void) node__delete(el, &el->el_key.map, key);
(void) node__delete(el, &el->el_keymacro.map, key);
return (0);
}
/* key_print():
/* keymacro_print():
* Print the binding associated with key key.
* Print entire el->el_key.map if null
* Print entire el->el_keymacro.map if null
*/
protected void
key_print(EditLine *el, const Char *key)
keymacro_print(EditLine *el, const Char *key)
{
/* do nothing if el->el_key.map is empty and null key specified */
if (el->el_key.map == NULL && *key == 0)
/* do nothing if el->el_keymacro.map is empty and null key specified */
if (el->el_keymacro.map == NULL && *key == 0)
return;
el->el_key.buf[0] = '"';
if (node_lookup(el, key, el->el_key.map, 1) <= -1)
el->el_keymacro.buf[0] = '"';
if (node_lookup(el, key, el->el_keymacro.map, 1) <= -1)
/* key is not bound */
(void) fprintf(el->el_errfile, "Unbound extended key \"" FSTR "\"\n",
key);
@ -275,7 +275,7 @@ key_print(EditLine *el, const Char *key)
* found. May read in more characters.
*/
private int
node_trav(EditLine *el, key_node_t *ptr, Char *ch, key_value_t *val)
node_trav(EditLine *el, keymacro_node_t *ptr, Char *ch, keymacro_value_t *val)
{
if (ptr->ch == *ch) {
@ -312,11 +312,11 @@ node_trav(EditLine *el, key_node_t *ptr, Char *ch, key_value_t *val)
* Find a node that matches *str or allocate a new one
*/
private int
node__try(EditLine *el, key_node_t *ptr, const Char *str, key_value_t *val, int ntype)
node__try(EditLine *el, keymacro_node_t *ptr, const Char *str, keymacro_value_t *val, int ntype)
{
if (ptr->ch != *str) {
key_node_t *xm;
keymacro_node_t *xm;
for (xm = ptr; xm->sibling != NULL; xm = xm->sibling)
if (xm->sibling->ch == *str)
@ -374,15 +374,15 @@ node__try(EditLine *el, key_node_t *ptr, const Char *str, key_value_t *val, int
* Delete node that matches str
*/
private int
node__delete(EditLine *el, key_node_t **inptr, const Char *str)
node__delete(EditLine *el, keymacro_node_t **inptr, const Char *str)
{
key_node_t *ptr;
key_node_t *prev_ptr = NULL;
keymacro_node_t *ptr;
keymacro_node_t *prev_ptr = NULL;
ptr = *inptr;
if (ptr->ch != *str) {
key_node_t *xm;
keymacro_node_t *xm;
for (xm = ptr; xm->sibling != NULL; xm = xm->sibling)
if (xm->sibling->ch == *str)
@ -422,7 +422,7 @@ node__delete(EditLine *el, key_node_t **inptr, const Char *str)
* Puts a tree of nodes onto free list using free(3).
*/
private void
node__put(EditLine *el, key_node_t *ptr)
node__put(EditLine *el, keymacro_node_t *ptr)
{
if (ptr == NULL)
return;
@ -451,14 +451,14 @@ node__put(EditLine *el, key_node_t *ptr)
/* node__get():
* Returns pointer to a key_node_t for ch.
* Returns pointer to a keymacro_node_t for ch.
*/
private key_node_t *
private keymacro_node_t *
node__get(Int ch)
{
key_node_t *ptr;
keymacro_node_t *ptr;
ptr = (key_node_t *) el_malloc((size_t) sizeof(key_node_t));
ptr = (keymacro_node_t *) el_malloc((size_t) sizeof(keymacro_node_t));
if (ptr == NULL)
return NULL;
ptr->ch = ch;
@ -470,7 +470,7 @@ node__get(Int ch)
}
private void
node__free(key_node_t *k)
node__free(keymacro_node_t *k)
{
if (k == NULL)
return;
@ -484,7 +484,7 @@ node__free(key_node_t *k)
* Print if last node
*/
private int
node_lookup(EditLine *el, const Char *str, key_node_t *ptr, size_t cnt)
node_lookup(EditLine *el, const Char *str, keymacro_node_t *ptr, size_t cnt)
{
ssize_t used;
@ -496,10 +496,10 @@ node_lookup(EditLine *el, const Char *str, key_node_t *ptr, size_t cnt)
(void) node_enum(el, ptr, cnt);
return (0);
} else {
/* If match put this char into el->el_key.buf. Recurse */
/* If match put this char into el->el_keymacro.buf. Recurse */
if (ptr->ch == *str) {
/* match found */
used = ct_visual_char(el->el_key.buf + cnt,
used = ct_visual_char(el->el_keymacro.buf + cnt,
KEY_BUFSIZ - cnt, ptr->ch);
if (used == -1)
return (-1); /* ran out of buffer space */
@ -510,9 +510,9 @@ node_lookup(EditLine *el, const Char *str, key_node_t *ptr, size_t cnt)
else {
/* next node is null so key should be complete */
if (str[1] == 0) {
el->el_key.buf[cnt + used ] = '"';
el->el_key.buf[cnt + used + 1] = '\0';
key_kprint(el, el->el_key.buf,
el->el_keymacro.buf[cnt + used ] = '"';
el->el_keymacro.buf[cnt + used + 1] = '\0';
keymacro_kprint(el, el->el_keymacro.buf,
&ptr->val, ptr->type);
return (0);
} else
@ -535,16 +535,16 @@ node_lookup(EditLine *el, const Char *str, key_node_t *ptr, size_t cnt)
* Traverse the node printing the characters it is bound in buffer
*/
private int
node_enum(EditLine *el, key_node_t *ptr, size_t cnt)
node_enum(EditLine *el, keymacro_node_t *ptr, size_t cnt)
{
ssize_t used;
if (cnt >= KEY_BUFSIZ - 5) { /* buffer too small */
el->el_key.buf[++cnt] = '"';
el->el_key.buf[++cnt] = '\0';
el->el_keymacro.buf[++cnt] = '"';
el->el_keymacro.buf[++cnt] = '\0';
(void) fprintf(el->el_errfile,
"Some extended keys too long for internal print buffer");
(void) fprintf(el->el_errfile, " \"" FSTR "...\"\n", el->el_key.buf);
(void) fprintf(el->el_errfile, " \"" FSTR "...\"\n", el->el_keymacro.buf);
return (0);
}
if (ptr == NULL) {
@ -555,12 +555,12 @@ node_enum(EditLine *el, key_node_t *ptr, size_t cnt)
return (-1);
}
/* put this char at end of str */
used = ct_visual_char(el->el_key.buf + cnt, KEY_BUFSIZ - cnt, ptr->ch);
used = ct_visual_char(el->el_keymacro.buf + cnt, KEY_BUFSIZ - cnt, ptr->ch);
if (ptr->next == NULL) {
/* print this key and function */
el->el_key.buf[cnt + used ] = '"';
el->el_key.buf[cnt + used + 1] = '\0';
key_kprint(el, el->el_key.buf, &ptr->val, ptr->type);
el->el_keymacro.buf[cnt + used ] = '"';
el->el_keymacro.buf[cnt + used + 1] = '\0';
keymacro_kprint(el, el->el_keymacro.buf, &ptr->val, ptr->type);
} else
(void) node_enum(el, ptr->next, cnt + used);
@ -571,12 +571,12 @@ node_enum(EditLine *el, key_node_t *ptr, size_t cnt)
}
/* key_kprint():
/* keymacro_kprint():
* Print the specified key and its associated
* function specified by val
*/
protected void
key_kprint(EditLine *el, const Char *key, key_value_t *val, int ntype)
keymacro_kprint(EditLine *el, const Char *key, keymacro_value_t *val, int ntype)
{
el_bindings_t *fp;
char unparsbuf[EL_BUFSIZ];
@ -586,7 +586,7 @@ key_kprint(EditLine *el, const Char *key, key_value_t *val, int ntype)
switch (ntype) {
case XK_STR:
case XK_EXE:
(void) key__decode_str(val->str, unparsbuf,
(void) keymacro__decode_str(val->str, unparsbuf,
sizeof(unparsbuf),
ntype == XK_STR ? "\"\"" : "[]");
(void) fprintf(el->el_outfile, fmt,
@ -623,11 +623,11 @@ key_kprint(EditLine *el, const Char *key, key_value_t *val, int ntype)
*b++ = c; \
else \
b++
/* key__decode_str():
/* keymacro__decode_str():
* Make a printable version of the ey
*/
protected size_t
key__decode_str(const Char *str, char *buf, size_t len, const char *sep)
keymacro__decode_str(const Char *str, char *buf, size_t len, const char *sep)
{
char *b = buf, *eb = b + len;
const Char *p;

View File

@ -1,4 +1,4 @@
/* $NetBSD: key.h,v 1.13 2009/12/30 22:37:40 christos Exp $ */
/* $NetBSD: keymacro.h,v 1.1 2011/07/28 01:56:27 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -37,44 +37,40 @@
/*
* el.key.h: Key macro header
*/
#ifndef _h_el_key
#define _h_el_key
#ifndef _h_el_keymacro
#define _h_el_keymacro
typedef union key_value_t {
typedef union keymacro_value_t {
el_action_t cmd; /* If it is a command the # */
Char *str; /* If it is a string... */
} key_value_t;
} keymacro_value_t;
typedef struct key_node_t key_node_t;
typedef struct keymacro_node_t keymacro_node_t;
typedef struct el_key_t {
typedef struct el_keymacromacro_t {
Char *buf; /* Key print buffer */
key_node_t *map; /* Key map */
key_value_t val; /* Local conversion buffer */
} el_key_t;
keymacro_node_t *map; /* Key map */
keymacro_value_t val; /* Local conversion buffer */
} el_keymacro_t;
#define XK_CMD 0
#define XK_STR 1
#define XK_NOD 2
#define XK_EXE 3
#undef key_end
#undef key_clear
#undef key_print
protected int key_init(EditLine *);
protected void key_end(EditLine *);
protected key_value_t *key_map_cmd(EditLine *, int);
protected key_value_t *key_map_str(EditLine *, Char *);
protected void key_reset(EditLine *);
protected int key_get(EditLine *, Char *, key_value_t *);
protected void key_add(EditLine *, const Char *, key_value_t *, int);
protected void key_clear(EditLine *, el_action_t *, const Char *);
protected int key_delete(EditLine *, const Char *);
protected void key_print(EditLine *, const Char *);
protected void key_kprint(EditLine *, const Char *, key_value_t *,
protected int keymacro_init(EditLine *);
protected void keymacro_end(EditLine *);
protected keymacro_value_t *keymacro_map_cmd(EditLine *, int);
protected keymacro_value_t *keymacro_map_str(EditLine *, Char *);
protected void keymacro_reset(EditLine *);
protected int keymacro_get(EditLine *, Char *, keymacro_value_t *);
protected void keymacro_add(EditLine *, const Char *, keymacro_value_t *, int);
protected void keymacro_clear(EditLine *, el_action_t *, const Char *);
protected int keymacro_delete(EditLine *, const Char *);
protected void keymacro_print(EditLine *, const Char *);
protected void keymacro_kprint(EditLine *, const Char *, keymacro_value_t *,
int);
protected size_t key__decode_str(const Char *, char *, size_t,
protected size_t keymacro__decode_str(const Char *, char *, size_t,
const char *);
#endif /* _h_el_key */
#endif /* _h_el_keymacro */

View File

@ -1,4 +1,4 @@
/* $NetBSD: map.c,v 1.26 2011/07/28 01:05:20 christos Exp $ */
/* $NetBSD: map.c,v 1.27 2011/07/28 01:56:27 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: map.c,v 1.26 2011/07/28 01:05:20 christos Exp $");
__RCSID("$NetBSD: map.c,v 1.27 2011/07/28 01:56:27 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@ -1005,7 +1005,7 @@ map_init_meta(EditLine *el)
break;
default:
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;
}
map[(int) buf[0]] = ED_SEQUENCE_LEAD_IN;
@ -1027,7 +1027,7 @@ map_init_vi(EditLine *el)
el->el_map.type = MAP_VI;
el->el_map.current = el->el_map.key;
key_reset(el);
keymacro_reset(el);
for (i = 0; i < N_KEYS; i++) {
key[i] = vii[i];
@ -1056,7 +1056,7 @@ map_init_emacs(EditLine *el)
el->el_map.type = MAP_EMACS;
el->el_map.current = el->el_map.key;
key_reset(el);
keymacro_reset(el);
for (i = 0; i < N_KEYS; i++) {
key[i] = emacs[i];
@ -1069,7 +1069,7 @@ map_init_emacs(EditLine *el)
buf[0] = CONTROL('X');
buf[1] = CONTROL('X');
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);
terminal_bind_arrow(el);
@ -1126,7 +1126,7 @@ map_print_key(EditLine *el, el_action_t *map, const Char *in)
el_bindings_t *bp, *ep;
if (in[0] == '\0' || in[1] == '\0') {
(void) key__decode_str(in, outbuf, sizeof(outbuf), "");
(void) keymacro__decode_str(in, outbuf, sizeof(outbuf), "");
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]) {
@ -1135,7 +1135,7 @@ map_print_key(EditLine *el, el_action_t *map, const Char *in)
return;
}
} else
key_print(el, in);
keymacro_print(el, in);
}
@ -1155,7 +1155,7 @@ map_print_some_keys(EditLine *el, el_action_t *map, Int first, Int last)
lastbuf[1] = 0;
if (map[first] == ED_UNASSIGNED) {
if (first == last) {
(void) key__decode_str(firstbuf, unparsbuf,
(void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile,
"%-15s-> is undefined\n", unparsbuf);
@ -1166,14 +1166,14 @@ map_print_some_keys(EditLine *el, el_action_t *map, Int first, Int last)
for (bp = el->el_map.help; bp < ep; bp++) {
if (bp->func == map[first]) {
if (first == last) {
(void) key__decode_str(firstbuf, unparsbuf,
(void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile, "%-15s-> " FSTR "\n",
unparsbuf, bp->name);
} else {
(void) key__decode_str(firstbuf, unparsbuf,
(void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ);
(void) key__decode_str(lastbuf, extrabuf,
(void) keymacro__decode_str(lastbuf, extrabuf,
sizeof(extrabuf), STRQQ);
(void) fprintf(el->el_outfile,
"%-4s to %-7s-> " FSTR "\n",
@ -1184,14 +1184,14 @@ map_print_some_keys(EditLine *el, el_action_t *map, Int first, Int last)
}
#ifdef MAP_DEBUG
if (map == el->el_map.key) {
(void) key__decode_str(firstbuf, unparsbuf,
(void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile,
"BUG!!! %s isn't bound to anything.\n", unparsbuf);
(void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n",
first, el->el_map.key[first]);
} else {
(void) key__decode_str(firstbuf, unparsbuf,
(void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile,
"BUG!!! %s isn't bound to anything.\n", unparsbuf);
@ -1232,7 +1232,7 @@ map_print_all_keys(EditLine *el)
map_print_some_keys(el, el->el_map.alt, prev, i - 1);
(void) fprintf(el->el_outfile, "Multi-character bindings\n");
key_print(el, STR(""));
keymacro_print(el, STR(""));
(void) fprintf(el->el_outfile, "Arrow key bindings\n");
terminal_print_arrow(el, STR(""));
}
@ -1325,9 +1325,9 @@ map_bind(EditLine *el, int argc, const Char **argv)
return (-1);
}
if (in[1])
(void) key_delete(el, in);
(void) keymacro_delete(el, in);
else if (map[(unsigned char) *in] == ED_SEQUENCE_LEAD_IN)
(void) key_delete(el, in);
(void) keymacro_delete(el, in);
else
map[(unsigned char) *in] = ED_UNASSIGNED;
return (0);
@ -1341,7 +1341,7 @@ map_bind(EditLine *el, int argc, const Char **argv)
}
#ifdef notyet
if (argv[argc + 1] != NULL) {
bindkey_usage();
bindkeymacro_usage();
return (-1);
}
#endif
@ -1355,9 +1355,9 @@ map_bind(EditLine *el, int argc, const Char **argv)
return (-1);
}
if (key)
terminal_set_arrow(el, in, key_map_str(el, out), ntype);
terminal_set_arrow(el, in, keymacro_map_str(el, out), ntype);
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;
break;
@ -1369,13 +1369,13 @@ map_bind(EditLine *el, int argc, const Char **argv)
return (-1);
}
if (key)
terminal_set_arrow(el, in, key_map_str(el, out), ntype);
terminal_set_arrow(el, in, keymacro_map_str(el, out), ntype);
else {
if (in[1]) {
key_add(el, in, key_map_cmd(el, cmd), ntype);
keymacro_add(el, in, keymacro_map_cmd(el, cmd), ntype);
map[(unsigned char) *in] = ED_SEQUENCE_LEAD_IN;
} else {
key_clear(el, map, in);
keymacro_clear(el, map, in);
map[(unsigned char) *in] = cmd;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: read.c,v 1.62 2011/07/28 00:44:35 christos Exp $ */
/* $NetBSD: read.c,v 1.63 2011/07/28 01:56:27 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: read.c,v 1.62 2011/07/28 00:44:35 christos Exp $");
__RCSID("$NetBSD: read.c,v 1.63 2011/07/28 01:56:27 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@ -268,8 +268,8 @@ read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch)
#endif
cmd = el->el_map.current[(unsigned char) *ch];
if (cmd == ED_SEQUENCE_LEAD_IN) {
key_value_t val;
switch (key_get(el, ch, &val)) {
keymacro_value_t val;
switch (keymacro_get(el, ch, &val)) {
case XK_CMD:
cmd = val.cmd;
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: terminal.c,v 1.1 2011/07/28 01:05:20 christos Exp $ */
/* $NetBSD: terminal.c,v 1.2 2011/07/28 01:56:27 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95";
#else
__RCSID("$NetBSD: terminal.c,v 1.1 2011/07/28 01:05:20 christos Exp $");
__RCSID("$NetBSD: terminal.c,v 1.2 2011/07/28 01:56:27 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@ -65,9 +65,6 @@ __RCSID("$NetBSD: terminal.c,v 1.1 2011/07/28 01:05:20 christos Exp $");
#if defined(HAVE_TERM_H) && !defined(__sun)
#include <term.h>
#endif
#undef key_end
#undef key_clear
#undef key_print
#include <sys/types.h>
#include <sys/ioctl.h>
@ -347,7 +344,7 @@ terminal_init(EditLine *el)
el->el_terminal.t_cap = (char *) el_malloc(TC_BUFSIZE);
if (el->el_terminal.t_cap == NULL)
return (-1);
el->el_terminal.t_fkey = (fkey_t *) el_malloc(A_K_NKEYS * sizeof(fkey_t));
el->el_terminal.t_fkey = (funckey_t *) el_malloc(A_K_NKEYS * sizeof(funckey_t));
if (el->el_terminal.t_fkey == NULL)
return (-1);
el->el_terminal.t_loc = 0;
@ -1074,7 +1071,7 @@ terminal_change_size(EditLine *el, int lins, int cols)
private void
terminal_init_arrow(EditLine *el)
{
fkey_t *arrow = el->el_terminal.t_fkey;
funckey_t *arrow = el->el_terminal.t_fkey;
arrow[A_K_DN].name = STR("down");
arrow[A_K_DN].key = T_kd;
@ -1114,7 +1111,7 @@ terminal_init_arrow(EditLine *el)
private void
terminal_reset_arrow(EditLine *el)
{
fkey_t *arrow = el->el_terminal.t_fkey;
funckey_t *arrow = el->el_terminal.t_fkey;
static const Char strA[] = {033, '[', 'A', '\0'};
static const Char strB[] = {033, '[', 'B', '\0'};
static const Char strC[] = {033, '[', 'C', '\0'};
@ -1128,32 +1125,32 @@ terminal_reset_arrow(EditLine *el)
static const Char stOH[] = {033, 'O', 'H', '\0'};
static const Char stOF[] = {033, 'O', 'F', '\0'};
key_add(el, strA, &arrow[A_K_UP].fun, arrow[A_K_UP].type);
key_add(el, strB, &arrow[A_K_DN].fun, arrow[A_K_DN].type);
key_add(el, strC, &arrow[A_K_RT].fun, arrow[A_K_RT].type);
key_add(el, strD, &arrow[A_K_LT].fun, arrow[A_K_LT].type);
key_add(el, strH, &arrow[A_K_HO].fun, arrow[A_K_HO].type);
key_add(el, strF, &arrow[A_K_EN].fun, arrow[A_K_EN].type);
key_add(el, stOA, &arrow[A_K_UP].fun, arrow[A_K_UP].type);
key_add(el, stOB, &arrow[A_K_DN].fun, arrow[A_K_DN].type);
key_add(el, stOC, &arrow[A_K_RT].fun, arrow[A_K_RT].type);
key_add(el, stOD, &arrow[A_K_LT].fun, arrow[A_K_LT].type);
key_add(el, stOH, &arrow[A_K_HO].fun, arrow[A_K_HO].type);
key_add(el, stOF, &arrow[A_K_EN].fun, arrow[A_K_EN].type);
keymacro_add(el, strA, &arrow[A_K_UP].fun, arrow[A_K_UP].type);
keymacro_add(el, strB, &arrow[A_K_DN].fun, arrow[A_K_DN].type);
keymacro_add(el, strC, &arrow[A_K_RT].fun, arrow[A_K_RT].type);
keymacro_add(el, strD, &arrow[A_K_LT].fun, arrow[A_K_LT].type);
keymacro_add(el, strH, &arrow[A_K_HO].fun, arrow[A_K_HO].type);
keymacro_add(el, strF, &arrow[A_K_EN].fun, arrow[A_K_EN].type);
keymacro_add(el, stOA, &arrow[A_K_UP].fun, arrow[A_K_UP].type);
keymacro_add(el, stOB, &arrow[A_K_DN].fun, arrow[A_K_DN].type);
keymacro_add(el, stOC, &arrow[A_K_RT].fun, arrow[A_K_RT].type);
keymacro_add(el, stOD, &arrow[A_K_LT].fun, arrow[A_K_LT].type);
keymacro_add(el, stOH, &arrow[A_K_HO].fun, arrow[A_K_HO].type);
keymacro_add(el, stOF, &arrow[A_K_EN].fun, arrow[A_K_EN].type);
if (el->el_map.type == MAP_VI) {
key_add(el, &strA[1], &arrow[A_K_UP].fun, arrow[A_K_UP].type);
key_add(el, &strB[1], &arrow[A_K_DN].fun, arrow[A_K_DN].type);
key_add(el, &strC[1], &arrow[A_K_RT].fun, arrow[A_K_RT].type);
key_add(el, &strD[1], &arrow[A_K_LT].fun, arrow[A_K_LT].type);
key_add(el, &strH[1], &arrow[A_K_HO].fun, arrow[A_K_HO].type);
key_add(el, &strF[1], &arrow[A_K_EN].fun, arrow[A_K_EN].type);
key_add(el, &stOA[1], &arrow[A_K_UP].fun, arrow[A_K_UP].type);
key_add(el, &stOB[1], &arrow[A_K_DN].fun, arrow[A_K_DN].type);
key_add(el, &stOC[1], &arrow[A_K_RT].fun, arrow[A_K_RT].type);
key_add(el, &stOD[1], &arrow[A_K_LT].fun, arrow[A_K_LT].type);
key_add(el, &stOH[1], &arrow[A_K_HO].fun, arrow[A_K_HO].type);
key_add(el, &stOF[1], &arrow[A_K_EN].fun, arrow[A_K_EN].type);
keymacro_add(el, &strA[1], &arrow[A_K_UP].fun, arrow[A_K_UP].type);
keymacro_add(el, &strB[1], &arrow[A_K_DN].fun, arrow[A_K_DN].type);
keymacro_add(el, &strC[1], &arrow[A_K_RT].fun, arrow[A_K_RT].type);
keymacro_add(el, &strD[1], &arrow[A_K_LT].fun, arrow[A_K_LT].type);
keymacro_add(el, &strH[1], &arrow[A_K_HO].fun, arrow[A_K_HO].type);
keymacro_add(el, &strF[1], &arrow[A_K_EN].fun, arrow[A_K_EN].type);
keymacro_add(el, &stOA[1], &arrow[A_K_UP].fun, arrow[A_K_UP].type);
keymacro_add(el, &stOB[1], &arrow[A_K_DN].fun, arrow[A_K_DN].type);
keymacro_add(el, &stOC[1], &arrow[A_K_RT].fun, arrow[A_K_RT].type);
keymacro_add(el, &stOD[1], &arrow[A_K_LT].fun, arrow[A_K_LT].type);
keymacro_add(el, &stOH[1], &arrow[A_K_HO].fun, arrow[A_K_HO].type);
keymacro_add(el, &stOF[1], &arrow[A_K_EN].fun, arrow[A_K_EN].type);
}
}
@ -1162,9 +1159,9 @@ terminal_reset_arrow(EditLine *el)
* Set an arrow key binding
*/
protected int
terminal_set_arrow(EditLine *el, const Char *name, key_value_t *fun, int type)
terminal_set_arrow(EditLine *el, const Char *name, keymacro_value_t *fun, int type)
{
fkey_t *arrow = el->el_terminal.t_fkey;
funckey_t *arrow = el->el_terminal.t_fkey;
int i;
for (i = 0; i < A_K_NKEYS; i++)
@ -1183,7 +1180,7 @@ terminal_set_arrow(EditLine *el, const Char *name, key_value_t *fun, int type)
protected int
terminal_clear_arrow(EditLine *el, const Char *name)
{
fkey_t *arrow = el->el_terminal.t_fkey;
funckey_t *arrow = el->el_terminal.t_fkey;
int i;
for (i = 0; i < A_K_NKEYS; i++)
@ -1202,12 +1199,12 @@ protected void
terminal_print_arrow(EditLine *el, const Char *name)
{
int i;
fkey_t *arrow = el->el_terminal.t_fkey;
funckey_t *arrow = el->el_terminal.t_fkey;
for (i = 0; i < A_K_NKEYS; i++)
if (*name == '\0' || Strcmp(name, arrow[i].name) == 0)
if (arrow[i].type != XK_NOD)
key_kprint(el, arrow[i].name, &arrow[i].fun,
keymacro_kprint(el, arrow[i].name, &arrow[i].fun,
arrow[i].type);
}
@ -1222,7 +1219,7 @@ terminal_bind_arrow(EditLine *el)
const el_action_t *dmap;
int i, j;
char *p;
fkey_t *arrow = el->el_terminal.t_fkey;
funckey_t *arrow = el->el_terminal.t_fkey;
/* Check if the components needed are initialized */
if (el->el_terminal.t_buf == NULL || el->el_map.key == NULL)
@ -1258,19 +1255,19 @@ terminal_bind_arrow(EditLine *el)
* unassigned key.
*/
if (arrow[i].type == XK_NOD)
key_clear(el, map, px);
keymacro_clear(el, map, px);
else {
if (p[1] && (dmap[j] == map[j] ||
map[j] == ED_SEQUENCE_LEAD_IN)) {
key_add(el, px, &arrow[i].fun,
keymacro_add(el, px, &arrow[i].fun,
arrow[i].type);
map[j] = ED_SEQUENCE_LEAD_IN;
} else if (map[j] == ED_UNASSIGNED) {
key_clear(el, map, px);
keymacro_clear(el, map, px);
if (arrow[i].type == XK_CMD)
map[j] = arrow[i].fun.cmd;
else
key_add(el, px, &arrow[i].fun,
keymacro_add(el, px, &arrow[i].fun,
arrow[i].type);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: terminal.h,v 1.1 2011/07/28 01:05:20 christos Exp $ */
/* $NetBSD: terminal.h,v 1.2 2011/07/28 01:56:27 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -45,9 +45,9 @@
typedef struct { /* Symbolic function key bindings */
const Char *name; /* name of the key */
int key; /* Index in termcap table */
key_value_t fun; /* Function bound to it */
keymacro_value_t fun; /* Function bound to it */
int type; /* Type of function */
} fkey_t;
} funckey_t;
typedef struct {
const char *t_name; /* the terminal name */
@ -67,7 +67,7 @@ typedef struct {
char **t_str; /* termcap strings */
int *t_val; /* termcap values */
char *t_cap; /* Termcap buffer */
fkey_t *t_fkey; /* Array of keys */
funckey_t *t_fkey; /* Array of keys */
} el_terminal_t;
/*
@ -95,7 +95,7 @@ protected int terminal_init(EditLine *);
protected void terminal_bind_arrow(EditLine *);
protected void terminal_print_arrow(EditLine *, const Char *);
protected int terminal_clear_arrow(EditLine *, const Char *);
protected int terminal_set_arrow(EditLine *, const Char *, key_value_t *, int);
protected int terminal_set_arrow(EditLine *, const Char *, keymacro_value_t *, int);
protected void terminal_end(EditLine *);
protected void terminal_get(EditLine *, const char **);
protected int terminal_set(EditLine *, const char *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: tty.c,v 1.36 2011/07/28 00:45:50 christos Exp $ */
/* $NetBSD: tty.c,v 1.37 2011/07/28 01:56:27 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: tty.c,v 1.36 2011/07/28 00:45:50 christos Exp $");
__RCSID("$NetBSD: tty.c,v 1.37 2011/07/28 01:56:27 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@ -924,15 +924,15 @@ tty_bind_char(EditLine *el, int force)
if (new[0] == old[0] && !force)
continue;
/* Put the old default binding back, and set the new binding */
key_clear(el, map, old);
keymacro_clear(el, map, old);
map[UC(old[0])] = dmap[UC(old[0])];
key_clear(el, map, new);
keymacro_clear(el, map, new);
/* MAP_VI == 1, MAP_EMACS == 0... */
map[UC(new[0])] = tp->bind[el->el_map.type];
if (dalt) {
key_clear(el, alt, old);
keymacro_clear(el, alt, old);
alt[UC(old[0])] = dalt[UC(old[0])];
key_clear(el, alt, new);
keymacro_clear(el, alt, new);
alt[UC(new[0])] = tp->bind[el->el_map.type + 1];
}
}