wrapper to make the code a bit cleaner.
* src/help.c (do_help, parse_help_input): Use the wrapper.
* src/browser.c (do_browser, parse_browser_input): Likewise.
+ * src/search.c (search_init, do_gotolinecolumn): Likewise.
+ * src/search.c (findnextstr): Replace a call of old wrapper
+ 'getfuncfromkey()' with a call of new 'func_from_key()'.
+ * src/winio.c (getfuncfromkey): Delete now unneeded wrapper.
2014-07-01 Benno Schulenberg <bensberg@justemail.net>
* src/browser.c (do_browser), src/help.c (do_help): Make sure
void set_spell_shortcuts(void);
#endif
const subnfunc *sctofunc(sc *s);
-const subnfunc *getfuncfromkey(WINDOW *win);
const char *flagtostr(int flag);
sc *strtosc(char *input);
int strtomenu(char *input);
{
int i = 0;
char *buf;
- sc *s;
static char *backupstring = NULL;
/* The search string we'll be using. */
statusbar(_("Cancelled"));
return -1;
} else {
- void (*func)(void) = NULL;
-
- for (s = sclist; s != NULL; s = s->next)
- if ((s->menu & currmenu) && i == s->seq) {
- func = s->scfunc;
- break;
- }
+ functionptrtype func = func_from_key(&i);
if (i == -2 || i == 0 ) {
#ifdef HAVE_REGEX_H
ssize_t current_y_find = openfile->current_y;
filestruct *fileptr = openfile->current;
const char *rev_start = fileptr->data, *found = NULL;
- const subnfunc *f;
time_t lastkbcheck = time(NULL);
/* rev_start might end up 1 character before the start or after the
enable_nodelay();
while (TRUE) {
if (time(NULL) - lastkbcheck > 1) {
+ int input = parse_kbinput(edit);
+
lastkbcheck = time(NULL);
- f = getfuncfromkey(edit);
- if (f && f->scfunc == do_cancel) {
+
+ if (input && func_from_key(&input) == do_cancel) {
statusbar(_("Cancelled"));
return FALSE;
}
void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
bool interactive, bool save_pos, bool allow_update)
{
- const sc *s;
-
if (interactive) {
char *ans = mallocstrcpy(NULL, answer);
+ functionptrtype func;
/* Ask for the line and column. */
int i = do_prompt(FALSE,
return;
}
- s = get_shortcut(&i);
+ func = func_from_key(&i);
- if (s && s->scfunc == gototext_void) {
+ if (func == gototext_void) {
/* Keep answer up on the statusbar. */
search_init(TRUE, TRUE);
return NULL;
}
-/* Try to get a function back from a window. Just a wrapper. */
-const subnfunc *getfuncfromkey(WINDOW *win)
-{
- int kbinput;
- const sc *s;
-
- kbinput = parse_kbinput(win);
- if (kbinput == 0)
- return NULL;
-
- s = get_shortcut(&kbinput);
- if (!s)
- return NULL;
-
- return sctofunc((sc *) s);
-}
-
/* Move to (x, y) in win, and display a line of n spaces with the
* current attributes. */
void blank_line(WINDOW *win, int y, int x, int n)