From: Thomas Roessler Date: Wed, 16 Sep 1998 06:40:27 +0000 (+0000) Subject: Use for function keys as well as for other special X-Git-Tag: mutt-0-94-7i-rel~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b01b6fa864c36399ee52965069b51461e30edc4c;p=mutt Use for function keys as well as for other special keys. Additionally, this patch makes it possible to use all special keys inside a key _sequence_. --- diff --git a/keymap.c b/keymap.c index b3f8c0e3..b1b9f18b 100644 --- a/keymap.c +++ b/keymap.c @@ -86,28 +86,58 @@ static struct keymap_t *allocKeys (int len, keycode_t *keys) return (p); } -static int parsekeys (char *s, keycode_t *d, int max) +static int parse_fkey(char *s) +{ + char *t; + int n = 0; + + if(s[0] != '<' || tolower(s[1]) != 'f') + return -1; + + for(t = s + 2; *t && isdigit((unsigned char) *t); t++) + { + n *= 10; + n += *t - '0'; + } + + if(*t != '>') + return -1; + else + return n; +} + +static int parsekeys (char *str, keycode_t *d, int max) { int n, len = max; + char buff[SHORT_STRING]; + char c; + char *s, *t; + strfcpy(buff, str, sizeof(buff)); + s = buff; + while (*s && len) { - if ((n = mutt_getvaluebyname (s, KeyNames)) != -1) - { - s += strlen (s); - *d = n; - } - else if (tolower (*s) == 'f' && isdigit ((unsigned char) s[1])) + *d = '\0'; + if(*s == '<' && (t = strchr(s, '>'))) { - n = 0; - for (s++; isdigit ((unsigned char) *s) ; s++) + t++; c = *t; *t = '\0'; + + if ((n = mutt_getvaluebyname (s, KeyNames)) != -1) { - n *= 10; - n += *s - '0'; + s = t; + *d = n; } - *d = KEY_F(n); + else if ((n = parse_fkey(s)) > 0) + { + s = t; + *d = KEY_F (n); + } + + *t = c; } - else + + if(!*d) { *d = *s; s++;