Skip to content

Commit

Permalink
Always return OPs in the op member
Browse files Browse the repository at this point in the history
  • Loading branch information
gahr authored and flatcap committed May 2, 2022
1 parent 8c2c39b commit 46c6bdc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
4 changes: 2 additions & 2 deletions conn/dlg_verifycert.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ static int menu_dialog_dokey(struct Menu *menu, int *id)
ch = mutt_getch_timeout(5000);
// mutt_curses_set_cursor(cursor);

if (ch.ch < OP_NULL)
if ((ch.op == OP_TIMEOUT) || (ch.op == OP_ABORT))
{
*id = ch.ch;
*id = ch.op;
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion enter/enter.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ int mutt_enter_string_full(char *buf, size_t buflen, int col, CompletionFlags fl
{
quote_event = mutt_getch();
} while (quote_event.ch == OP_TIMEOUT);
if (quote_event.ch >= 0)
if (quote_event.op != OP_ABORT)
{
event = quote_event;
goto self_insert;
Expand Down
4 changes: 2 additions & 2 deletions flags.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,13 @@ int mutt_change_flag(struct Mailbox *m, struct EmailList *el, bool bf)
do
{
event = mutt_getch();
} while (event.ch == -2); // Timeout
} while (event.op == OP_TIMEOUT);
mutt_curses_set_cursor(cursor);

window_set_focus(old_focus);
msgwin_clear_text();

if (event.ch < 0) // SIGINT, Abort key (Ctrl-G)
if (event.op == OP_ABORT)
return -1;

switch (event.ch)
Expand Down
7 changes: 4 additions & 3 deletions gui/curs_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ static int mutt_monitor_getch(void)
struct KeyEvent mutt_getch(void)
{
int ch;
const struct KeyEvent err = { OP_ABORT, OP_NULL };
const struct KeyEvent timeout = { OP_TIMEOUT, OP_NULL };
const struct KeyEvent err = { 0, OP_ABORT };
const struct KeyEvent timeout = { 0, OP_TIMEOUT };

struct KeyEvent *key = array_pop(&UngetKeyEvents);
if (key)
Expand Down Expand Up @@ -311,6 +311,7 @@ struct KeyEvent mutt_getch(void)
/* send ALT-x as ESC-x */
ch &= ~0x80;
mutt_unget_ch(ch);
ch = '\033';
return (struct KeyEvent){ .ch = '\033' /* Escape */, .op = OP_NULL };
}

Expand Down Expand Up @@ -580,7 +581,7 @@ int mutt_buffer_enter_fname(const char *prompt, struct Buffer *fname,
do
{
ch = mutt_getch();
} while (ch.ch == OP_TIMEOUT);
} while (ch.op == OP_TIMEOUT);
mutt_curses_set_cursor(cursor);

mutt_window_move(win, 0, 0);
Expand Down
11 changes: 5 additions & 6 deletions keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ struct KeyEvent km_dokey_event(enum MenuType mtype)
/* If a timeout was not received, or the window was resized, exit the
* loop now. Otherwise, continue to loop until reaching a total of
* $timeout seconds. */
if ((tmp.ch != OP_TIMEOUT) || SigWinch)
if ((tmp.op != OP_TIMEOUT) || SigWinch)
goto gotkey;
#ifdef USE_INOTIFY
if (MonitorFilesChanged)
Expand All @@ -685,12 +685,11 @@ struct KeyEvent km_dokey_event(enum MenuType mtype)
gotkey:
#endif
/* hide timeouts, but not window resizes, from the line editor. */
if ((mtype == MENU_EDITOR) && (tmp.ch == OP_TIMEOUT) && !SigWinch)
if ((mtype == MENU_EDITOR) && (tmp.op == OP_TIMEOUT) && !SigWinch)
continue;

if (tmp.ch < 0)
if ((tmp.op == OP_TIMEOUT) || (tmp.op == OP_ABORT))
{
tmp.op = tmp.ch;
return tmp;
}

Expand Down Expand Up @@ -755,7 +754,7 @@ struct KeyEvent km_dokey_event(enum MenuType mtype)
if (++pos == map->len)
{
if (map->op != OP_MACRO)
return (struct KeyEvent){ .ch = '\0', .op = map->op };
return (struct KeyEvent){ .ch = tmp.ch, .op = map->op };

/* OptIgnoreMacroEvents turns off processing the MacroEvents buffer
* in mutt_getch(). Generating new macro events during that time would
Expand All @@ -769,7 +768,7 @@ struct KeyEvent km_dokey_event(enum MenuType mtype)
* but less so than aborting the prompt. */
if (OptIgnoreMacroEvents)
{
return (struct KeyEvent){ .ch = '\0', .op = OP_NULL };
return (struct KeyEvent){ .ch = tmp.ch, .op = OP_NULL };
}

if (n++ == 10)
Expand Down
9 changes: 4 additions & 5 deletions question/question.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,9 @@ int mutt_multi_choice(const char *prompt, const char *letters)
mutt_refresh();
/* SigWinch is not processed unless timeout is set */
ch = mutt_getch_timeout(30 * 1000);
if (ch.ch == OP_TIMEOUT)
if (ch.op == OP_TIMEOUT)
continue;
/* (ch.ch == 0) is technically possible. Treat the same as < 0 (abort) */
if ((ch.ch <= 0) || CI_is_return(ch.ch))
if ((ch.op == OP_NULL) || (ch.op == OP_ABORT) || CI_is_return(ch.ch))
{
choice = -1;
break;
Expand Down Expand Up @@ -318,11 +317,11 @@ enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
mutt_refresh();
/* SigWinch is not processed unless timeout is set */
ch = mutt_getch_timeout(30 * 1000);
if (ch.ch == OP_TIMEOUT)
if (ch.op == OP_TIMEOUT)
continue;
if (CI_is_return(ch.ch))
break;
if (ch.ch < 0)
if (ch.op == OP_ABORT)
{
def = MUTT_ABORT;
break;
Expand Down

0 comments on commit 46c6bdc

Please sign in to comment.