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>
15 #include <lib-mx/pop.h>
16 #include <imap/imap.h>
25 #include "recvattach.h"
30 static const char *No_mailbox_is_open = N_("No mailbox is open.");
31 static const char *There_are_no_messages = N_("There are no messages.");
32 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
33 static const char *Function_not_permitted_in_attach_message_mode =
34 N_("Function not permitted in attach-message mode.");
35 static const char *No_visible = N_("No visible messages.");
37 #define CHECK_IN_MAILBOX if (!Context) \
40 mutt_error (_(No_mailbox_is_open)); \
44 #define CHECK_MSGCOUNT if (!Context) \
47 mutt_error(_(No_mailbox_is_open)); \
50 else if (!Context->msgcount) \
53 mutt_error(_(There_are_no_messages)); \
57 #define CHECK_VISIBLE if (Context && menu->current >= Context->vcount) \
60 mutt_error(_(No_visible)); \
65 #define CHECK_READONLY if (Context->readonly) \
68 mutt_error(_(Mailbox_is_read_only)); \
72 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
75 mutt_error(_(Function_not_permitted_in_attach_message_mode)); \
79 #define CURHDR Context->hdrs[Context->v2r[menu->current]]
80 #define OLDHDR Context->hdrs[Context->v2r[menu->oldcurrent]]
81 #define UNREAD(h) mutt_thread_contains_unread (Context, h)
83 extern size_t UngetCount;
85 void index_make_entry (char *s, ssize_t l, struct menu_t * menu, int num)
87 format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_INDEX;
88 int edgemsgno, reverse = Sort & SORT_REVERSE;
89 HEADER *h = Context->hdrs[Context->v2r[num]];
92 if ((Sort & SORT_MASK) == SORT_THREADS && h->tree) {
93 flag |= M_FORMAT_TREE; /* display the thread tree */
94 if (h->display_subject)
95 flag |= M_FORMAT_FORCESUBJ;
98 if (menu->top + menu->pagelen > menu->max)
99 edgemsgno = Context->v2r[menu->max - 1];
101 edgemsgno = Context->v2r[menu->top + menu->pagelen - 1];
104 edgemsgno = Context->v2r[menu->top];
106 for (tmp = h->thread->parent; tmp; tmp = tmp->parent) {
110 /* if no ancestor is visible on current screen, provisionally force
112 if (reverse ? tmp->message->msgno > edgemsgno : tmp->message->msgno <
114 flag |= M_FORMAT_FORCESUBJ;
117 else if (tmp->message->virtual >= 0)
120 if (flag & M_FORMAT_FORCESUBJ) {
121 for (tmp = h->thread->prev; tmp; tmp = tmp->prev) {
125 /* ...but if a previous sibling is available, don't force it */
126 if (reverse ? tmp->message->msgno >
127 edgemsgno : tmp->message->msgno < edgemsgno)
129 else if (tmp->message->virtual >= 0) {
130 flag &= ~M_FORMAT_FORCESUBJ;
138 _mutt_make_string (s, l, NONULL (HdrFmt), Context, h, flag);
141 int index_color (int index_no)
143 HEADER *h = Context->hdrs[Context->v2r[index_no]];
148 mutt_set_header_color (Context, h);
152 static int ci_next_undeleted (int msgno)
156 for (i = msgno + 1; i < Context->vcount; i++)
157 if (!Context->hdrs[Context->v2r[i]]->deleted)
162 static int ci_previous_undeleted (int msgno)
166 for (i = msgno - 1; i >= 0; i--)
167 if (!Context->hdrs[Context->v2r[i]]->deleted)
172 /* Return the index of the first new message, or failing that, the first
175 static int ci_first_message (void)
179 if (Context && Context->msgcount) {
180 for (i = 0; i < Context->vcount; i++) {
181 if (!Context->hdrs[Context->v2r[i]]->read &&
182 !Context->hdrs[Context->v2r[i]]->deleted) {
183 if (!Context->hdrs[Context->v2r[i]]->old)
192 /* If Sort is reverse and not threaded, the latest message is first.
193 * If Sort is threaded, the latest message is first iff exactly one
194 * of Sort and SortAux are reverse.
196 if (((Sort & SORT_REVERSE) && (Sort & SORT_MASK) != SORT_THREADS) ||
197 ((Sort & SORT_MASK) == SORT_THREADS &&
198 ((Sort ^ SortAux) & SORT_REVERSE)))
201 return Context->vcount ? Context->vcount - 1 : 0;
206 /* This should be in mx.c, but it only gets used here. */
207 static int mx_toggle_write (CONTEXT * ctx)
213 mutt_error (_("Cannot toggle write on a readonly mailbox!"));
218 if (ctx->dontwrite) {
220 mutt_message (_("Changes to folder will be written on folder exit."));
224 mutt_message (_("Changes to folder will not be written."));
230 static void update_index (MUTTMENU * menu, CONTEXT * ctx __attribute__ ((unused)), int check,
231 int oldcount, int index_hint)
233 /* store pointers to the newly added messages */
234 HEADER **save_new = NULL;
237 /* take note of the current message */
239 if (menu->current < Context->vcount)
240 menu->oldcurrent = index_hint;
242 oldcount = 0; /* invalid message number! */
245 /* We are in a limited view. Check if the new message(s) satisfy
246 * the limit criteria. If they do, set their virtual msgno so that
247 * they will be visible in the limited view */
248 if (Context->pattern) {
249 #define THIS_BODY Context->hdrs[j]->content
250 for (j = (check == M_REOPENED) ? 0 : oldcount; j < Context->msgcount; j++) {
251 if (mutt_pattern_exec
252 (Context->limit_pattern, M_MATCH_FULL_ADDRESS, Context,
254 Context->hdrs[j]->virtual = Context->vcount;
255 Context->v2r[Context->vcount] = j;
256 Context->hdrs[j]->limited = 1;
259 THIS_BODY->length + THIS_BODY->offset - THIS_BODY->hdr_offset;
265 /* save the list of new messages */
266 if (oldcount && check != M_REOPENED && ((Sort & SORT_MASK) == SORT_THREADS)) {
267 save_new = p_new(HEADER*, Context->msgcount - oldcount);
268 for (j = oldcount; j < Context->msgcount; j++)
269 save_new[j - oldcount] = Context->hdrs[j];
272 /* if the mailbox was reopened, need to rethread from scratch */
273 mutt_sort_headers (Context, (check == M_REOPENED));
275 /* uncollapse threads with new mail */
276 if ((Sort & SORT_MASK) == SORT_THREADS) {
277 if (check == M_REOPENED) {
280 Context->collapsed = 0;
282 for (h = Context->tree; h; h = h->next) {
283 for (c = h; !c->message; c = c->child);
284 mutt_uncollapse_thread (Context, c->message);
286 mutt_set_virtual (Context);
289 for (j = 0; j < Context->msgcount - oldcount; j++) {
292 for (k = 0; k < Context->msgcount; k++) {
293 HEADER *h = Context->hdrs[k];
295 if (h == save_new[j] && (!Context->pattern || h->limited))
296 mutt_uncollapse_thread (Context, h);
300 mutt_set_virtual (Context);
306 /* restore the current message to the message it was pointing to */
307 for (j = 0; j < Context->vcount; j++) {
308 if (Context->hdrs[Context->v2r[j]]->index == menu->oldcurrent) {
315 if (menu->current < 0)
316 menu->current = ci_first_message ();
319 static void resort_index (MUTTMENU * menu)
322 HEADER *current = CURHDR;
325 mutt_sort_headers (Context, 0);
326 /* Restore the current message */
328 for (i = 0; i < Context->vcount; i++) {
329 if (Context->hdrs[Context->v2r[i]] == current) {
335 if ((Sort & SORT_MASK) == SORT_THREADS && menu->current < 0)
336 menu->current = mutt_parent_message (Context, current);
338 if (menu->current < 0)
339 menu->current = ci_first_message ();
341 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
344 /* This function handles the message index window as well as commands returned
345 * from the pager (MENU_PAGER).
347 int mutt_index_menu (void)
349 char buf[LONG_STRING];
352 int done = 0; /* controls when to exit the "event" loop */
354 int tag = 0; /* has the tag-prefix command been pressed? */
359 const char *cp; /* temporary variable. */
360 int index_hint; /* used to restore cursor position */
361 int do_buffy_notify = 1;
362 int closed = 0; /* did we OP_QUIT or OP_EXIT out of this menu? */
363 int attach_msg = option (OPTATTACHMSG);
365 menu = mutt_new_menu ();
366 menu->menu = MENU_MAIN;
368 menu->pagelen = LINES - 3;
369 menu->make_entry = (void *) index_make_entry;
370 menu->color = index_color;
371 menu->current = ci_first_message ();
374 buffy_check (0); /* force the buffy check after we enter the folder */
375 /* record folder we open to place sidebar indicator properly */
376 if (Context && Context->path)
377 sidebar_set_current (Context->path);
381 tag = 0; /* clear the tag-prefix */
383 menu->max = Context ? Context->vcount : 0;
384 oldcount = Context ? Context->msgcount : 0;
386 /* check if we need to resort the index because just about
387 * any 'op' below could do mutt_enter_command(), either here or
388 * from any new menu launched, and change $sort/$sort_aux
390 if (option (OPTNEEDRESORT) && Context && Context->msgcount)
393 if (option (OPTREDRAWTREE) && Context && Context->msgcount
394 && (Sort & SORT_MASK) == SORT_THREADS) {
395 mutt_draw_tree (Context);
396 menu->redraw |= REDRAW_STATUS;
397 unset_option (OPTREDRAWTREE);
400 if (Context && !attach_msg) {
403 /* check for new mail in the mailbox. If nonzero, then something has
404 * changed about the file (either we got new mail or the file was
405 * modified underneath us.)
408 imap_allow_reopen (Context);
410 index_hint = (Context->vcount && menu->current >= 0
411 && menu->current < Context->vcount) ? CURHDR->index : 0;
413 if ((check = mx_check_mailbox (Context, &index_hint, 0)) < 0) {
414 if (!Context->path) {
415 /* fatal error occurred */
417 menu->redraw = REDRAW_FULL;
419 set_option (OPTSEARCHINVALID);
421 else if (check == M_NEW_MAIL || check == M_REOPENED || check == M_FLAGS) {
422 update_index (menu, Context, check, oldcount, index_hint);
424 /* notify the user of new mail */
425 if (check == M_REOPENED)
427 ("Mailbox was externally modified. Flags may be wrong."));
428 else if (check == M_NEW_MAIL) {
429 /* on new mail: redraw sidebar */
431 mutt_message (_("New mail in this mailbox."));
433 if (mod_core.beep_new)
436 else if (check == M_FLAGS)
437 mutt_message (_("Mailbox was externally modified."));
439 /* avoid the message being overwritten by buffy */
442 menu->redraw = REDRAW_FULL;
443 menu->max = Context->vcount;
445 set_option (OPTSEARCHINVALID);
450 imap_disallow_reopen (Context);
453 /* check for new mail in the incoming folders */
455 if ((newcount = buffy_check (0)) != oldcount) {
456 menu->redraw |= REDRAW_STATUS;
457 menu->redraw |= REDRAW_SIDEBAR;
459 if (do_buffy_notify) {
460 if (buffy_notify () && mod_core.beep_new)
469 if (menu->redraw & REDRAW_SIDEBAR)
471 if (menu->redraw & REDRAW_FULL) {
472 menu_redraw_full (menu);
477 if (menu->menu == MENU_MAIN) {
478 if (Context && Context->hdrs && !(menu->current >= Context->vcount)) {
479 menu_check_recenter (menu);
481 if (menu->redraw & REDRAW_INDEX) {
482 menu_redraw_index (menu);
483 menu->redraw |= REDRAW_STATUS;
485 else if (menu->redraw & (REDRAW_MOTION_RESYNCH | REDRAW_MOTION))
486 menu_redraw_motion (menu);
487 else if (menu->redraw & REDRAW_CURRENT)
488 menu_redraw_current (menu);
491 if (menu->redraw & REDRAW_STATUS) {
492 menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
493 CLEARLINE(main_w, 0);
494 SETCOLOR(main_w, MT_COLOR_STATUS);
495 BKGDSET(main_w, MT_COLOR_STATUS);
497 mutt_paddstr (main_w, getmaxx(main_w), buf);
498 SETCOLOR(main_w, MT_COLOR_NORMAL);
499 BKGDSET(main_w, MT_COLOR_NORMAL);
500 sidebar_set_buffystats (Context);
501 menu->redraw &= ~REDRAW_STATUS;
502 if (option (OPTXTERMSETTITLES)) {
503 menu_status_line(buf, sizeof(buf), menu, NONULL(XtermTitle));
504 printf("\033]2;%s\007", buf);
505 menu_status_line(buf, sizeof(buf), menu, NONULL(XtermIcon));
506 printf("\033]1;%s\007", buf);
512 if (menu->current < menu->max)
513 menu->oldcurrent = menu->current;
515 menu->oldcurrent = -1;
521 menu->redraw = REDRAW_FULL;
522 menu->menu = MENU_MAIN;
523 menu->top = 0; /* so we scroll the right amount */
527 op = km_dokey (MENU_MAIN);
529 continue; /* either user abort or timeout */
533 /* special handling for the tag-prefix function */
534 if (op == OP_TAG_PREFIX) {
536 mutt_error (_("No mailbox is open."));
541 if (!Context->tagged) {
542 mutt_error (_("No tagged messages."));
548 /* give visual indication that the next command is a tag- command */
549 mvwaddstr (stdscr, LINES - 1, 0, "tag-");
552 /* get the real command */
553 if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX) {
554 /* abort tag sequence */
555 CLEARLINE(stdscr, LINES - 1);
559 else if (option (OPTAUTOTAG) && Context && Context->tagged)
562 if (op == OP_TAG_PREFIX_COND) {
564 mutt_error (_("No mailbox is open."));
569 if (!Context->tagged) {
572 while (UngetCount > 0) {
574 if (tmp.op == OP_END_COND)
577 mutt_message (_("Nothing to do."));
583 /* give visual indication that the next command is a tag- command */
584 mvwaddstr (stdscr, LINES - 1, 0, "tag-");
587 /* get the real command */
588 if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX) {
589 /* abort tag sequence */
590 CLEARLINE(stdscr, LINES - 1);
597 if (menu->current < menu->max)
598 menu->oldcurrent = menu->current;
600 menu->oldcurrent = -1;
602 mutt_curs_set (1); /* fallback from the pager */
607 /* ----------------------------------------------------------------------
612 menu_bottom_page (menu);
615 menu_first_entry (menu);
618 menu_middle_page (menu);
624 menu_half_down (menu);
627 menu_next_line (menu);
630 menu_prev_line (menu);
633 menu_next_page (menu);
636 menu_prev_page (menu);
639 menu_last_entry (menu);
642 menu_top_page (menu);
645 menu_current_top (menu);
647 case OP_CURRENT_MIDDLE:
648 menu_current_middle (menu);
650 case OP_CURRENT_BOTTOM:
651 menu_current_bottom (menu);
657 if (isdigit (LastKey))
658 mutt_ungetch (LastKey, 0);
660 if (mutt_get_field (_("Jump to message: "), buf, sizeof (buf), 0) != 0
664 if (!isdigit ((unsigned char) buf[0])) {
665 mutt_error (_("Argument must be a message number."));
671 if (i > 0 && i <= Context->msgcount) {
672 for (j = i - 1; j < Context->msgcount; j++) {
673 if (Context->hdrs[j]->virtual != -1)
676 if (j >= Context->msgcount) {
677 for (j = i - 2; j >= 0; j--) {
678 if (Context->hdrs[j]->virtual != -1)
684 menu->current = Context->hdrs[j]->virtual;
685 if (menu->menu == MENU_PAGER) {
686 op = OP_DISPLAY_MESSAGE;
690 menu->redraw = REDRAW_MOTION;
693 mutt_error (_("That message is not visible."));
696 mutt_error (_("Invalid message number."));
700 /* --------------------------------------------------------------------
701 * `index' specific commands
704 case OP_MAIN_DELETE_PATTERN:
709 CHECK_MX_ACL (Context, ACL_DELETE, _("Deletion"));
712 mutt_pattern_func (M_DELETE, _("Delete messages matching: "));
713 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
716 case OP_MAIN_FETCH_MAIL:
719 menu->redraw = REDRAW_FULL;
723 mutt_help (MENU_MAIN);
724 menu->redraw = REDRAW_FULL;
727 case OP_MAIN_SHOW_LIMIT:
729 if (!Context->pattern)
730 mutt_message (_("No limit pattern is in effect."));
735 /* i18n: ask for a limit to apply */
736 snprintf (buffer, sizeof (buffer), _("Limit: %s"), Context->pattern);
737 mutt_message ("%s", buffer);
744 menu->oldcurrent = (Context->vcount && menu->current >= 0
746 Context->vcount) ? CURHDR->index : -1;
747 if (op == OP_TOGGLE_READ) {
748 char buffer[LONG_STRING];
750 if (m_strncmp (Context->pattern, "!~R!~D~s", 8) != 0) {
751 snprintf (buffer, sizeof (buffer), "!~R!~D~s%s",
752 Context->pattern ? Context->pattern : ".*");
753 set_option (OPTHIDEREAD);
756 m_strcpy(buf, sizeof(buf), Context->pattern + 8);
757 if (m_strncmp (buf, ".*", 2) == 0)
758 snprintf (buf, sizeof (buf), "~A");
759 unset_option (OPTHIDEREAD);
761 p_delete(&Context->pattern);
762 Context->pattern = m_strdup(buf);
764 if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
765 mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
767 if (menu->oldcurrent >= 0) {
768 /* try to find what used to be the current message */
770 for (i = 0; i < Context->vcount; i++)
771 if (Context->hdrs[Context->v2r[i]]->index == menu->oldcurrent) {
775 if (menu->current < 0)
780 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
781 if (Context->msgcount && (Sort & SORT_MASK) == SORT_THREADS)
782 mutt_draw_tree (Context);
783 menu->redraw = REDRAW_FULL;
785 if (Context->pattern)
786 mutt_message _("To view all messages, limit to \"all\".");
796 if (query_quadoption2(mod_core.quit, _("Quit Madmutt?")) == M_YES) {
799 oldcount = Context ? Context->msgcount : 0;
802 || (check = mx_close_mailbox (Context, &index_hint)) == 0)
805 if (check == M_NEW_MAIL || check == M_REOPENED)
806 update_index (menu, Context, check, oldcount, index_hint);
808 menu->redraw = REDRAW_FULL; /* new mail arrived? */
809 set_option (OPTSEARCHINVALID);
815 clearok (main_w, TRUE);
816 menu->redraw = REDRAW_FULL;
820 case OP_SEARCH_REVERSE:
822 case OP_SEARCH_OPPOSITE:
825 if ((menu->current = mutt_search_command (menu->current, op)) == -1)
826 menu->current = menu->oldcurrent;
828 menu->redraw = REDRAW_MOTION;
832 case OP_SORT_REVERSE:
833 if (mutt_select_sort ((op == OP_SORT_REVERSE)) == 0) {
834 if (Context && Context->msgcount) {
836 set_option (OPTSEARCHINVALID);
844 if (tag && !option (OPTAUTOTAG)) {
845 for (j = 0; j < Context->vcount; j++)
846 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_TAG, 0);
847 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
850 mutt_set_flag (Context, CURHDR, M_TAG, !CURHDR->tagged);
851 Context->last_tag = CURHDR->tagged ? CURHDR :
852 ((Context->last_tag == CURHDR && !CURHDR->tagged)
853 ? NULL : Context->last_tag);
854 menu->redraw = REDRAW_STATUS;
855 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1) {
857 menu->redraw |= REDRAW_MOTION_RESYNCH;
860 menu->redraw |= REDRAW_CURRENT;
864 case OP_MAIN_TAG_PATTERN:
867 mutt_pattern_func (M_TAG, _("Tag messages matching: "));
868 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
871 case OP_MAIN_UNDELETE_PATTERN:
876 CHECK_MX_ACL (Context, ACL_DELETE, _("Undeletion"));
878 if (mutt_pattern_func (M_UNDELETE, _("Undelete messages matching: ")) ==
880 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
883 case OP_MAIN_UNTAG_PATTERN:
886 if (mutt_pattern_func (M_UNTAG, _("Untag messages matching: ")) == 0)
887 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
890 /* --------------------------------------------------------------------
891 * The following operations can be performed inside of the pager.
894 case OP_MAIN_IMAP_FETCH:
895 if (Context->magic == M_IMAP)
896 imap_check_mailbox (Context, &index_hint, 1);
899 case OP_MAIN_SYNC_FOLDER:
900 if (Context && !Context->msgcount)
907 int oldvcount = Context->vcount;
908 oldcount = Context->msgcount;
912 /* calculate the number of messages _above_ the cursor,
913 * so we can keep the cursor on the current message
915 for (j = 0; j <= menu->current; j++) {
916 if (Context->hdrs[Context->v2r[j]]->deleted)
920 if ((check = mx_sync_mailbox (Context, &index_hint)) == 0) {
921 if (Context->vcount != oldvcount)
922 menu->current -= dcount;
923 set_option (OPTSEARCHINVALID);
925 else if (check == M_NEW_MAIL || check == M_REOPENED)
926 update_index (menu, Context, check, oldcount, index_hint);
929 * do a sanity check even if mx_sync_mailbox failed.
932 if (menu->current < 0 || menu->current >= Context->vcount)
933 menu->current = ci_first_message ();
936 /* check for a fatal error, or all messages deleted */
940 /* if we were in the pager, redisplay the message */
941 if (menu->menu == MENU_PAGER) {
942 op = OP_DISPLAY_MESSAGE;
946 menu->redraw = REDRAW_FULL;
949 case OP_SIDEBAR_OPEN:
950 case OP_MAIN_CHANGE_FOLDER:
951 case OP_MAIN_CHANGE_FOLDER_READONLY:
952 if (attach_msg || op == OP_MAIN_CHANGE_FOLDER_READONLY)
958 cp = _("Open mailbox in read-only mode");
960 cp = _("Open mailbox");
963 if (Context && Context->path)
964 m_strcpy(buf, sizeof(buf), Context->path);
965 if (op != OP_SIDEBAR_OPEN)
966 buffy_next (buf, sizeof (buf));
968 if (op == OP_SIDEBAR_OPEN) {
969 m_strcpy(buf, sizeof(buf), sidebar_get_current());
971 else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) {
972 if (menu->menu == MENU_PAGER) {
973 op = OP_DISPLAY_MESSAGE;
979 CLEARLINE(main_w, LINES - 1);
983 mutt_expand_path (buf, sizeof (buf));
984 if (mx_get_magic (buf) <= 0) {
985 mutt_error (_("%s is not a mailbox."), buf);
988 m_strreplace(&CurrentFolder, buf);
993 if (Context->cinfo && Context->realpath)
994 m_strreplace(&LastFolder, Context->realpath);
996 m_strreplace(&LastFolder, Context->path);
997 oldcount = Context ? Context->msgcount : 0;
999 if ((check = mx_close_mailbox (Context, &index_hint)) != 0) {
1000 if (check == M_NEW_MAIL || check == M_REOPENED)
1001 update_index (menu, Context, check, oldcount, index_hint);
1003 set_option (OPTSEARCHINVALID);
1004 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1012 /* Set CurrentMenu to MENU_MAIN before executing any folder
1013 * hooks so that all the index menu functions are available to
1017 CurrentMenu = MENU_MAIN;
1018 mutt_folder_hook (buf);
1020 if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL) {
1021 menu->current = ci_first_message ();
1025 sidebar_set_current (buf);
1027 mutt_clear_error ();
1028 buffy_check (0); /* force the buffy check after we have changed
1030 menu->redraw = REDRAW_FULL;
1031 set_option (OPTSEARCHINVALID);
1034 case OP_DISPLAY_MESSAGE:
1035 case OP_DISPLAY_HEADERS: /* don't weed the headers */
1040 * toggle the weeding of headers so that a user can press the key
1041 * again while reading the message.
1043 if (op == OP_DISPLAY_HEADERS)
1044 toggle_option (OPTWEED);
1046 unset_option (OPTNEEDRESORT);
1048 if ((Sort & SORT_MASK) == SORT_THREADS && CURHDR->collapsed) {
1049 mutt_uncollapse_thread (Context, CURHDR);
1050 mutt_set_virtual (Context);
1051 if (option (OPTUNCOLLAPSEJUMP))
1052 menu->current = mutt_thread_next_unread (Context, CURHDR);
1055 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1056 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1058 if ((op = mutt_display_message (CURHDR)) == -1) {
1059 unset_option (OPTNEEDRESORT);
1063 menu->menu = MENU_PAGER;
1064 menu->oldcurrent = menu->current;
1069 if (menu->menu == MENU_MAIN && attach_msg) {
1074 if ((menu->menu == MENU_MAIN)
1075 && (query_quadoption2(mod_core.quit,
1076 _("Exit Madmutt without saving?")) == M_YES))
1079 mx_fastclose_mailbox (Context);
1090 mutt_edit_content_type (CURHDR, CURHDR->content, NULL);
1091 /* if we were in the pager, redisplay the message */
1092 if (menu->menu == MENU_PAGER) {
1093 op = OP_DISPLAY_MESSAGE;
1097 menu->redraw = REDRAW_CURRENT;
1100 case OP_MAIN_BREAK_THREAD:
1105 if ((Sort & SORT_MASK) != SORT_THREADS)
1106 mutt_error (_("Threading is not enabled."));
1110 HEADER *oldcur = CURHDR;
1112 mutt_break_thread (CURHDR);
1113 mutt_sort_headers (Context, 1);
1114 menu->current = oldcur->virtual;
1117 Context->changed = 1;
1118 mutt_message _("Thread broken");
1120 if (menu->menu == MENU_PAGER) {
1121 op = OP_DISPLAY_MESSAGE;
1125 menu->redraw |= REDRAW_INDEX;
1129 case OP_MAIN_LINK_THREADS:
1134 if ((Sort & SORT_MASK) != SORT_THREADS)
1135 mutt_error (_("Threading is not enabled."));
1137 else if (!CURHDR->env->message_id)
1138 mutt_error (_("No Message-ID: header available to link thread"));
1140 else if (!tag && (!Context->last_tag || !Context->last_tag->tagged))
1141 mutt_error (_("First, please tag a message to be linked here"));
1144 HEADER *oldcur = CURHDR;
1146 if (mutt_link_threads (CURHDR, tag ? NULL : Context->last_tag,
1148 mutt_sort_headers (Context, 1);
1149 menu->current = oldcur->virtual;
1151 Context->changed = 1;
1152 mutt_message _("Threads linked");
1155 mutt_error (_("No thread linked"));
1158 if (menu->menu == MENU_PAGER) {
1159 op = OP_DISPLAY_MESSAGE;
1163 menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
1166 case OP_MAIN_NEXT_UNDELETED:
1169 if (menu->current >= Context->vcount - 1) {
1170 if (menu->menu == MENU_MAIN)
1171 mutt_error (_("You are on the last message."));
1175 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1176 menu->current = menu->oldcurrent;
1177 if (menu->menu == MENU_MAIN)
1178 mutt_error (_("No undeleted messages."));
1180 else if (menu->menu == MENU_PAGER) {
1181 op = OP_DISPLAY_MESSAGE;
1185 menu->redraw = REDRAW_MOTION;
1191 if (menu->current >= Context->vcount - 1) {
1192 if (menu->menu == MENU_MAIN)
1193 mutt_error (_("You are on the last message."));
1198 if (menu->menu == MENU_PAGER) {
1199 op = OP_DISPLAY_MESSAGE;
1203 menu->redraw = REDRAW_MOTION;
1206 case OP_MAIN_PREV_UNDELETED:
1209 if (menu->current < 1) {
1210 mutt_error (_("You are on the first message."));
1214 if ((menu->current = ci_previous_undeleted (menu->current)) == -1) {
1215 menu->current = menu->oldcurrent;
1216 if (menu->menu == MENU_MAIN)
1217 mutt_error (_("No undeleted messages."));
1219 else if (menu->menu == MENU_PAGER) {
1220 op = OP_DISPLAY_MESSAGE;
1224 menu->redraw = REDRAW_MOTION;
1230 if (menu->current < 1) {
1231 if (menu->menu == MENU_MAIN)
1232 mutt_error (_("You are on the first message."));
1237 if (menu->menu == MENU_PAGER) {
1238 op = OP_DISPLAY_MESSAGE;
1242 menu->redraw = REDRAW_MOTION;
1245 case OP_DECRYPT_COPY:
1246 case OP_DECRYPT_SAVE:
1247 case OP_COPY_MESSAGE:
1249 case OP_DECODE_COPY:
1250 case OP_DECODE_SAVE:
1253 if (mutt_save_message (tag ? NULL : CURHDR,
1254 (op == OP_DECRYPT_SAVE) ||
1255 (op == OP_SAVE) || (op == OP_DECODE_SAVE),
1256 (op == OP_DECODE_SAVE) || (op == OP_DECODE_COPY),
1257 (op == OP_DECRYPT_SAVE)
1258 || (op == OP_DECRYPT_COPY)
1259 || 0, &menu->redraw) == 0 && (op == OP_SAVE
1266 menu->redraw |= REDRAW_INDEX;
1267 else if (option (OPTRESOLVE)) {
1268 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1269 menu->current = menu->oldcurrent;
1270 menu->redraw |= REDRAW_CURRENT;
1273 menu->redraw |= REDRAW_MOTION_RESYNCH;
1276 menu->redraw |= REDRAW_CURRENT;
1280 case OP_MAIN_NEXT_NEW:
1281 case OP_MAIN_NEXT_UNREAD:
1282 case OP_MAIN_PREV_NEW:
1283 case OP_MAIN_PREV_UNREAD:
1284 case OP_MAIN_NEXT_NEW_THEN_UNREAD:
1285 case OP_MAIN_PREV_NEW_THEN_UNREAD:
1287 int first_unread = -1;
1295 for (j = 0; j != Context->vcount; j++) {
1296 #define CURHDRi Context->hdrs[Context->v2r[i]]
1297 if (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_NEXT_UNREAD
1298 || op == OP_MAIN_NEXT_NEW_THEN_UNREAD) {
1300 if (i > Context->vcount - 1) {
1301 mutt_message _("Search wrapped to top.");
1309 mutt_message _("Search wrapped to bottom.");
1311 i = Context->vcount - 1;
1315 if (CURHDRi->collapsed && (Sort & SORT_MASK) == SORT_THREADS) {
1316 if (UNREAD (CURHDRi) && first_unread == -1)
1318 if (UNREAD (CURHDRi) == 1 && first_new == -1)
1321 else if ((!CURHDRi->deleted && !CURHDRi->read)) {
1322 if (first_unread == -1)
1324 if ((!CURHDRi->old) && first_new == -1)
1328 if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD) &&
1331 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1332 op == OP_MAIN_NEXT_NEW_THEN_UNREAD
1333 || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1338 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1339 op == OP_MAIN_NEXT_NEW_THEN_UNREAD
1340 || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1342 menu->current = first_new;
1343 else if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD ||
1344 op == OP_MAIN_NEXT_NEW_THEN_UNREAD
1345 || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1346 && first_unread != -1)
1347 menu->current = first_unread;
1349 if (menu->current == -1) {
1350 menu->current = menu->oldcurrent;
1351 mutt_error ("%s%s.",
1352 (op == OP_MAIN_NEXT_NEW
1354 OP_MAIN_PREV_NEW) ? _("No new messages") :
1355 _("No unread messages"),
1356 Context->pattern ? _(" in this limited view") : "");
1358 else if (menu->menu == MENU_PAGER) {
1359 op = OP_DISPLAY_MESSAGE;
1363 menu->redraw = REDRAW_MOTION;
1366 case OP_FLAG_MESSAGE:
1371 CHECK_MX_ACL (Context, ACL_WRITE, _("Flagging"));
1374 for (j = 0; j < Context->vcount; j++) {
1375 if (Context->hdrs[Context->v2r[j]]->tagged)
1376 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]],
1377 M_FLAG, !Context->hdrs[Context->v2r[j]]->flagged);
1380 menu->redraw |= REDRAW_INDEX;
1383 mutt_set_flag (Context, CURHDR, M_FLAG, !CURHDR->flagged);
1384 if (option (OPTRESOLVE)) {
1385 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1386 menu->current = menu->oldcurrent;
1387 menu->redraw = REDRAW_CURRENT;
1390 menu->redraw = REDRAW_MOTION_RESYNCH;
1393 menu->redraw = REDRAW_CURRENT;
1395 menu->redraw |= REDRAW_STATUS;
1403 CHECK_MX_ACL (Context, ACL_SEEN, _("Toggling"));
1406 for (j = 0; j < Context->vcount; j++) {
1407 if (Context->hdrs[Context->v2r[j]]->tagged) {
1408 if (Context->hdrs[Context->v2r[j]]->read ||
1409 Context->hdrs[Context->v2r[j]]->old)
1410 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_NEW,
1413 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_READ,
1417 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
1420 if (CURHDR->read || CURHDR->old)
1421 mutt_set_flag (Context, CURHDR, M_NEW, 1);
1423 mutt_set_flag (Context, CURHDR, M_READ, 1);
1425 if (option (OPTRESOLVE)) {
1426 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1427 menu->current = menu->oldcurrent;
1428 menu->redraw = REDRAW_CURRENT;
1431 menu->redraw = REDRAW_MOTION_RESYNCH;
1434 menu->redraw = REDRAW_CURRENT;
1435 menu->redraw |= REDRAW_STATUS;
1439 case OP_TOGGLE_WRITE:
1441 if (mx_toggle_write (Context) == 0)
1442 menu->redraw |= REDRAW_STATUS;
1445 case OP_MAIN_NEXT_THREAD:
1446 case OP_MAIN_NEXT_SUBTHREAD:
1447 case OP_MAIN_PREV_THREAD:
1448 case OP_MAIN_PREV_SUBTHREAD:
1452 case OP_MAIN_NEXT_THREAD:
1453 menu->current = mutt_next_thread (CURHDR);
1456 case OP_MAIN_NEXT_SUBTHREAD:
1457 menu->current = mutt_next_subthread (CURHDR);
1460 case OP_MAIN_PREV_THREAD:
1461 menu->current = mutt_previous_thread (CURHDR);
1464 case OP_MAIN_PREV_SUBTHREAD:
1465 menu->current = mutt_previous_subthread (CURHDR);
1469 if (menu->current < 0) {
1470 menu->current = menu->oldcurrent;
1471 if (op == OP_MAIN_NEXT_THREAD || op == OP_MAIN_NEXT_SUBTHREAD)
1472 mutt_error (_("No more threads."));
1475 mutt_error (_("You are on the first thread."));
1477 else if (menu->menu == MENU_PAGER) {
1478 op = OP_DISPLAY_MESSAGE;
1482 menu->redraw = REDRAW_MOTION;
1485 case OP_MAIN_PARENT_MESSAGE:
1489 if ((menu->current = mutt_parent_message (Context, CURHDR)) < 0) {
1490 menu->current = menu->oldcurrent;
1492 else if (menu->menu == MENU_PAGER) {
1493 op = OP_DISPLAY_MESSAGE;
1497 menu->redraw = REDRAW_MOTION;
1500 case OP_MAIN_SET_FLAG:
1501 case OP_MAIN_CLEAR_FLAG:
1506 if (mutt_change_flag (tag ? NULL : CURHDR, (op == OP_MAIN_SET_FLAG)) == 0) {
1507 menu->redraw = REDRAW_STATUS;
1509 menu->redraw |= REDRAW_INDEX;
1510 else if (option (OPTRESOLVE)) {
1511 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1512 menu->current = menu->oldcurrent;
1513 menu->redraw |= REDRAW_CURRENT;
1516 menu->redraw |= REDRAW_MOTION_RESYNCH;
1519 menu->redraw |= REDRAW_CURRENT;
1523 case OP_MAIN_COLLAPSE_THREAD:
1527 if ((Sort & SORT_MASK) != SORT_THREADS) {
1528 mutt_error (_("Threading is not enabled."));
1533 if (CURHDR->collapsed) {
1534 menu->current = mutt_uncollapse_thread (Context, CURHDR);
1535 mutt_set_virtual (Context);
1536 if (option (OPTUNCOLLAPSEJUMP))
1537 menu->current = mutt_thread_next_unread (Context, CURHDR);
1539 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR)) {
1540 menu->current = mutt_collapse_thread (Context, CURHDR);
1541 mutt_set_virtual (Context);
1544 mutt_error (_("Thread contains unread messages."));
1549 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1553 case OP_MAIN_COLLAPSE_ALL:
1557 if ((Sort & SORT_MASK) != SORT_THREADS) {
1558 mutt_error (_("Threading is not enabled."));
1565 THREAD *thread, *top;
1568 if (CURHDR->collapsed)
1569 final = mutt_uncollapse_thread (Context, CURHDR);
1570 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR))
1571 final = mutt_collapse_thread (Context, CURHDR);
1573 final = CURHDR->virtual;
1575 base = Context->hdrs[Context->v2r[final]];
1577 top = Context->tree;
1578 Context->collapsed = !Context->collapsed;
1579 while ((thread = top) != NULL) {
1580 while (!thread->message)
1581 thread = thread->child;
1582 h = thread->message;
1584 if (h->collapsed != Context->collapsed) {
1586 mutt_uncollapse_thread (Context, h);
1587 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (h))
1588 mutt_collapse_thread (Context, h);
1593 mutt_set_virtual (Context);
1594 for (j = 0; j < Context->vcount; j++) {
1595 if (Context->hdrs[Context->v2r[j]]->index == base->index) {
1601 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1605 /* --------------------------------------------------------------------
1606 * These functions are invoked directly from the internal-pager
1609 case OP_BOUNCE_MESSAGE:
1613 ci_bounce_message (tag ? NULL : CURHDR, &menu->redraw);
1616 case OP_CREATE_ALIAS:
1617 mutt_create_alias (Context
1618 && Context->vcount ? CURHDR->env : NULL, NULL);
1619 MAYBE_REDRAW (menu->redraw);
1620 menu->redraw |= REDRAW_CURRENT;
1625 mutt_query_menu (NULL, 0);
1626 MAYBE_REDRAW (menu->redraw);
1629 case OP_PURGE_MESSAGE:
1635 CHECK_MX_ACL (Context, ACL_DELETE, _("Deletion"));
1638 mutt_tag_set_flag (M_DELETE, 1);
1639 mutt_tag_set_flag (M_PURGED, (op != OP_PURGE_MESSAGE) ? 0 : 1);
1640 if (option (OPTDELETEUNTAG))
1641 mutt_tag_set_flag (M_TAG, 0);
1642 menu->redraw = REDRAW_INDEX;
1645 mutt_set_flag (Context, CURHDR, M_DELETE, 1);
1646 mutt_set_flag (Context, CURHDR, M_PURGED,
1647 (op != OP_PURGE_MESSAGE) ? 0 : 1);
1648 if (option (OPTDELETEUNTAG))
1649 mutt_set_flag (Context, CURHDR, M_TAG, 0);
1650 if (option (OPTRESOLVE)) {
1651 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1652 menu->current = menu->oldcurrent;
1653 menu->redraw = REDRAW_CURRENT;
1655 else if (menu->menu == MENU_PAGER) {
1656 op = OP_DISPLAY_MESSAGE;
1660 menu->redraw |= REDRAW_MOTION_RESYNCH;
1663 menu->redraw = REDRAW_CURRENT;
1665 menu->redraw |= REDRAW_STATUS;
1668 case OP_DELETE_THREAD:
1669 case OP_DELETE_SUBTHREAD:
1674 CHECK_MX_ACL (Context, ACL_DELETE, _("Deletion"));
1676 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 1,
1677 op == OP_DELETE_THREAD ? 0 : 1);
1680 if (option (OPTDELETEUNTAG))
1681 mutt_thread_set_flag (CURHDR, M_TAG, 0,
1682 op == OP_DELETE_THREAD ? 0 : 1);
1683 if (option (OPTRESOLVE))
1684 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1685 menu->current = menu->oldcurrent;
1686 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1690 case OP_DISPLAY_ADDRESS:
1693 mutt_display_address (CURHDR->env);
1696 case OP_ENTER_COMMAND:
1697 CurrentMenu = MENU_MAIN;
1698 mutt_enter_command ();
1699 mutt_check_rescore (Context);
1700 if (option (OPTFORCEREDRAWINDEX))
1701 menu->redraw = REDRAW_FULL;
1702 unset_option (OPTFORCEREDRAWINDEX);
1703 unset_option (OPTFORCEREDRAWPAGER);
1706 case OP_EDIT_MESSAGE:
1712 CHECK_MX_ACL (Context, ACL_INSERT, _("Editing"));
1714 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1715 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1716 mutt_edit_message (Context, tag ? NULL : CURHDR);
1717 menu->redraw = REDRAW_FULL;
1721 case OP_FORWARD_MESSAGE:
1726 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1727 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1728 ci_send_message (SENDFORWARD, NULL, NULL, Context, tag ? NULL : CURHDR);
1729 menu->redraw = REDRAW_FULL;
1732 case OP_GROUP_REPLY:
1737 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1738 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1740 ci_send_message (SENDREPLY | SENDGROUPREPLY, NULL, NULL, Context,
1741 tag ? NULL : CURHDR);
1742 menu->redraw = REDRAW_FULL;
1750 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1751 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1753 ci_send_message (SENDREPLY | SENDLISTREPLY, NULL, NULL, Context,
1754 tag ? NULL : CURHDR);
1755 menu->redraw = REDRAW_FULL;
1760 ci_send_message (0, NULL, NULL, Context, NULL);
1761 menu->redraw = REDRAW_FULL;
1764 case OP_EXTRACT_KEYS:
1767 crypt_extract_keys_from_messages (tag ? NULL : CURHDR);
1768 menu->redraw = REDRAW_FULL;
1772 case OP_CHECK_TRADITIONAL:
1775 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1776 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1778 if (menu->menu == MENU_PAGER) {
1779 op = OP_DISPLAY_MESSAGE;
1787 mutt_pipe_message (tag ? NULL : CURHDR);
1788 MAYBE_REDRAW (menu->redraw);
1794 mutt_print_message (tag ? NULL : CURHDR);
1797 case OP_MAIN_READ_THREAD:
1798 case OP_MAIN_READ_SUBTHREAD:
1803 CHECK_MX_ACL (Context, ACL_SEEN, _("Marking as read"));
1805 rc = mutt_thread_set_flag (CURHDR, M_READ, 1,
1806 op == OP_MAIN_READ_THREAD ? 0 : 1);
1809 if (option (OPTRESOLVE)) {
1810 if ((menu->current = (op == OP_MAIN_READ_THREAD ?
1811 mutt_next_thread (CURHDR) :
1812 mutt_next_subthread (CURHDR))) == -1)
1813 menu->current = menu->oldcurrent;
1815 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1819 case OP_RECALL_MESSAGE:
1821 ci_send_message (SENDPOSTPONED, NULL, NULL, Context, NULL);
1822 menu->redraw = REDRAW_FULL;
1831 for (j = 0; j < Context->vcount; j++) {
1832 if (Context->hdrs[Context->v2r[j]]->tagged)
1833 mutt_resend_message (NULL, Context,
1834 Context->hdrs[Context->v2r[j]]);
1838 mutt_resend_message (NULL, Context, CURHDR);
1840 menu->redraw = REDRAW_FULL;
1848 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1849 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1851 ci_send_message (SENDREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
1852 menu->redraw = REDRAW_FULL;
1855 case OP_SHELL_ESCAPE:
1856 mutt_shell_escape ();
1857 MAYBE_REDRAW (menu->redraw);
1861 case OP_TAG_SUBTHREAD:
1864 rc = mutt_thread_set_flag (CURHDR, M_TAG, !CURHDR->tagged,
1865 op == OP_TAG_THREAD ? 0 : 1);
1868 if (option (OPTRESOLVE)) {
1869 menu->current = mutt_next_thread (CURHDR);
1871 if (menu->current == -1)
1872 menu->current = menu->oldcurrent;
1874 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1883 CHECK_MX_ACL (Context, ACL_DELETE, _("Undeletion"));
1886 mutt_tag_set_flag (M_DELETE, 0);
1887 mutt_tag_set_flag (M_PURGED, 0);
1888 menu->redraw = REDRAW_INDEX;
1891 mutt_set_flag (Context, CURHDR, M_DELETE, 0);
1892 mutt_set_flag (Context, CURHDR, M_PURGED, 0);
1893 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1) {
1895 menu->redraw = REDRAW_MOTION_RESYNCH;
1898 menu->redraw = REDRAW_CURRENT;
1900 menu->redraw |= REDRAW_STATUS;
1903 case OP_UNDELETE_THREAD:
1904 case OP_UNDELETE_SUBTHREAD:
1909 CHECK_MX_ACL (Context, ACL_DELETE, _("Undeletion"));
1911 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
1912 op == OP_UNDELETE_THREAD ? 0 : 1)
1913 + mutt_thread_set_flag (CURHDR, M_PURGED, 0,
1914 op == OP_UNDELETE_THREAD ? 0 : 1);
1917 if (option (OPTRESOLVE)) {
1918 if (op == OP_UNDELETE_THREAD)
1919 menu->current = mutt_next_thread (CURHDR);
1921 menu->current = mutt_next_subthread (CURHDR);
1923 if (menu->current == -1)
1924 menu->current = menu->oldcurrent;
1926 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1931 if (option (OPTFORCEBUFFYCHECK))
1934 menu->redraw = REDRAW_FULL;
1937 case OP_VIEW_ATTACHMENTS:
1940 mutt_view_attachments (CURHDR);
1941 if (CURHDR->attach_del)
1942 Context->changed = 1;
1943 menu->redraw = REDRAW_FULL;
1949 case OP_SIDEBAR_SCROLL_UP:
1950 case OP_SIDEBAR_SCROLL_DOWN:
1951 case OP_SIDEBAR_NEXT:
1952 case OP_SIDEBAR_PREV:
1953 case OP_SIDEBAR_NEXT_NEW:
1954 case OP_SIDEBAR_PREV_NEW:
1955 sidebar_scroll (op);
1959 if (menu->menu == MENU_MAIN)
1960 km_error_key (MENU_MAIN);
1963 if (menu->menu == MENU_PAGER) {
1964 menu->menu = MENU_MAIN;
1965 menu->redraw = REDRAW_FULL;
1973 /* Close all open IMAP connections */
1977 mutt_menuDestroy (&menu);
1981 void mutt_set_header_color (CONTEXT * ctx, HEADER * curhdr)
1988 for (color = ColorIndexList; color; color = color->next)
1989 if (mutt_pattern_exec
1990 (color->color_pattern, M_MATCH_FULL_ADDRESS, ctx, curhdr)) {
1991 curhdr->pair = color->pair;
1994 curhdr->pair = ColorDefs[MT_COLOR_NORMAL];