event_t mutt_getch (void)
{
int ch;
- event_t err = {-1,0}, ret;
+ event_t err = {-1, OP_NULL }, ret;
if (UngetCount)
return (KeyEvent[--UngetCount]);
{
char buf[LONG_STRING], helpstr[SHORT_STRING];
int op = OP_NULL;
- event_t event = {OP_NULL, 0};
+ event_t event = {-1, 0};
int done = 0; /* controls when to exit the "event" loop */
int i = 0, j;
int tag = 0; /* has the tag-prefix command been pressed? */
{
timeout (Timeout * 1000); /* milliseconds */
event = mutt_getch ();
+ dprint(1, (debugfile, "mutt_index_menu[%d]: Got event (%d, %d)\n", __LINE__,
+ event.ch, event.op));
timeout (-1); /* restore blocking operation */
if (event.ch != -1)
{
+ dprint(1, (debugfile, "mutt_index_menu[%d]: Pushing event (%d, %d)\n", __LINE__,
+ event.ch, event.op));
mutt_ungetch (event.ch, event.op);
op = km_dokey (MENU_MAIN);
+ dprint(1, (debugfile, "mutt_index_menu[%d]: Got op %d\n", __LINE__,
+ op));
}
+ else
+ op = -1;
}
else
+ {
op = km_dokey (MENU_MAIN);
+ dprint(1, (debugfile, "mutt_index_menu[%d]: Got op %d\n", __LINE__,
+ op));
+ }
mutt_curs_set (1);
/* exec command-name */
int mutt_parse_exec (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
{
- int op = OP_NULL;
- char *command = NULL;
+ int ops[128];
+ int nops = 0;
struct binding_t *bindings = NULL;
-
+ char *command;
+
if (!MoreArgs (s))
{
strfcpy (err->data, _("exec: too few arguments"), err->dsize);
return (-1);
}
- mutt_extract_token (buf, s, 0);
- command = safe_strdup (buf->data);
-
- if (MoreArgs (s))
- {
- strfcpy (err->data, _("too many arguments"), err->dsize);
- return (-1);
- }
-
- if ((bindings = km_get_table (CurrentMenu)) == NULL)
- bindings = OpGeneric;
-
- op = get_op (bindings, command, strlen(command));
- if (op == OP_NULL)
- op = get_op (OpGeneric, command, strlen(command));
-
- if (op == OP_NULL)
+ do
{
- mutt_flushinp ();
- mutt_error (_("%s: no such command"), command);
- FREE (&command);
- return (-1);
+ mutt_extract_token (buf, s, 0);
+ command = buf->data;
+
+ if ((bindings = km_get_table (CurrentMenu)) == NULL)
+ bindings = OpGeneric;
+
+ ops[nops] = get_op (bindings, command, strlen(command));
+ if (ops[nops] == OP_NULL)
+ ops[nops] = get_op (OpGeneric, command, strlen(command));
+
+ if (ops[nops] == OP_NULL)
+ {
+ mutt_flushinp ();
+ mutt_error (_("%s: no such command"), command);
+ return (-1);
+ }
}
-
- mutt_ungetch (0, op);
- FREE (&command);
+ while(MoreArgs(s) && ++nops < sizeof(ops)/sizeof(ops[0]));
+
+ while(nops)
+ mutt_ungetch(0, ops[--nops]);
+
return 0;
}