diff --git a/src/global.c b/src/global.c index 4a99643b..6868bd62 100644 --- a/src/global.c +++ b/src/global.c @@ -441,6 +441,28 @@ int the_code_for(void (*func)(void), int defaultval) return s->keycode; } +/* Return the shortcut that corresponds to the values of kbinput (the + * key itself) and meta_key (whether the key is a meta sequence). The + * returned shortcut will be the first in the list that corresponds to + * the given sequence. */ +const keystruct *get_shortcut(int *kbinput) +{ + keystruct *s; + + /* Plain characters cannot be shortcuts, so just skip those. */ + if (!meta_key && ((*kbinput >= 0x20 && *kbinput < 0x7F) || + (*kbinput >= 0xA0 && *kbinput <= 0xFF))) + return NULL; + + for (s = sclist; s != NULL; s = s->next) { + if ((s->menus & currmenu) && *kbinput == s->keycode && + meta_key == s->meta) + return s; + } + + return NULL; +} + /* Return a pointer to the function that is bound to the given key. */ functionptrtype func_from_key(int *kbinput) { diff --git a/src/proto.h b/src/proto.h index aa9cd31f..2a2ba967 100644 --- a/src/proto.h +++ b/src/proto.h @@ -320,6 +320,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place, size_t length_of_list(int menu); const keystruct *first_sc_for(int menu, void (*func)(void)); int the_code_for(void (*func)(void), int defaultval); +const keystruct *get_shortcut(int *kbinput); functionptrtype func_from_key(int *kbinput); int keycode_from_string(const char *keystring); void assign_keyinfo(keystruct *s, const char *keystring, const int keycode); @@ -617,7 +618,6 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count); #ifdef ENABLE_MOUSE int get_mouseinput(int *mouse_row, int *mouse_col, bool allow_shortcuts); #endif -const keystruct *get_shortcut(int *kbinput); void blank_edit(void); void blank_statusbar(void); void wipe_statusbar(void); diff --git a/src/winio.c b/src/winio.c index bbdaffd7..917233c1 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1768,28 +1768,6 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts) } #endif /* ENABLE_MOUSE */ -/* Return the shortcut that corresponds to the values of kbinput (the - * key itself) and meta_key (whether the key is a meta sequence). The - * returned shortcut will be the first in the list that corresponds to - * the given sequence. */ -const keystruct *get_shortcut(int *kbinput) -{ - keystruct *s; - - /* Plain characters cannot be shortcuts, so just skip those. */ - if (!meta_key && ((*kbinput >= 0x20 && *kbinput < 0x7F) || - (*kbinput >= 0xA0 && *kbinput <= 0xFF))) - return NULL; - - for (s = sclist; s != NULL; s = s->next) { - if ((s->menus & currmenu) && *kbinput == s->keycode && - meta_key == s->meta) - return s; - } - - return NULL; -} - /* Move (in the given window) to the given row and wipe it clean. */ void blank_row(WINDOW *window, int row) {