version 1.58, 2014/12/06 23:20:17 |
version 1.59, 2015/03/17 18:08:52 |
|
|
|
|
#include "macro.h" |
#include "macro.h" |
|
|
#ifdef FKEYS |
|
#include "key.h" |
#include "key.h" |
#ifndef BINDKEY |
#ifndef BINDKEY |
#define BINDKEY /* bindkey is used by FKEYS startup code */ |
#define BINDKEY /* bindkey is used by FKEYS startup code */ |
#endif /* !BINDKEY */ |
#endif /* !BINDKEY */ |
#endif /* FKEYS */ |
|
|
|
static int remap(KEYMAP *, int, PF, KEYMAP *); |
static int remap(KEYMAP *, int, PF, KEYMAP *); |
static KEYMAP *reallocmap(KEYMAP *); |
static KEYMAP *reallocmap(KEYMAP *); |
|
|
return (remap(curmap, c, funct, pref_map)); |
return (remap(curmap, c, funct, pref_map)); |
} |
} |
|
|
#ifdef FKEYS |
|
/* |
/* |
* Wrapper for bindkey() that converts escapes. |
* Wrapper for bindkey() that converts escapes. |
*/ |
*/ |
|
|
key.k_count = i; |
key.k_count = i; |
return (bindkey(&map, func, key.k_chars, key.k_count)); |
return (bindkey(&map, func, key.k_chars, key.k_count)); |
} |
} |
#endif /* FKEYS */ |
|
#endif /* BINDKEY */ |
#endif /* BINDKEY */ |
|
|
/* |
/* |
|
|
} |
} |
|
|
/* |
/* |
* excline - run a line from a load file or eval-expression. If FKEYS is |
* excline - run a line from a load file or eval-expression. |
* defined, duplicate functionality of dobind so function key values don't |
|
* have to fit in type char. |
|
*/ |
*/ |
int |
int |
excline(char *line) |
excline(char *line) |
|
|
char *funcp, *tmp; |
char *funcp, *tmp; |
char *argp = NULL; |
char *argp = NULL; |
long nl; |
long nl; |
#ifdef FKEYS |
|
int bind; |
int bind; |
KEYMAP *curmap; |
KEYMAP *curmap; |
#define BINDARG 0 /* this arg is key to bind (local/global set key) */ |
#define BINDARG 0 /* this arg is key to bind (local/global set key) */ |
|
|
#define BINDNEXT 2 /* next arg " (define-key) */ |
#define BINDNEXT 2 /* next arg " (define-key) */ |
#define BINDDO 3 /* already found key to bind */ |
#define BINDDO 3 /* already found key to bind */ |
#define BINDEXT 1 /* space for trailing \0 */ |
#define BINDEXT 1 /* space for trailing \0 */ |
#else /* FKEYS */ |
|
#define BINDEXT 0 |
|
#endif /* FKEYS */ |
|
|
|
lp = NULL; |
lp = NULL; |
|
|
|
|
ewprintf("Unknown function: %s", funcp); |
ewprintf("Unknown function: %s", funcp); |
return (FALSE); |
return (FALSE); |
} |
} |
#ifdef FKEYS |
|
if (fp == bindtokey || fp == unbindtokey) { |
if (fp == bindtokey || fp == unbindtokey) { |
bind = BINDARG; |
bind = BINDARG; |
curmap = fundamental_map; |
curmap = fundamental_map; |
|
|
bind = BINDNEXT; |
bind = BINDNEXT; |
else |
else |
bind = BINDNO; |
bind = BINDNO; |
#endif /* FKEYS */ |
|
/* Pack away all the args now... */ |
/* Pack away all the args now... */ |
if ((np = lalloc(0)) == FALSE) |
if ((np = lalloc(0)) == FALSE) |
return (FALSE); |
return (FALSE); |
|
|
goto cleanup; |
goto cleanup; |
} |
} |
bcopy(argp, ltext(lp), (int)(line - argp)); |
bcopy(argp, ltext(lp), (int)(line - argp)); |
#ifdef FKEYS |
|
/* don't count BINDEXT */ |
/* don't count BINDEXT */ |
lp->l_used--; |
lp->l_used--; |
if (bind == BINDARG) |
if (bind == BINDARG) |
bind = BINDNO; |
bind = BINDNO; |
#endif /* FKEYS */ |
|
} else { |
} else { |
/* quoted strings are special */ |
/* quoted strings are special */ |
++argp; |
++argp; |
#ifdef FKEYS |
|
if (bind != BINDARG) { |
if (bind != BINDARG) { |
#endif /* FKEYS */ |
|
lp = lalloc((int)(line - argp) + BINDEXT); |
lp = lalloc((int)(line - argp) + BINDEXT); |
if (lp == NULL) { |
if (lp == NULL) { |
status = FALSE; |
status = FALSE; |
goto cleanup; |
goto cleanup; |
} |
} |
lp->l_used = 0; |
lp->l_used = 0; |
#ifdef FKEYS |
|
} else |
} else |
key.k_count = 0; |
key.k_count = 0; |
#endif /* FKEYS */ |
|
while (*argp != '"' && *argp != '\0') { |
while (*argp != '"' && *argp != '\0') { |
if (*argp != '\\') |
if (*argp != '\\') |
c = *argp++; |
c = *argp++; |
|
|
} |
} |
} |
} |
break; |
break; |
#ifdef FKEYS |
|
case 'f': |
case 'f': |
case 'F': |
case 'F': |
c = *++argp - '0'; |
c = *++argp - '0'; |
|
|
} |
} |
c += KFIRST; |
c += KFIRST; |
break; |
break; |
#endif /* FKEYS */ |
|
default: |
default: |
c = CHARMASK(*argp); |
c = CHARMASK(*argp); |
break; |
break; |
} |
} |
argp++; |
argp++; |
} |
} |
#ifdef FKEYS |
|
if (bind == BINDARG) |
if (bind == BINDARG) |
key.k_chars[key.k_count++] = c; |
key.k_chars[key.k_count++] = c; |
else |
else |
#endif /* FKEYS */ |
|
lp->l_text[lp->l_used++] = c; |
lp->l_text[lp->l_used++] = c; |
} |
} |
if (*line) |
if (*line) |
line++; |
line++; |
} |
} |
#ifdef FKEYS |
|
switch (bind) { |
switch (bind) { |
case BINDARG: |
case BINDARG: |
bind = BINDDO; |
bind = BINDDO; |
|
|
bind = BINDARG; |
bind = BINDARG; |
break; |
break; |
default: |
default: |
#endif /* FKEYS */ |
|
lp->l_fp = np->l_fp; |
lp->l_fp = np->l_fp; |
lp->l_bp = np; |
lp->l_bp = np; |
np->l_fp = lp; |
np->l_fp = lp; |
np = lp; |
np = lp; |
#ifdef FKEYS |
|
} |
} |
#endif /* FKEYS */ |
|
} |
} |
#ifdef FKEYS |
|
switch (bind) { |
switch (bind) { |
default: |
default: |
dobeep(); |
dobeep(); |
|
|
key.k_count); |
key.k_count); |
break; |
break; |
case BINDNO: |
case BINDNO: |
#endif /* FKEYS */ |
|
inmacro = TRUE; |
inmacro = TRUE; |
maclcur = maclcur->l_fp; |
maclcur = maclcur->l_fp; |
status = (*fp)(f, n); |
status = (*fp)(f, n); |
inmacro = FALSE; |
inmacro = FALSE; |
#ifdef FKEYS |
|
} |
} |
#endif /* FKEYS */ |
|
cleanup: |
cleanup: |
lp = maclcur->l_fp; |
lp = maclcur->l_fp; |
while (lp != maclcur) { |
while (lp != maclcur) { |