diff --git a/src/global.c b/src/global.c index e2d8749fb1d57326d16be37184a172c964ee0cc9..b95afa87c0ef1b1c2ca3d8f9c299afc5b15374a5 100644 --- a/src/global.c +++ b/src/global.c @@ -340,7 +340,6 @@ void add_to_sclist(int menus, const char *scstring, void (*func)(void), int togg if (toggle) s->ordinal = ++counter; s->keystr = (char *) scstring; - s->type = strtokeytype(scstring); assign_keyinfo(s); #ifdef DEBUG @@ -400,41 +399,31 @@ functionptrtype func_from_key(int *kbinput) return NULL; } -/* Return the type of command key based on the given string. */ -key_type strtokeytype(const char *str) -{ - if (str[0] == '^') - return CONTROL; - else if (str[0] == 'M') - return META; - else if (str[0] == 'F') - return FKEY; - else - return RAWINPUT; -} - /* Assign the info to the shortcut struct. * Assumes keystr is already assigned, naturally. */ void assign_keyinfo(sc *s) { - if (s->type == CONTROL) { + s->type = DIRECT; + + if (s->keystr[0] == '^') { assert(strlen(s->keystr) > 1); s->seq = s->keystr[1] - 64; - } else if (s->type == META) { + } else if (s->keystr[0] == 'M') { assert(strlen(s->keystr) > 2); + s->type = META; s->seq = tolower((int) s->keystr[2]); - } else if (s->type == FKEY) { + } else if (s->keystr[0] == 'F') { assert(strlen(s->keystr) > 1); s->seq = KEY_F0 + atoi(&s->keystr[1]); } else /* RAWINPUT */ s->seq = (int) s->keystr[0]; /* Override some keys which don't bind as easily as we'd like. */ - if (s->type == CONTROL && (!strcasecmp(&s->keystr[1], "space"))) + if (strcasecmp(s->keystr, "^Space") == 0) s->seq = 0; - else if (s->type == META && (!strcasecmp(&s->keystr[2], "space"))) + else if (strcasecmp(s->keystr, "M-Space") == 0) s->seq = (int) ' '; - else if (s->type == RAWINPUT) { + else { if (!strcasecmp(s->keystr, "Up")) s->seq = KEY_UP; else if (!strcasecmp(s->keystr, "Down")) diff --git a/src/nano.h b/src/nano.h index 7403833dbad8fe8ec049b7a7e262e51c43915435..b43c3214245f2e665628b0511a1a5c823bd08826 100644 --- a/src/nano.h +++ b/src/nano.h @@ -188,7 +188,7 @@ typedef enum { } update_type; typedef enum { - CONTROL, META, FKEY, RAWINPUT + DIRECT, META } key_type; typedef enum { diff --git a/src/proto.h b/src/proto.h index 98081aa489d98ea119ae174f491947ae7bf4c102..58f7fad829173142f6a78cbbcce71b7ba84bb37f 100644 --- a/src/proto.h +++ b/src/proto.h @@ -362,7 +362,6 @@ size_t length_of_list(int menu); const sc *first_sc_for(int menu, void (*func)(void)); int sc_seq_or(void (*func)(void), int defaultval); functionptrtype func_from_key(int *kbinput); -key_type strtokeytype(const char *str); void assign_keyinfo(sc *s); void print_sclist(void); void shortcut_init(void); diff --git a/src/rcfile.c b/src/rcfile.c index c46c361ad19d6acdea1985249daad09817893b33..722a9adf01978e75e27402ff2b982817e7122b55 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -472,7 +472,6 @@ void parse_binding(char *ptr, bool dobind) newsc->keystr = keycopy; newsc->menus = menu; - newsc->type = strtokeytype(newsc->keystr); assign_keyinfo(newsc); /* Do not allow rebinding the equivalent of the Escape key. */ diff --git a/src/winio.c b/src/winio.c index b912290290faa22b428a0a4d4a90c834b58e09f0..f98117b08a5daa031d8bdd048ec213184bef9eb7 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1563,7 +1563,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts) /* And put the corresponding key into the keyboard buffer. */ if (f != NULL) { const sc *s = first_sc_for(currmenu, f->scfunc); - unget_kbinput(s->seq, s->type == META, s->type == FKEY); + unget_kbinput(s->seq, s->type == META, s->type == DIRECT); } return 1; } else