2 * Copyright notice from original mutt:
3 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
5 * Parts were written/modified by:
6 * Nico Golde <nico@ngolde.de>
8 * This file is part of mutt-ng, see http://www.muttng.org/.
9 * It's licensed under the GNU General Public License,
10 * please see the file GPL in the top level source directory.
13 #include <lib-ui/lib-ui.h>
14 #include <lib-mx/mx.h>
24 #include "recvattach.h"
29 #include <imap/imap_private.h>
31 static const char *No_mailbox_is_open = N_("No mailbox is open.");
32 static const char *There_are_no_messages = N_("There are no messages.");
33 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
34 static const char *Function_not_permitted_in_attach_message_mode =
35 N_("Function not permitted in attach-message mode.");
36 static const char *No_visible = N_("No visible messages.");
38 #define CHECK_IN_MAILBOX if (!Context) \
41 mutt_error (_(No_mailbox_is_open)); \
45 #define CHECK_MSGCOUNT if (!Context) \
48 mutt_error(_(No_mailbox_is_open)); \
51 else if (!Context->msgcount) \
54 mutt_error(_(There_are_no_messages)); \
58 #define CHECK_VISIBLE if (Context && menu->current >= Context->vcount) \
61 mutt_error(_(No_visible)); \
66 #define CHECK_READONLY if (Context->readonly) \
69 mutt_error(_(Mailbox_is_read_only)); \
73 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
76 mutt_error(_(Function_not_permitted_in_attach_message_mode)); \
80 #define CURHDR Context->hdrs[Context->v2r[menu->current]]
81 #define OLDHDR Context->hdrs[Context->v2r[menu->oldcurrent]]
82 #define UNREAD(h) mutt_thread_contains_unread (Context, h)
84 extern size_t UngetCount;
86 void index_make_entry (char *s, ssize_t l, struct menu_t * menu, int num)
88 format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_INDEX;
89 int edgemsgno, reverse = Sort & SORT_REVERSE;
90 HEADER *h = Context->hdrs[Context->v2r[num]];
93 if ((Sort & SORT_MASK) == SORT_THREADS && h->tree) {
94 flag |= M_FORMAT_TREE; /* display the thread tree */
95 if (h->display_subject)
96 flag |= M_FORMAT_FORCESUBJ;
99 if (menu->top + menu->pagelen > menu->max)
100 edgemsgno = Context->v2r[menu->max - 1];
102 edgemsgno = Context->v2r[menu->top + menu->pagelen - 1];
105 edgemsgno = Context->v2r[menu->top];
107 for (tmp = h->thread->parent; tmp; tmp = tmp->parent) {
111 /* if no ancestor is visible on current screen, provisionally force
113 if (reverse ? tmp->message->msgno > edgemsgno : tmp->message->msgno <
115 flag |= M_FORMAT_FORCESUBJ;
118 else if (tmp->message->virtual >= 0)
121 if (flag & M_FORMAT_FORCESUBJ) {
122 for (tmp = h->thread->prev; tmp; tmp = tmp->prev) {
126 /* ...but if a previous sibling is available, don't force it */
127 if (reverse ? tmp->message->msgno >
128 edgemsgno : tmp->message->msgno < edgemsgno)
130 else if (tmp->message->virtual >= 0) {
131 flag &= ~M_FORMAT_FORCESUBJ;
139 _mutt_make_string (s, l, NONULL (HdrFmt), Context, h, flag);
142 int index_color (int index_no)
144 HEADER *h = Context->hdrs[Context->v2r[index_no]];
149 mutt_set_header_color (Context, h);
153 static int ci_next_undeleted (int msgno)
157 for (i = msgno + 1; i < Context->vcount; i++)
158 if (!Context->hdrs[Context->v2r[i]]->deleted)
163 static int ci_previous_undeleted (int msgno)
167 for (i = msgno - 1; i >= 0; i--)
168 if (!Context->hdrs[Context->v2r[i]]->deleted)
173 /* Return the index of the first new message, or failing that, the first
176 static int ci_first_message (void)
180 if (Context && Context->msgcount) {
181 for (i = 0; i < Context->vcount; i++) {
182 if (!Context->hdrs[Context->v2r[i]]->read &&
183 !Context->hdrs[Context->v2r[i]]->deleted) {
184 if (!Context->hdrs[Context->v2r[i]]->old)
193 /* If Sort is reverse and not threaded, the latest message is first.
194 * If Sort is threaded, the latest message is first iff exactly one
195 * of Sort and SortAux are reverse.
197 if (((Sort & SORT_REVERSE) && (Sort & SORT_MASK) != SORT_THREADS) ||
198 ((Sort & SORT_MASK) == SORT_THREADS &&
199 ((Sort ^ SortAux) & SORT_REVERSE)))
202 return (Context->vcount ? Context->vcount - 1 : 0);
207 /* This should be in mx.c, but it only gets used here. */
208 static int mx_toggle_write (CONTEXT * ctx)
214 mutt_error (_("Cannot toggle write on a readonly mailbox!"));
219 if (ctx->dontwrite) {
221 mutt_message (_("Changes to folder will be written on folder exit."));
225 mutt_message (_("Changes to folder will not be written."));
231 static void update_index (MUTTMENU * menu, CONTEXT * ctx __attribute__ ((unused)), int check,
232 int oldcount, int index_hint)
234 /* store pointers to the newly added messages */
235 HEADER **save_new = NULL;
238 /* take note of the current message */
240 if (menu->current < Context->vcount)
241 menu->oldcurrent = index_hint;
243 oldcount = 0; /* invalid message number! */
246 /* We are in a limited view. Check if the new message(s) satisfy
247 * the limit criteria. If they do, set their virtual msgno so that
248 * they will be visible in the limited view */
249 if (Context->pattern) {
250 #define THIS_BODY Context->hdrs[j]->content
251 for (j = (check == M_REOPENED) ? 0 : oldcount; j < Context->msgcount; j++) {
252 if (mutt_pattern_exec
253 (Context->limit_pattern, M_MATCH_FULL_ADDRESS, Context,
255 Context->hdrs[j]->virtual = Context->vcount;
256 Context->v2r[Context->vcount] = j;
257 Context->hdrs[j]->limited = 1;
260 THIS_BODY->length + THIS_BODY->offset - THIS_BODY->hdr_offset;
266 /* save the list of new messages */
267 if (oldcount && check != M_REOPENED && ((Sort & SORT_MASK) == SORT_THREADS)) {
268 save_new = p_new(HEADER*, Context->msgcount - oldcount);
269 for (j = oldcount; j < Context->msgcount; j++)
270 save_new[j - oldcount] = Context->hdrs[j];
273 /* if the mailbox was reopened, need to rethread from scratch */
274 mutt_sort_headers (Context, (check == M_REOPENED));
276 /* uncollapse threads with new mail */
277 if ((Sort & SORT_MASK) == SORT_THREADS) {
278 if (check == M_REOPENED) {
281 Context->collapsed = 0;
283 for (h = Context->tree; h; h = h->next) {
284 for (c = h; !c->message; c = c->child);
285 mutt_uncollapse_thread (Context, c->message);
287 mutt_set_virtual (Context);
290 for (j = 0; j < Context->msgcount - oldcount; j++) {
293 for (k = 0; k < Context->msgcount; k++) {
294 HEADER *h = Context->hdrs[k];
296 if (h == save_new[j] && (!Context->pattern || h->limited))
297 mutt_uncollapse_thread (Context, h);
301 mutt_set_virtual (Context);
307 /* restore the current message to the message it was pointing to */
308 for (j = 0; j < Context->vcount; j++) {
309 if (Context->hdrs[Context->v2r[j]]->index == menu->oldcurrent) {
316 if (menu->current < 0)
317 menu->current = ci_first_message ();
320 static void resort_index (MUTTMENU * menu)
323 HEADER *current = CURHDR;
326 mutt_sort_headers (Context, 0);
327 /* Restore the current message */
329 for (i = 0; i < Context->vcount; i++) {
330 if (Context->hdrs[Context->v2r[i]] == current) {
336 if ((Sort & SORT_MASK) == SORT_THREADS && menu->current < 0)
337 menu->current = mutt_parent_message (Context, current);
339 if (menu->current < 0)
340 menu->current = ci_first_message ();
342 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
345 /* This function handles the message index window as well as commands returned
346 * from the pager (MENU_PAGER).
348 int mutt_index_menu (void)
350 char buf[LONG_STRING];
353 int done = 0; /* controls when to exit the "event" loop */
355 int tag = 0; /* has the tag-prefix command been pressed? */
360 const char *cp; /* temporary variable. */
361 int index_hint; /* used to restore cursor position */
362 int do_buffy_notify = 1;
363 int closed = 0; /* did we OP_QUIT or OP_EXIT out of this menu? */
364 int attach_msg = option (OPTATTACHMSG);
366 menu = mutt_new_menu ();
367 menu->menu = MENU_MAIN;
369 menu->pagelen = LINES - 3;
370 menu->make_entry = (void *) index_make_entry;
371 menu->color = index_color;
372 menu->current = ci_first_message ();
375 buffy_check (0); /* force the buffy check after we enter the folder */
376 /* record folder we open to place sidebar indicator properly */
377 if (Context && Context->path)
378 sidebar_set_current (Context->path);
382 tag = 0; /* clear the tag-prefix */
384 menu->max = Context ? Context->vcount : 0;
385 oldcount = Context ? Context->msgcount : 0;
387 /* check if we need to resort the index because just about
388 * any 'op' below could do mutt_enter_command(), either here or
389 * from any new menu launched, and change $sort/$sort_aux
391 if (option (OPTNEEDRESORT) && Context && Context->msgcount)
394 if (option (OPTREDRAWTREE) && Context && Context->msgcount
395 && (Sort & SORT_MASK) == SORT_THREADS) {
396 mutt_draw_tree (Context);
397 menu->redraw |= REDRAW_STATUS;
398 unset_option (OPTREDRAWTREE);
401 if (Context && !attach_msg) {
404 /* check for new mail in the mailbox. If nonzero, then something has
405 * changed about the file (either we got new mail or the file was
406 * modified underneath us.)
409 imap_allow_reopen (Context);
411 index_hint = (Context->vcount && menu->current >= 0
412 && menu->current < Context->vcount) ? CURHDR->index : 0;
414 if ((check = mx_check_mailbox (Context, &index_hint, 0)) < 0) {
415 if (!Context->path) {
416 /* fatal error occurred */
418 menu->redraw = REDRAW_FULL;
420 set_option (OPTSEARCHINVALID);
422 else if (check == M_NEW_MAIL || check == M_REOPENED || check == M_FLAGS) {
423 update_index (menu, Context, check, oldcount, index_hint);
425 /* notify the user of new mail */
426 if (check == M_REOPENED)
428 ("Mailbox was externally modified. Flags may be wrong."));
429 else if (check == M_NEW_MAIL) {
430 /* on new mail: redraw sidebar */
432 mutt_message (_("New mail in this mailbox."));
434 if (mod_core.beep_new)
437 else if (check == M_FLAGS)
438 mutt_message (_("Mailbox was externally modified."));
440 /* avoid the message being overwritten by buffy */
443 menu->redraw = REDRAW_FULL;
444 menu->max = Context->vcount;
446 set_option (OPTSEARCHINVALID);
451 imap_disallow_reopen (Context);
454 /* check for new mail in the incoming folders */
456 if ((newcount = buffy_check (0)) != oldcount) {
457 menu->redraw |= REDRAW_STATUS;
458 menu->redraw |= REDRAW_SIDEBAR;
460 if (do_buffy_notify) {
461 if (buffy_notify () && mod_core.beep_new)
470 if (menu->redraw & REDRAW_SIDEBAR)
472 if (menu->redraw & REDRAW_FULL) {
473 menu_redraw_full (menu);
478 if (menu->menu == MENU_MAIN) {
479 if (Context && Context->hdrs && !(menu->current >= Context->vcount)) {
480 menu_check_recenter (menu);
482 if (menu->redraw & REDRAW_INDEX) {
483 menu_redraw_index (menu);
484 menu->redraw |= REDRAW_STATUS;
486 else if (menu->redraw & (REDRAW_MOTION_RESYNCH | REDRAW_MOTION))
487 menu_redraw_motion (menu);
488 else if (menu->redraw & REDRAW_CURRENT)
489 menu_redraw_current (menu);
492 if (menu->redraw & REDRAW_STATUS) {
493 menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
494 CLEARLINE(main_w, 0);
495 SETCOLOR(main_w, MT_COLOR_STATUS);
496 BKGDSET(main_w, MT_COLOR_STATUS);
498 mutt_paddstr (main_w, getmaxx(main_w), buf);
499 SETCOLOR(main_w, MT_COLOR_NORMAL);
500 BKGDSET(main_w, MT_COLOR_NORMAL);
501 sidebar_set_buffystats (Context);
502 menu->redraw &= ~REDRAW_STATUS;
503 if (option (OPTXTERMSETTITLES)) {
504 menu_status_line(buf, sizeof(buf), menu, NONULL(XtermTitle));
505 printf("\033]2;%s\007", buf);
506 menu_status_line(buf, sizeof(buf), menu, NONULL(XtermIcon));
507 printf("\033]1;%s\007", buf);
513 if (menu->current < menu->max)
514 menu->oldcurrent = menu->current;
516 menu->oldcurrent = -1;
522 menu->redraw = REDRAW_FULL;
523 menu->menu = MENU_MAIN;
524 menu->top = 0; /* so we scroll the right amount */
528 op = km_dokey (MENU_MAIN);
530 continue; /* either user abort or timeout */
534 /* special handling for the tag-prefix function */
535 if (op == OP_TAG_PREFIX) {
537 mutt_error (_("No mailbox is open."));
542 if (!Context->tagged) {
543 mutt_error (_("No tagged messages."));
549 /* give visual indication that the next command is a tag- command */
550 mvwaddstr (stdscr, LINES - 1, 0, "tag-");
553 /* get the real command */
554 if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX) {
555 /* abort tag sequence */
556 CLEARLINE(stdscr, LINES - 1);
560 else if (option (OPTAUTOTAG) && Context && Context->tagged)
563 if (op == OP_TAG_PREFIX_COND) {
565 mutt_error (_("No mailbox is open."));
570 if (!Context->tagged) {
573 while (UngetCount > 0) {
575 if (tmp.op == OP_END_COND)
578 mutt_message (_("Nothing to do."));
584 /* give visual indication that the next command is a tag- command */
585 mvwaddstr (stdscr, LINES - 1, 0, "tag-");
588 /* get the real command */
589 if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX) {
590 /* abort tag sequence */
591 CLEARLINE(stdscr, LINES - 1);
598 if (menu->current < menu->max)
599 menu->oldcurrent = menu->current;
601 menu->oldcurrent = -1;
603 mutt_curs_set (1); /* fallback from the pager */
608 /* ----------------------------------------------------------------------
613 menu_bottom_page (menu);
616 menu_first_entry (menu);
619 menu_middle_page (menu);
625 menu_half_down (menu);
628 menu_next_line (menu);
631 menu_prev_line (menu);
634 menu_next_page (menu);
637 menu_prev_page (menu);
640 menu_last_entry (menu);
643 menu_top_page (menu);
646 menu_current_top (menu);
648 case OP_CURRENT_MIDDLE:
649 menu_current_middle (menu);
651 case OP_CURRENT_BOTTOM:
652 menu_current_bottom (menu);
658 if (isdigit (LastKey))
659 mutt_ungetch (LastKey, 0);
661 if (mutt_get_field (_("Jump to message: "), buf, sizeof (buf), 0) != 0
665 if (!isdigit ((unsigned char) buf[0])) {
666 mutt_error (_("Argument must be a message number."));
672 if (i > 0 && i <= Context->msgcount) {
673 for (j = i - 1; j < Context->msgcount; j++) {
674 if (Context->hdrs[j]->virtual != -1)
677 if (j >= Context->msgcount) {
678 for (j = i - 2; j >= 0; j--) {
679 if (Context->hdrs[j]->virtual != -1)
685 menu->current = Context->hdrs[j]->virtual;
686 if (menu->menu == MENU_PAGER) {
687 op = OP_DISPLAY_MESSAGE;
691 menu->redraw = REDRAW_MOTION;
694 mutt_error (_("That message is not visible."));
697 mutt_error (_("Invalid message number."));
701 /* --------------------------------------------------------------------
702 * `index' specific commands
705 case OP_MAIN_DELETE_PATTERN:
710 CHECK_MX_ACL (Context, ACL_DELETE, _("Deletion"));
713 mutt_pattern_func (M_DELETE, _("Delete messages matching: "));
714 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
717 case OP_MAIN_FETCH_MAIL:
720 menu->redraw = REDRAW_FULL;
724 mutt_help (MENU_MAIN);
725 menu->redraw = REDRAW_FULL;
728 case OP_MAIN_SHOW_LIMIT:
730 if (!Context->pattern)
731 mutt_message (_("No limit pattern is in effect."));
736 /* i18n: ask for a limit to apply */
737 snprintf (buffer, sizeof (buffer), _("Limit: %s"), Context->pattern);
738 mutt_message ("%s", buffer);
745 menu->oldcurrent = (Context->vcount && menu->current >= 0
747 Context->vcount) ? CURHDR->index : -1;
748 if (op == OP_TOGGLE_READ) {
749 char buffer[LONG_STRING];
751 if (m_strncmp (Context->pattern, "!~R!~D~s", 8) != 0) {
752 snprintf (buffer, sizeof (buffer), "!~R!~D~s%s",
753 Context->pattern ? Context->pattern : ".*");
754 set_option (OPTHIDEREAD);
757 m_strcpy(buf, sizeof(buf), Context->pattern + 8);
758 if (m_strncmp (buf, ".*", 2) == 0)
759 snprintf (buf, sizeof (buf), "~A");
760 unset_option (OPTHIDEREAD);
762 p_delete(&Context->pattern);
763 Context->pattern = m_strdup(buf);
765 if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
766 mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
768 if (menu->oldcurrent >= 0) {
769 /* try to find what used to be the current message */
771 for (i = 0; i < Context->vcount; i++)
772 if (Context->hdrs[Context->v2r[i]]->index == menu->oldcurrent) {
776 if (menu->current < 0)
781 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
782 if (Context->msgcount && (Sort & SORT_MASK) == SORT_THREADS)
783 mutt_draw_tree (Context);
784 menu->redraw = REDRAW_FULL;
786 if (Context->pattern)
787 mutt_message _("To view all messages, limit to \"all\".");
797 if (query_quadoption2(mod_core.quit, _("Quit Madmutt?")) == M_YES) {
800 oldcount = Context ? Context->msgcount : 0;
803 || (check = mx_close_mailbox (Context, &index_hint)) == 0)
806 if (check == M_NEW_MAIL || check == M_REOPENED)
807 update_index (menu, Context, check, oldcount, index_hint);
809 menu->redraw = REDRAW_FULL; /* new mail arrived? */
810 set_option (OPTSEARCHINVALID);
816 clearok (main_w, TRUE);
817 menu->redraw = REDRAW_FULL;
821 case OP_SEARCH_REVERSE:
823 case OP_SEARCH_OPPOSITE:
826 if ((menu->current = mutt_search_command (menu->current, op)) == -1)
827 menu->current = menu->oldcurrent;
829 menu->redraw = REDRAW_MOTION;
833 case OP_SORT_REVERSE:
834 if (mutt_select_sort ((op == OP_SORT_REVERSE)) == 0) {
835 if (Context && Context->msgcount) {
837 set_option (OPTSEARCHINVALID);
845 if (tag && !option (OPTAUTOTAG)) {
846 for (j = 0; j < Context->vcount; j++)
847 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_TAG, 0);
848 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
851 mutt_set_flag (Context, CURHDR, M_TAG, !CURHDR->tagged);
852 Context->last_tag = CURHDR->tagged ? CURHDR :
853 ((Context->last_tag == CURHDR && !CURHDR->tagged)
854 ? NULL : Context->last_tag);
855 menu->redraw = REDRAW_STATUS;
856 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1) {
858 menu->redraw |= REDRAW_MOTION_RESYNCH;
861 menu->redraw |= REDRAW_CURRENT;
865 case OP_MAIN_TAG_PATTERN:
868 mutt_pattern_func (M_TAG, _("Tag messages matching: "));
869 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
872 case OP_MAIN_UNDELETE_PATTERN:
877 CHECK_MX_ACL (Context, ACL_DELETE, _("Undeletion"));
879 if (mutt_pattern_func (M_UNDELETE, _("Undelete messages matching: ")) ==
881 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
884 case OP_MAIN_UNTAG_PATTERN:
887 if (mutt_pattern_func (M_UNTAG, _("Untag messages matching: ")) == 0)
888 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
891 /* --------------------------------------------------------------------
892 * The following operations can be performed inside of the pager.
895 case OP_MAIN_IMAP_FETCH:
896 if (Context->magic == M_IMAP)
897 imap_check_mailbox (Context, &index_hint, 1);
900 case OP_MAIN_SYNC_FOLDER:
901 if (Context && !Context->msgcount)
908 int oldvcount = Context->vcount;
909 oldcount = Context->msgcount;
913 /* calculate the number of messages _above_ the cursor,
914 * so we can keep the cursor on the current message
916 for (j = 0; j <= menu->current; j++) {
917 if (Context->hdrs[Context->v2r[j]]->deleted)
921 if ((check = mx_sync_mailbox (Context, &index_hint)) == 0) {
922 if (Context->vcount != oldvcount)
923 menu->current -= dcount;
924 set_option (OPTSEARCHINVALID);
926 else if (check == M_NEW_MAIL || check == M_REOPENED)
927 update_index (menu, Context, check, oldcount, index_hint);
930 * do a sanity check even if mx_sync_mailbox failed.
933 if (menu->current < 0 || menu->current >= Context->vcount)
934 menu->current = ci_first_message ();
937 /* check for a fatal error, or all messages deleted */
941 /* if we were in the pager, redisplay the message */
942 if (menu->menu == MENU_PAGER) {
943 op = OP_DISPLAY_MESSAGE;
947 menu->redraw = REDRAW_FULL;
950 case OP_SIDEBAR_OPEN:
951 case OP_MAIN_CHANGE_FOLDER:
952 case OP_MAIN_CHANGE_FOLDER_READONLY:
953 if (attach_msg || op == OP_MAIN_CHANGE_FOLDER_READONLY)
959 cp = _("Open mailbox in read-only mode");
961 cp = _("Open mailbox");
964 if (Context && Context->path)
965 m_strcpy(buf, sizeof(buf), Context->path);
966 if (op != OP_SIDEBAR_OPEN)
967 buffy_next (buf, sizeof (buf));
969 if (op == OP_SIDEBAR_OPEN) {
970 m_strcpy(buf, sizeof(buf), sidebar_get_current());
972 else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) {
973 if (menu->menu == MENU_PAGER) {
974 op = OP_DISPLAY_MESSAGE;
980 CLEARLINE(main_w, LINES - 1);
984 mutt_expand_path (buf, sizeof (buf));
985 if (mx_get_magic (buf) <= 0) {
986 mutt_error (_("%s is not a mailbox."), buf);
989 m_strreplace(&CurrentFolder, buf);
994 if (Context->cinfo && Context->realpath)
995 m_strreplace(&LastFolder, Context->realpath);
997 m_strreplace(&LastFolder, Context->path);
998 oldcount = Context ? Context->msgcount : 0;
1000 if ((check = mx_close_mailbox (Context, &index_hint)) != 0) {
1001 if (check == M_NEW_MAIL || check == M_REOPENED)
1002 update_index (menu, Context, check, oldcount, index_hint);
1004 set_option (OPTSEARCHINVALID);
1005 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1013 /* Set CurrentMenu to MENU_MAIN before executing any folder
1014 * hooks so that all the index menu functions are available to
1018 CurrentMenu = MENU_MAIN;
1019 mutt_folder_hook (buf);
1021 if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL) {
1022 menu->current = ci_first_message ();
1026 sidebar_set_current (buf);
1028 mutt_clear_error ();
1029 buffy_check (0); /* force the buffy check after we have changed
1031 menu->redraw = REDRAW_FULL;
1032 set_option (OPTSEARCHINVALID);
1035 case OP_DISPLAY_MESSAGE:
1036 case OP_DISPLAY_HEADERS: /* don't weed the headers */
1041 * toggle the weeding of headers so that a user can press the key
1042 * again while reading the message.
1044 if (op == OP_DISPLAY_HEADERS)
1045 toggle_option (OPTWEED);
1047 unset_option (OPTNEEDRESORT);
1049 if ((Sort & SORT_MASK) == SORT_THREADS && CURHDR->collapsed) {
1050 mutt_uncollapse_thread (Context, CURHDR);
1051 mutt_set_virtual (Context);
1052 if (option (OPTUNCOLLAPSEJUMP))
1053 menu->current = mutt_thread_next_unread (Context, CURHDR);
1056 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1057 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1059 if ((op = mutt_display_message (CURHDR)) == -1) {
1060 unset_option (OPTNEEDRESORT);
1064 menu->menu = MENU_PAGER;
1065 menu->oldcurrent = menu->current;
1070 if (menu->menu == MENU_MAIN && attach_msg) {
1075 if ((menu->menu == MENU_MAIN)
1076 && (query_quadoption2(mod_core.quit,
1077 _("Exit Madmutt without saving?")) == M_YES))
1080 mx_fastclose_mailbox (Context);
1091 mutt_edit_content_type (CURHDR, CURHDR->content, NULL);
1092 /* if we were in the pager, redisplay the message */
1093 if (menu->menu == MENU_PAGER) {
1094 op = OP_DISPLAY_MESSAGE;
1098 menu->redraw = REDRAW_CURRENT;
1101 case OP_MAIN_BREAK_THREAD:
1106 if ((Sort & SORT_MASK) != SORT_THREADS)
1107 mutt_error (_("Threading is not enabled."));
1111 HEADER *oldcur = CURHDR;
1113 mutt_break_thread (CURHDR);
1114 mutt_sort_headers (Context, 1);
1115 menu->current = oldcur->virtual;
1118 Context->changed = 1;
1119 mutt_message _("Thread broken");
1121 if (menu->menu == MENU_PAGER) {
1122 op = OP_DISPLAY_MESSAGE;
1126 menu->redraw |= REDRAW_INDEX;
1130 case OP_MAIN_LINK_THREADS:
1135 if ((Sort & SORT_MASK) != SORT_THREADS)
1136 mutt_error (_("Threading is not enabled."));
1138 else if (!CURHDR->env->message_id)
1139 mutt_error (_("No Message-ID: header available to link thread"));
1141 else if (!tag && (!Context->last_tag || !Context->last_tag->tagged))
1142 mutt_error (_("First, please tag a message to be linked here"));
1145 HEADER *oldcur = CURHDR;
1147 if (mutt_link_threads (CURHDR, tag ? NULL : Context->last_tag,
1149 mutt_sort_headers (Context, 1);
1150 menu->current = oldcur->virtual;
1152 Context->changed = 1;
1153 mutt_message _("Threads linked");
1156 mutt_error (_("No thread linked"));
1159 if (menu->menu == MENU_PAGER) {
1160 op = OP_DISPLAY_MESSAGE;
1164 menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
1167 case OP_MAIN_NEXT_UNDELETED:
1170 if (menu->current >= Context->vcount - 1) {
1171 if (menu->menu == MENU_MAIN)
1172 mutt_error (_("You are on the last message."));
1176 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1177 menu->current = menu->oldcurrent;
1178 if (menu->menu == MENU_MAIN)
1179 mutt_error (_("No undeleted messages."));
1181 else if (menu->menu == MENU_PAGER) {
1182 op = OP_DISPLAY_MESSAGE;
1186 menu->redraw = REDRAW_MOTION;
1192 if (menu->current >= Context->vcount - 1) {
1193 if (menu->menu == MENU_MAIN)
1194 mutt_error (_("You are on the last message."));
1199 if (menu->menu == MENU_PAGER) {
1200 op = OP_DISPLAY_MESSAGE;
1204 menu->redraw = REDRAW_MOTION;
1207 case OP_MAIN_PREV_UNDELETED:
1210 if (menu->current < 1) {
1211 mutt_error (_("You are on the first message."));
1215 if ((menu->current = ci_previous_undeleted (menu->current)) == -1) {
1216 menu->current = menu->oldcurrent;
1217 if (menu->menu == MENU_MAIN)
1218 mutt_error (_("No undeleted messages."));
1220 else if (menu->menu == MENU_PAGER) {
1221 op = OP_DISPLAY_MESSAGE;
1225 menu->redraw = REDRAW_MOTION;
1231 if (menu->current < 1) {
1232 if (menu->menu == MENU_MAIN)
1233 mutt_error (_("You are on the first message."));
1238 if (menu->menu == MENU_PAGER) {
1239 op = OP_DISPLAY_MESSAGE;
1243 menu->redraw = REDRAW_MOTION;
1246 case OP_DECRYPT_COPY:
1247 case OP_DECRYPT_SAVE:
1248 case OP_COPY_MESSAGE:
1250 case OP_DECODE_COPY:
1251 case OP_DECODE_SAVE:
1254 if (mutt_save_message (tag ? NULL : CURHDR,
1255 (op == OP_DECRYPT_SAVE) ||
1256 (op == OP_SAVE) || (op == OP_DECODE_SAVE),
1257 (op == OP_DECODE_SAVE) || (op == OP_DECODE_COPY),
1258 (op == OP_DECRYPT_SAVE)
1259 || (op == OP_DECRYPT_COPY)
1260 || 0, &menu->redraw) == 0 && (op == OP_SAVE
1267 menu->redraw |= REDRAW_INDEX;
1268 else if (option (OPTRESOLVE)) {
1269 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1270 menu->current = menu->oldcurrent;
1271 menu->redraw |= REDRAW_CURRENT;
1274 menu->redraw |= REDRAW_MOTION_RESYNCH;
1277 menu->redraw |= REDRAW_CURRENT;
1281 case OP_MAIN_NEXT_NEW:
1282 case OP_MAIN_NEXT_UNREAD:
1283 case OP_MAIN_PREV_NEW:
1284 case OP_MAIN_PREV_UNREAD:
1285 case OP_MAIN_NEXT_NEW_THEN_UNREAD:
1286 case OP_MAIN_PREV_NEW_THEN_UNREAD:
1288 int first_unread = -1;
1296 for (j = 0; j != Context->vcount; j++) {
1297 #define CURHDRi Context->hdrs[Context->v2r[i]]
1298 if (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_NEXT_UNREAD
1299 || op == OP_MAIN_NEXT_NEW_THEN_UNREAD) {
1301 if (i > Context->vcount - 1) {
1302 mutt_message _("Search wrapped to top.");
1310 mutt_message _("Search wrapped to bottom.");
1312 i = Context->vcount - 1;
1316 if (CURHDRi->collapsed && (Sort & SORT_MASK) == SORT_THREADS) {
1317 if (UNREAD (CURHDRi) && first_unread == -1)
1319 if (UNREAD (CURHDRi) == 1 && first_new == -1)
1322 else if ((!CURHDRi->deleted && !CURHDRi->read)) {
1323 if (first_unread == -1)
1325 if ((!CURHDRi->old) && first_new == -1)
1329 if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD) &&
1332 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1333 op == OP_MAIN_NEXT_NEW_THEN_UNREAD
1334 || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1339 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1340 op == OP_MAIN_NEXT_NEW_THEN_UNREAD
1341 || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1343 menu->current = first_new;
1344 else if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD ||
1345 op == OP_MAIN_NEXT_NEW_THEN_UNREAD
1346 || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1347 && first_unread != -1)
1348 menu->current = first_unread;
1350 if (menu->current == -1) {
1351 menu->current = menu->oldcurrent;
1352 mutt_error ("%s%s.",
1353 (op == OP_MAIN_NEXT_NEW
1355 OP_MAIN_PREV_NEW) ? _("No new messages") :
1356 _("No unread messages"),
1357 Context->pattern ? _(" in this limited view") : "");
1359 else if (menu->menu == MENU_PAGER) {
1360 op = OP_DISPLAY_MESSAGE;
1364 menu->redraw = REDRAW_MOTION;
1367 case OP_FLAG_MESSAGE:
1372 CHECK_MX_ACL (Context, ACL_WRITE, _("Flagging"));
1375 for (j = 0; j < Context->vcount; j++) {
1376 if (Context->hdrs[Context->v2r[j]]->tagged)
1377 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]],
1378 M_FLAG, !Context->hdrs[Context->v2r[j]]->flagged);
1381 menu->redraw |= REDRAW_INDEX;
1384 mutt_set_flag (Context, CURHDR, M_FLAG, !CURHDR->flagged);
1385 if (option (OPTRESOLVE)) {
1386 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1387 menu->current = menu->oldcurrent;
1388 menu->redraw = REDRAW_CURRENT;
1391 menu->redraw = REDRAW_MOTION_RESYNCH;
1394 menu->redraw = REDRAW_CURRENT;
1396 menu->redraw |= REDRAW_STATUS;
1404 CHECK_MX_ACL (Context, ACL_SEEN, _("Toggling"));
1407 for (j = 0; j < Context->vcount; j++) {
1408 if (Context->hdrs[Context->v2r[j]]->tagged) {
1409 if (Context->hdrs[Context->v2r[j]]->read ||
1410 Context->hdrs[Context->v2r[j]]->old)
1411 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_NEW,
1414 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_READ,
1418 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
1421 if (CURHDR->read || CURHDR->old)
1422 mutt_set_flag (Context, CURHDR, M_NEW, 1);
1424 mutt_set_flag (Context, CURHDR, M_READ, 1);
1426 if (option (OPTRESOLVE)) {
1427 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1428 menu->current = menu->oldcurrent;
1429 menu->redraw = REDRAW_CURRENT;
1432 menu->redraw = REDRAW_MOTION_RESYNCH;
1435 menu->redraw = REDRAW_CURRENT;
1436 menu->redraw |= REDRAW_STATUS;
1440 case OP_TOGGLE_WRITE:
1442 if (mx_toggle_write (Context) == 0)
1443 menu->redraw |= REDRAW_STATUS;
1446 case OP_MAIN_NEXT_THREAD:
1447 case OP_MAIN_NEXT_SUBTHREAD:
1448 case OP_MAIN_PREV_THREAD:
1449 case OP_MAIN_PREV_SUBTHREAD:
1453 case OP_MAIN_NEXT_THREAD:
1454 menu->current = mutt_next_thread (CURHDR);
1457 case OP_MAIN_NEXT_SUBTHREAD:
1458 menu->current = mutt_next_subthread (CURHDR);
1461 case OP_MAIN_PREV_THREAD:
1462 menu->current = mutt_previous_thread (CURHDR);
1465 case OP_MAIN_PREV_SUBTHREAD:
1466 menu->current = mutt_previous_subthread (CURHDR);
1470 if (menu->current < 0) {
1471 menu->current = menu->oldcurrent;
1472 if (op == OP_MAIN_NEXT_THREAD || op == OP_MAIN_NEXT_SUBTHREAD)
1473 mutt_error (_("No more threads."));
1476 mutt_error (_("You are on the first thread."));
1478 else if (menu->menu == MENU_PAGER) {
1479 op = OP_DISPLAY_MESSAGE;
1483 menu->redraw = REDRAW_MOTION;
1486 case OP_MAIN_PARENT_MESSAGE:
1490 if ((menu->current = mutt_parent_message (Context, CURHDR)) < 0) {
1491 menu->current = menu->oldcurrent;
1493 else if (menu->menu == MENU_PAGER) {
1494 op = OP_DISPLAY_MESSAGE;
1498 menu->redraw = REDRAW_MOTION;
1501 case OP_MAIN_SET_FLAG:
1502 case OP_MAIN_CLEAR_FLAG:
1507 if (mutt_change_flag (tag ? NULL : CURHDR, (op == OP_MAIN_SET_FLAG)) == 0) {
1508 menu->redraw = REDRAW_STATUS;
1510 menu->redraw |= REDRAW_INDEX;
1511 else if (option (OPTRESOLVE)) {
1512 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1513 menu->current = menu->oldcurrent;
1514 menu->redraw |= REDRAW_CURRENT;
1517 menu->redraw |= REDRAW_MOTION_RESYNCH;
1520 menu->redraw |= REDRAW_CURRENT;
1524 case OP_MAIN_COLLAPSE_THREAD:
1528 if ((Sort & SORT_MASK) != SORT_THREADS) {
1529 mutt_error (_("Threading is not enabled."));
1534 if (CURHDR->collapsed) {
1535 menu->current = mutt_uncollapse_thread (Context, CURHDR);
1536 mutt_set_virtual (Context);
1537 if (option (OPTUNCOLLAPSEJUMP))
1538 menu->current = mutt_thread_next_unread (Context, CURHDR);
1540 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR)) {
1541 menu->current = mutt_collapse_thread (Context, CURHDR);
1542 mutt_set_virtual (Context);
1545 mutt_error (_("Thread contains unread messages."));
1550 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1554 case OP_MAIN_COLLAPSE_ALL:
1558 if ((Sort & SORT_MASK) != SORT_THREADS) {
1559 mutt_error (_("Threading is not enabled."));
1566 THREAD *thread, *top;
1569 if (CURHDR->collapsed)
1570 final = mutt_uncollapse_thread (Context, CURHDR);
1571 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR))
1572 final = mutt_collapse_thread (Context, CURHDR);
1574 final = CURHDR->virtual;
1576 base = Context->hdrs[Context->v2r[final]];
1578 top = Context->tree;
1579 Context->collapsed = !Context->collapsed;
1580 while ((thread = top) != NULL) {
1581 while (!thread->message)
1582 thread = thread->child;
1583 h = thread->message;
1585 if (h->collapsed != Context->collapsed) {
1587 mutt_uncollapse_thread (Context, h);
1588 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (h))
1589 mutt_collapse_thread (Context, h);
1594 mutt_set_virtual (Context);
1595 for (j = 0; j < Context->vcount; j++) {
1596 if (Context->hdrs[Context->v2r[j]]->index == base->index) {
1602 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1606 /* --------------------------------------------------------------------
1607 * These functions are invoked directly from the internal-pager
1610 case OP_BOUNCE_MESSAGE:
1614 ci_bounce_message (tag ? NULL : CURHDR, &menu->redraw);
1617 case OP_CREATE_ALIAS:
1618 mutt_create_alias (Context
1619 && Context->vcount ? CURHDR->env : NULL, NULL);
1620 MAYBE_REDRAW (menu->redraw);
1621 menu->redraw |= REDRAW_CURRENT;
1626 mutt_query_menu (NULL, 0);
1627 MAYBE_REDRAW (menu->redraw);
1630 case OP_PURGE_MESSAGE:
1636 CHECK_MX_ACL (Context, ACL_DELETE, _("Deletion"));
1639 mutt_tag_set_flag (M_DELETE, 1);
1640 mutt_tag_set_flag (M_PURGED, (op != OP_PURGE_MESSAGE) ? 0 : 1);
1641 if (option (OPTDELETEUNTAG))
1642 mutt_tag_set_flag (M_TAG, 0);
1643 menu->redraw = REDRAW_INDEX;
1646 mutt_set_flag (Context, CURHDR, M_DELETE, 1);
1647 mutt_set_flag (Context, CURHDR, M_PURGED,
1648 (op != OP_PURGE_MESSAGE) ? 0 : 1);
1649 if (option (OPTDELETEUNTAG))
1650 mutt_set_flag (Context, CURHDR, M_TAG, 0);
1651 if (option (OPTRESOLVE)) {
1652 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1653 menu->current = menu->oldcurrent;
1654 menu->redraw = REDRAW_CURRENT;
1656 else if (menu->menu == MENU_PAGER) {
1657 op = OP_DISPLAY_MESSAGE;
1661 menu->redraw |= REDRAW_MOTION_RESYNCH;
1664 menu->redraw = REDRAW_CURRENT;
1666 menu->redraw |= REDRAW_STATUS;
1669 case OP_DELETE_THREAD:
1670 case OP_DELETE_SUBTHREAD:
1675 CHECK_MX_ACL (Context, ACL_DELETE, _("Deletion"));
1677 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 1,
1678 op == OP_DELETE_THREAD ? 0 : 1);
1681 if (option (OPTDELETEUNTAG))
1682 mutt_thread_set_flag (CURHDR, M_TAG, 0,
1683 op == OP_DELETE_THREAD ? 0 : 1);
1684 if (option (OPTRESOLVE))
1685 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1686 menu->current = menu->oldcurrent;
1687 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1691 case OP_DISPLAY_ADDRESS:
1694 mutt_display_address (CURHDR->env);
1697 case OP_ENTER_COMMAND:
1698 CurrentMenu = MENU_MAIN;
1699 mutt_enter_command ();
1700 mutt_check_rescore (Context);
1701 if (option (OPTFORCEREDRAWINDEX))
1702 menu->redraw = REDRAW_FULL;
1703 unset_option (OPTFORCEREDRAWINDEX);
1704 unset_option (OPTFORCEREDRAWPAGER);
1707 case OP_EDIT_MESSAGE:
1713 CHECK_MX_ACL (Context, ACL_INSERT, _("Editing"));
1715 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1716 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1717 mutt_edit_message (Context, tag ? NULL : CURHDR);
1718 menu->redraw = REDRAW_FULL;
1722 case OP_FORWARD_MESSAGE:
1727 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1728 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1729 ci_send_message (SENDFORWARD, NULL, NULL, Context, tag ? NULL : CURHDR);
1730 menu->redraw = REDRAW_FULL;
1733 case OP_GROUP_REPLY:
1738 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1739 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1741 ci_send_message (SENDREPLY | SENDGROUPREPLY, NULL, NULL, Context,
1742 tag ? NULL : CURHDR);
1743 menu->redraw = REDRAW_FULL;
1751 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1752 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1754 ci_send_message (SENDREPLY | SENDLISTREPLY, NULL, NULL, Context,
1755 tag ? NULL : CURHDR);
1756 menu->redraw = REDRAW_FULL;
1761 ci_send_message (0, NULL, NULL, Context, NULL);
1762 menu->redraw = REDRAW_FULL;
1765 case OP_EXTRACT_KEYS:
1768 crypt_extract_keys_from_messages (tag ? NULL : CURHDR);
1769 menu->redraw = REDRAW_FULL;
1773 case OP_CHECK_TRADITIONAL:
1776 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1777 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1779 if (menu->menu == MENU_PAGER) {
1780 op = OP_DISPLAY_MESSAGE;
1788 mutt_pipe_message (tag ? NULL : CURHDR);
1789 MAYBE_REDRAW (menu->redraw);
1795 mutt_print_message (tag ? NULL : CURHDR);
1798 case OP_MAIN_READ_THREAD:
1799 case OP_MAIN_READ_SUBTHREAD:
1804 CHECK_MX_ACL (Context, ACL_SEEN, _("Marking as read"));
1806 rc = mutt_thread_set_flag (CURHDR, M_READ, 1,
1807 op == OP_MAIN_READ_THREAD ? 0 : 1);
1810 if (option (OPTRESOLVE)) {
1811 if ((menu->current = (op == OP_MAIN_READ_THREAD ?
1812 mutt_next_thread (CURHDR) :
1813 mutt_next_subthread (CURHDR))) == -1)
1814 menu->current = menu->oldcurrent;
1816 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1820 case OP_RECALL_MESSAGE:
1822 ci_send_message (SENDPOSTPONED, NULL, NULL, Context, NULL);
1823 menu->redraw = REDRAW_FULL;
1832 for (j = 0; j < Context->vcount; j++) {
1833 if (Context->hdrs[Context->v2r[j]]->tagged)
1834 mutt_resend_message (NULL, Context,
1835 Context->hdrs[Context->v2r[j]]);
1839 mutt_resend_message (NULL, Context, CURHDR);
1841 menu->redraw = REDRAW_FULL;
1849 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1850 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1852 ci_send_message (SENDREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
1853 menu->redraw = REDRAW_FULL;
1856 case OP_SHELL_ESCAPE:
1857 mutt_shell_escape ();
1858 MAYBE_REDRAW (menu->redraw);
1862 case OP_TAG_SUBTHREAD:
1865 rc = mutt_thread_set_flag (CURHDR, M_TAG, !CURHDR->tagged,
1866 op == OP_TAG_THREAD ? 0 : 1);
1869 if (option (OPTRESOLVE)) {
1870 menu->current = mutt_next_thread (CURHDR);
1872 if (menu->current == -1)
1873 menu->current = menu->oldcurrent;
1875 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1884 CHECK_MX_ACL (Context, ACL_DELETE, _("Undeletion"));
1887 mutt_tag_set_flag (M_DELETE, 0);
1888 mutt_tag_set_flag (M_PURGED, 0);
1889 menu->redraw = REDRAW_INDEX;
1892 mutt_set_flag (Context, CURHDR, M_DELETE, 0);
1893 mutt_set_flag (Context, CURHDR, M_PURGED, 0);
1894 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1) {
1896 menu->redraw = REDRAW_MOTION_RESYNCH;
1899 menu->redraw = REDRAW_CURRENT;
1901 menu->redraw |= REDRAW_STATUS;
1904 case OP_UNDELETE_THREAD:
1905 case OP_UNDELETE_SUBTHREAD:
1910 CHECK_MX_ACL (Context, ACL_DELETE, _("Undeletion"));
1912 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
1913 op == OP_UNDELETE_THREAD ? 0 : 1)
1914 + mutt_thread_set_flag (CURHDR, M_PURGED, 0,
1915 op == OP_UNDELETE_THREAD ? 0 : 1);
1918 if (option (OPTRESOLVE)) {
1919 if (op == OP_UNDELETE_THREAD)
1920 menu->current = mutt_next_thread (CURHDR);
1922 menu->current = mutt_next_subthread (CURHDR);
1924 if (menu->current == -1)
1925 menu->current = menu->oldcurrent;
1927 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1932 if (option (OPTFORCEBUFFYCHECK))
1935 menu->redraw = REDRAW_FULL;
1938 case OP_VIEW_ATTACHMENTS:
1941 mutt_view_attachments (CURHDR);
1942 if (CURHDR->attach_del)
1943 Context->changed = 1;
1944 menu->redraw = REDRAW_FULL;
1950 case OP_SIDEBAR_SCROLL_UP:
1951 case OP_SIDEBAR_SCROLL_DOWN:
1952 case OP_SIDEBAR_NEXT:
1953 case OP_SIDEBAR_PREV:
1954 case OP_SIDEBAR_NEXT_NEW:
1955 case OP_SIDEBAR_PREV_NEW:
1956 sidebar_scroll (op);
1960 if (menu->menu == MENU_MAIN)
1961 km_error_key (MENU_MAIN);
1964 if (menu->menu == MENU_PAGER) {
1965 menu->menu = MENU_MAIN;
1966 menu->redraw = REDRAW_FULL;
1974 /* Close all open IMAP connections */
1978 mutt_menuDestroy (&menu);
1982 void mutt_set_header_color (CONTEXT * ctx, HEADER * curhdr)
1989 for (color = ColorIndexList; color; color = color->next)
1990 if (mutt_pattern_exec
1991 (color->color_pattern, M_MATCH_FULL_ADDRESS, ctx, curhdr)) {
1992 curhdr->pair = color->pair;
1995 curhdr->pair = ColorDefs[MT_COLOR_NORMAL];