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>
15 #include <lib-ui/sidebar.h>
16 #include <lib-mx/mx.h>
26 #include "recvattach.h"
31 #include <imap/imap_private.h>
33 static const char *No_mailbox_is_open = N_("No mailbox is open.");
34 static const char *There_are_no_messages = N_("There are no messages.");
35 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
36 static const char *Function_not_permitted_in_attach_message_mode =
37 N_("Function not permitted in attach-message mode.");
38 static const char *No_visible = N_("No visible messages.");
40 #define CHECK_IN_MAILBOX if (!Context) \
43 mutt_error (_(No_mailbox_is_open)); \
47 #define CHECK_MSGCOUNT if (!Context) \
50 mutt_error(_(No_mailbox_is_open)); \
53 else if (!Context->msgcount) \
56 mutt_error(_(There_are_no_messages)); \
60 #define CHECK_VISIBLE if (Context && menu->current >= Context->vcount) \
63 mutt_error(_(No_visible)); \
68 #define CHECK_READONLY if (Context->readonly) \
71 mutt_error(_(Mailbox_is_read_only)); \
75 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
78 mutt_error(_(Function_not_permitted_in_attach_message_mode)); \
82 #define CURHDR Context->hdrs[Context->v2r[menu->current]]
83 #define OLDHDR Context->hdrs[Context->v2r[menu->oldcurrent]]
84 #define UNREAD(h) mutt_thread_contains_unread (Context, h)
86 extern size_t UngetCount;
88 void index_make_entry (char *s, ssize_t l, struct menu_t * menu, int num)
90 format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_INDEX;
91 int edgemsgno, reverse = Sort & SORT_REVERSE;
92 HEADER *h = Context->hdrs[Context->v2r[num]];
95 if ((Sort & SORT_MASK) == SORT_THREADS && h->tree) {
96 flag |= M_FORMAT_TREE; /* display the thread tree */
97 if (h->display_subject)
98 flag |= M_FORMAT_FORCESUBJ;
101 if (menu->top + menu->pagelen > menu->max)
102 edgemsgno = Context->v2r[menu->max - 1];
104 edgemsgno = Context->v2r[menu->top + menu->pagelen - 1];
107 edgemsgno = Context->v2r[menu->top];
109 for (tmp = h->thread->parent; tmp; tmp = tmp->parent) {
113 /* if no ancestor is visible on current screen, provisionally force
115 if (reverse ? tmp->message->msgno > edgemsgno : tmp->message->msgno <
117 flag |= M_FORMAT_FORCESUBJ;
120 else if (tmp->message->virtual >= 0)
123 if (flag & M_FORMAT_FORCESUBJ) {
124 for (tmp = h->thread->prev; tmp; tmp = tmp->prev) {
128 /* ...but if a previous sibling is available, don't force it */
129 if (reverse ? tmp->message->msgno >
130 edgemsgno : tmp->message->msgno < edgemsgno)
132 else if (tmp->message->virtual >= 0) {
133 flag &= ~M_FORMAT_FORCESUBJ;
141 _mutt_make_string (s, l, NONULL (HdrFmt), Context, h, flag);
144 int index_color (int index_no)
146 HEADER *h = Context->hdrs[Context->v2r[index_no]];
151 mutt_set_header_color (Context, h);
155 static int ci_next_undeleted (int msgno)
159 for (i = msgno + 1; i < Context->vcount; i++)
160 if (!Context->hdrs[Context->v2r[i]]->deleted)
165 static int ci_previous_undeleted (int msgno)
169 for (i = msgno - 1; i >= 0; i--)
170 if (!Context->hdrs[Context->v2r[i]]->deleted)
175 /* Return the index of the first new message, or failing that, the first
178 static int ci_first_message (void)
182 if (Context && Context->msgcount) {
183 for (i = 0; i < Context->vcount; i++) {
184 if (!Context->hdrs[Context->v2r[i]]->read &&
185 !Context->hdrs[Context->v2r[i]]->deleted) {
186 if (!Context->hdrs[Context->v2r[i]]->old)
195 /* If Sort is reverse and not threaded, the latest message is first.
196 * If Sort is threaded, the latest message is first iff exactly one
197 * of Sort and SortAux are reverse.
199 if (((Sort & SORT_REVERSE) && (Sort & SORT_MASK) != SORT_THREADS) ||
200 ((Sort & SORT_MASK) == SORT_THREADS &&
201 ((Sort ^ SortAux) & SORT_REVERSE)))
204 return (Context->vcount ? Context->vcount - 1 : 0);
209 /* This should be in mx.c, but it only gets used here. */
210 static int mx_toggle_write (CONTEXT * ctx)
216 mutt_error (_("Cannot toggle write on a readonly mailbox!"));
221 if (ctx->dontwrite) {
223 mutt_message (_("Changes to folder will be written on folder exit."));
227 mutt_message (_("Changes to folder will not be written."));
233 static void update_index (MUTTMENU * menu, CONTEXT * ctx __attribute__ ((unused)), int check,
234 int oldcount, int index_hint)
236 /* store pointers to the newly added messages */
237 HEADER **save_new = NULL;
240 /* take note of the current message */
242 if (menu->current < Context->vcount)
243 menu->oldcurrent = index_hint;
245 oldcount = 0; /* invalid message number! */
248 /* We are in a limited view. Check if the new message(s) satisfy
249 * the limit criteria. If they do, set their virtual msgno so that
250 * they will be visible in the limited view */
251 if (Context->pattern) {
252 #define THIS_BODY Context->hdrs[j]->content
253 for (j = (check == M_REOPENED) ? 0 : oldcount; j < Context->msgcount; j++) {
254 if (mutt_pattern_exec
255 (Context->limit_pattern, M_MATCH_FULL_ADDRESS, Context,
257 Context->hdrs[j]->virtual = Context->vcount;
258 Context->v2r[Context->vcount] = j;
259 Context->hdrs[j]->limited = 1;
262 THIS_BODY->length + THIS_BODY->offset - THIS_BODY->hdr_offset;
268 /* save the list of new messages */
269 if (oldcount && check != M_REOPENED && ((Sort & SORT_MASK) == SORT_THREADS)) {
270 save_new = p_new(HEADER*, Context->msgcount - oldcount);
271 for (j = oldcount; j < Context->msgcount; j++)
272 save_new[j - oldcount] = Context->hdrs[j];
275 /* if the mailbox was reopened, need to rethread from scratch */
276 mutt_sort_headers (Context, (check == M_REOPENED));
278 /* uncollapse threads with new mail */
279 if ((Sort & SORT_MASK) == SORT_THREADS) {
280 if (check == M_REOPENED) {
283 Context->collapsed = 0;
285 for (h = Context->tree; h; h = h->next) {
286 for (c = h; !c->message; c = c->child);
287 mutt_uncollapse_thread (Context, c->message);
289 mutt_set_virtual (Context);
292 for (j = 0; j < Context->msgcount - oldcount; j++) {
295 for (k = 0; k < Context->msgcount; k++) {
296 HEADER *h = Context->hdrs[k];
298 if (h == save_new[j] && (!Context->pattern || h->limited))
299 mutt_uncollapse_thread (Context, h);
303 mutt_set_virtual (Context);
309 /* restore the current message to the message it was pointing to */
310 for (j = 0; j < Context->vcount; j++) {
311 if (Context->hdrs[Context->v2r[j]]->index == menu->oldcurrent) {
318 if (menu->current < 0)
319 menu->current = ci_first_message ();
322 static void resort_index (MUTTMENU * menu)
325 HEADER *current = CURHDR;
328 mutt_sort_headers (Context, 0);
329 /* Restore the current message */
331 for (i = 0; i < Context->vcount; i++) {
332 if (Context->hdrs[Context->v2r[i]] == current) {
338 if ((Sort & SORT_MASK) == SORT_THREADS && menu->current < 0)
339 menu->current = mutt_parent_message (Context, current);
341 if (menu->current < 0)
342 menu->current = ci_first_message ();
344 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
347 /* This function handles the message index window as well as commands returned
348 * from the pager (MENU_PAGER).
350 int mutt_index_menu (void)
352 char buf[LONG_STRING];
355 int done = 0; /* controls when to exit the "event" loop */
357 int tag = 0; /* has the tag-prefix command been pressed? */
362 const char *cp; /* temporary variable. */
363 int index_hint; /* used to restore cursor position */
364 int do_buffy_notify = 1;
365 int closed = 0; /* did we OP_QUIT or OP_EXIT out of this menu? */
366 int attach_msg = option (OPTATTACHMSG);
368 menu = mutt_new_menu ();
369 menu->menu = MENU_MAIN;
371 menu->pagelen = LINES - 3;
372 menu->make_entry = (void *) index_make_entry;
373 menu->color = index_color;
374 menu->current = ci_first_message ();
377 buffy_check (0); /* force the buffy check after we enter the folder */
378 /* record folder we open to place sidebar indicator properly */
379 if (Context && Context->path)
380 sidebar_set_current (Context->path);
384 tag = 0; /* clear the tag-prefix */
386 menu->max = Context ? Context->vcount : 0;
387 oldcount = Context ? Context->msgcount : 0;
389 /* check if we need to resort the index because just about
390 * any 'op' below could do mutt_enter_command(), either here or
391 * from any new menu launched, and change $sort/$sort_aux
393 if (option (OPTNEEDRESORT) && Context && Context->msgcount)
396 if (option (OPTREDRAWTREE) && Context && Context->msgcount
397 && (Sort & SORT_MASK) == SORT_THREADS) {
398 mutt_draw_tree (Context);
399 menu->redraw |= REDRAW_STATUS;
400 unset_option (OPTREDRAWTREE);
403 if (Context && !attach_msg) {
406 /* check for new mail in the mailbox. If nonzero, then something has
407 * changed about the file (either we got new mail or the file was
408 * modified underneath us.)
411 imap_allow_reopen (Context);
413 index_hint = (Context->vcount && menu->current >= 0
414 && menu->current < Context->vcount) ? CURHDR->index : 0;
416 if ((check = mx_check_mailbox (Context, &index_hint, 0)) < 0) {
417 if (!Context->path) {
418 /* fatal error occurred */
420 menu->redraw = REDRAW_FULL;
422 set_option (OPTSEARCHINVALID);
424 else if (check == M_NEW_MAIL || check == M_REOPENED || check == M_FLAGS) {
425 update_index (menu, Context, check, oldcount, index_hint);
427 /* notify the user of new mail */
428 if (check == M_REOPENED)
430 ("Mailbox was externally modified. Flags may be wrong."));
431 else if (check == M_NEW_MAIL) {
432 /* on new mail: redraw sidebar */
434 mutt_message (_("New mail in this mailbox."));
436 if (mod_core.beep_new)
439 else if (check == M_FLAGS)
440 mutt_message (_("Mailbox was externally modified."));
442 /* avoid the message being overwritten by buffy */
445 menu->redraw = REDRAW_FULL;
446 menu->max = Context->vcount;
448 set_option (OPTSEARCHINVALID);
453 imap_disallow_reopen (Context);
456 /* check for new mail in the incoming folders */
458 if ((newcount = buffy_check (0)) != oldcount) {
459 menu->redraw |= REDRAW_STATUS;
460 menu->redraw |= REDRAW_SIDEBAR;
462 if (do_buffy_notify) {
463 if (buffy_notify () && mod_core.beep_new)
472 if (menu->redraw & REDRAW_SIDEBAR)
474 if (menu->redraw & REDRAW_FULL) {
475 menu_redraw_full (menu);
480 if (menu->menu == MENU_MAIN) {
481 if (Context && Context->hdrs && !(menu->current >= Context->vcount)) {
482 menu_check_recenter (menu);
484 if (menu->redraw & REDRAW_INDEX) {
485 menu_redraw_index (menu);
486 menu->redraw |= REDRAW_STATUS;
488 else if (menu->redraw & (REDRAW_MOTION_RESYNCH | REDRAW_MOTION))
489 menu_redraw_motion (menu);
490 else if (menu->redraw & REDRAW_CURRENT)
491 menu_redraw_current (menu);
494 if (menu->redraw & REDRAW_STATUS) {
495 menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
496 CLEARLINE(main_w, 0);
497 SETCOLOR(main_w, MT_COLOR_STATUS);
498 BKGDSET(main_w, MT_COLOR_STATUS);
500 mutt_paddstr (main_w, getmaxx(main_w), buf);
501 SETCOLOR(main_w, MT_COLOR_NORMAL);
502 BKGDSET(main_w, MT_COLOR_NORMAL);
503 sidebar_set_buffystats (Context);
504 menu->redraw &= ~REDRAW_STATUS;
505 if (option (OPTXTERMSETTITLES)) {
506 menu_status_line(buf, sizeof(buf), menu, NONULL(XtermTitle));
507 printf("\033]2;%s\007", buf);
508 menu_status_line(buf, sizeof(buf), menu, NONULL(XtermIcon));
509 printf("\033]1;%s\007", buf);
515 if (menu->current < menu->max)
516 menu->oldcurrent = menu->current;
518 menu->oldcurrent = -1;
524 menu->redraw = REDRAW_FULL;
525 menu->menu = MENU_MAIN;
526 menu->top = 0; /* so we scroll the right amount */
530 op = km_dokey (MENU_MAIN);
532 continue; /* either user abort or timeout */
536 /* special handling for the tag-prefix function */
537 if (op == OP_TAG_PREFIX) {
539 mutt_error (_("No mailbox is open."));
544 if (!Context->tagged) {
545 mutt_error (_("No tagged messages."));
551 /* give visual indication that the next command is a tag- command */
552 mvwaddstr (main_w, LINES - 1, 0, "tag-");
555 /* get the real command */
556 if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX) {
557 /* abort tag sequence */
558 CLEARLINE(main_w, LINES - 1);
562 else if (option (OPTAUTOTAG) && Context && Context->tagged)
565 if (op == OP_TAG_PREFIX_COND) {
567 mutt_error (_("No mailbox is open."));
572 if (!Context->tagged) {
575 while (UngetCount > 0) {
577 if (tmp.op == OP_END_COND)
580 mutt_message (_("Nothing to do."));
586 /* give visual indication that the next command is a tag- command */
587 mvwaddstr (main_w, LINES - 1, 0, "tag-");
590 /* get the real command */
591 if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX) {
592 /* abort tag sequence */
593 CLEARLINE(main_w, LINES - 1);
600 if (menu->current < menu->max)
601 menu->oldcurrent = menu->current;
603 menu->oldcurrent = -1;
605 mutt_curs_set (1); /* fallback from the pager */
610 /* ----------------------------------------------------------------------
615 menu_bottom_page (menu);
618 menu_first_entry (menu);
621 menu_middle_page (menu);
627 menu_half_down (menu);
630 menu_next_line (menu);
633 menu_prev_line (menu);
636 menu_next_page (menu);
639 menu_prev_page (menu);
642 menu_last_entry (menu);
645 menu_top_page (menu);
648 menu_current_top (menu);
650 case OP_CURRENT_MIDDLE:
651 menu_current_middle (menu);
653 case OP_CURRENT_BOTTOM:
654 menu_current_bottom (menu);
660 if (isdigit (LastKey))
661 mutt_ungetch (LastKey, 0);
663 if (mutt_get_field (_("Jump to message: "), buf, sizeof (buf), 0) != 0
667 if (!isdigit ((unsigned char) buf[0])) {
668 mutt_error (_("Argument must be a message number."));
674 if (i > 0 && i <= Context->msgcount) {
675 for (j = i - 1; j < Context->msgcount; j++) {
676 if (Context->hdrs[j]->virtual != -1)
679 if (j >= Context->msgcount) {
680 for (j = i - 2; j >= 0; j--) {
681 if (Context->hdrs[j]->virtual != -1)
687 menu->current = Context->hdrs[j]->virtual;
688 if (menu->menu == MENU_PAGER) {
689 op = OP_DISPLAY_MESSAGE;
693 menu->redraw = REDRAW_MOTION;
696 mutt_error (_("That message is not visible."));
699 mutt_error (_("Invalid message number."));
703 /* --------------------------------------------------------------------
704 * `index' specific commands
707 case OP_MAIN_DELETE_PATTERN:
712 CHECK_MX_ACL (Context, ACL_DELETE, _("Deletion"));
715 mutt_pattern_func (M_DELETE, _("Delete messages matching: "));
716 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
719 case OP_MAIN_FETCH_MAIL:
722 menu->redraw = REDRAW_FULL;
726 mutt_help (MENU_MAIN);
727 menu->redraw = REDRAW_FULL;
730 case OP_MAIN_SHOW_LIMIT:
732 if (!Context->pattern)
733 mutt_message (_("No limit pattern is in effect."));
738 /* i18n: ask for a limit to apply */
739 snprintf (buffer, sizeof (buffer), _("Limit: %s"), Context->pattern);
740 mutt_message ("%s", buffer);
747 menu->oldcurrent = (Context->vcount && menu->current >= 0
749 Context->vcount) ? CURHDR->index : -1;
750 if (op == OP_TOGGLE_READ) {
751 char buffer[LONG_STRING];
753 if (m_strncmp (Context->pattern, "!~R!~D~s", 8) != 0) {
754 snprintf (buffer, sizeof (buffer), "!~R!~D~s%s",
755 Context->pattern ? Context->pattern : ".*");
756 set_option (OPTHIDEREAD);
759 m_strcpy(buf, sizeof(buf), Context->pattern + 8);
760 if (m_strncmp (buf, ".*", 2) == 0)
761 snprintf (buf, sizeof (buf), "~A");
762 unset_option (OPTHIDEREAD);
764 p_delete(&Context->pattern);
765 Context->pattern = m_strdup(buf);
767 if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
768 mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
770 if (menu->oldcurrent >= 0) {
771 /* try to find what used to be the current message */
773 for (i = 0; i < Context->vcount; i++)
774 if (Context->hdrs[Context->v2r[i]]->index == menu->oldcurrent) {
778 if (menu->current < 0)
783 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
784 if (Context->msgcount && (Sort & SORT_MASK) == SORT_THREADS)
785 mutt_draw_tree (Context);
786 menu->redraw = REDRAW_FULL;
788 if (Context->pattern)
789 mutt_message _("To view all messages, limit to \"all\".");
799 if (query_quadoption2(mod_core.quit, _("Quit Madmutt?")) == M_YES) {
802 oldcount = Context ? Context->msgcount : 0;
805 || (check = mx_close_mailbox (Context, &index_hint)) == 0)
808 if (check == M_NEW_MAIL || check == M_REOPENED)
809 update_index (menu, Context, check, oldcount, index_hint);
811 menu->redraw = REDRAW_FULL; /* new mail arrived? */
812 set_option (OPTSEARCHINVALID);
818 clearok (main_w, TRUE);
819 menu->redraw = REDRAW_FULL;
823 case OP_SEARCH_REVERSE:
825 case OP_SEARCH_OPPOSITE:
828 if ((menu->current = mutt_search_command (menu->current, op)) == -1)
829 menu->current = menu->oldcurrent;
831 menu->redraw = REDRAW_MOTION;
835 case OP_SORT_REVERSE:
836 if (mutt_select_sort ((op == OP_SORT_REVERSE)) == 0) {
837 if (Context && Context->msgcount) {
839 set_option (OPTSEARCHINVALID);
847 if (tag && !option (OPTAUTOTAG)) {
848 for (j = 0; j < Context->vcount; j++)
849 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_TAG, 0);
850 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
853 mutt_set_flag (Context, CURHDR, M_TAG, !CURHDR->tagged);
854 Context->last_tag = CURHDR->tagged ? CURHDR :
855 ((Context->last_tag == CURHDR && !CURHDR->tagged)
856 ? NULL : Context->last_tag);
857 menu->redraw = REDRAW_STATUS;
858 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1) {
860 menu->redraw |= REDRAW_MOTION_RESYNCH;
863 menu->redraw |= REDRAW_CURRENT;
867 case OP_MAIN_TAG_PATTERN:
870 mutt_pattern_func (M_TAG, _("Tag messages matching: "));
871 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
874 case OP_MAIN_UNDELETE_PATTERN:
879 CHECK_MX_ACL (Context, ACL_DELETE, _("Undeletion"));
881 if (mutt_pattern_func (M_UNDELETE, _("Undelete messages matching: ")) ==
883 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
886 case OP_MAIN_UNTAG_PATTERN:
889 if (mutt_pattern_func (M_UNTAG, _("Untag messages matching: ")) == 0)
890 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
893 /* --------------------------------------------------------------------
894 * The following operations can be performed inside of the pager.
897 case OP_MAIN_IMAP_FETCH:
898 if (Context->magic == M_IMAP)
899 imap_check_mailbox (Context, &index_hint, 1);
902 case OP_MAIN_SYNC_FOLDER:
903 if (Context && !Context->msgcount)
910 int oldvcount = Context->vcount;
911 oldcount = Context->msgcount;
915 /* calculate the number of messages _above_ the cursor,
916 * so we can keep the cursor on the current message
918 for (j = 0; j <= menu->current; j++) {
919 if (Context->hdrs[Context->v2r[j]]->deleted)
923 if ((check = mx_sync_mailbox (Context, &index_hint)) == 0) {
924 if (Context->vcount != oldvcount)
925 menu->current -= dcount;
926 set_option (OPTSEARCHINVALID);
928 else if (check == M_NEW_MAIL || check == M_REOPENED)
929 update_index (menu, Context, check, oldcount, index_hint);
932 * do a sanity check even if mx_sync_mailbox failed.
935 if (menu->current < 0 || menu->current >= Context->vcount)
936 menu->current = ci_first_message ();
939 /* check for a fatal error, or all messages deleted */
943 /* if we were in the pager, redisplay the message */
944 if (menu->menu == MENU_PAGER) {
945 op = OP_DISPLAY_MESSAGE;
949 menu->redraw = REDRAW_FULL;
952 case OP_SIDEBAR_OPEN:
953 case OP_MAIN_CHANGE_FOLDER:
954 case OP_MAIN_CHANGE_FOLDER_READONLY:
955 if (attach_msg || op == OP_MAIN_CHANGE_FOLDER_READONLY)
961 cp = _("Open mailbox in read-only mode");
963 cp = _("Open mailbox");
966 if (Context && Context->path)
967 m_strcpy(buf, sizeof(buf), Context->path);
968 if (op != OP_SIDEBAR_OPEN)
969 buffy_next (buf, sizeof (buf));
971 if (op == OP_SIDEBAR_OPEN) {
972 m_strcpy(buf, sizeof(buf), sidebar_get_current());
974 else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) {
975 if (menu->menu == MENU_PAGER) {
976 op = OP_DISPLAY_MESSAGE;
982 CLEARLINE(main_w, LINES - 1);
986 mutt_expand_path (buf, sizeof (buf));
987 if (mx_get_magic (buf) <= 0) {
988 mutt_error (_("%s is not a mailbox."), buf);
991 m_strreplace(&CurrentFolder, buf);
996 if (Context->cinfo && Context->realpath)
997 m_strreplace(&LastFolder, Context->realpath);
999 m_strreplace(&LastFolder, Context->path);
1000 oldcount = Context ? Context->msgcount : 0;
1002 if ((check = mx_close_mailbox (Context, &index_hint)) != 0) {
1003 if (check == M_NEW_MAIL || check == M_REOPENED)
1004 update_index (menu, Context, check, oldcount, index_hint);
1006 set_option (OPTSEARCHINVALID);
1007 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1015 /* Set CurrentMenu to MENU_MAIN before executing any folder
1016 * hooks so that all the index menu functions are available to
1020 CurrentMenu = MENU_MAIN;
1021 mutt_folder_hook (buf);
1023 if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL) {
1024 menu->current = ci_first_message ();
1028 sidebar_set_current (buf);
1030 mutt_clear_error ();
1031 buffy_check (0); /* force the buffy check after we have changed
1033 menu->redraw = REDRAW_FULL;
1034 set_option (OPTSEARCHINVALID);
1037 case OP_DISPLAY_MESSAGE:
1038 case OP_DISPLAY_HEADERS: /* don't weed the headers */
1043 * toggle the weeding of headers so that a user can press the key
1044 * again while reading the message.
1046 if (op == OP_DISPLAY_HEADERS)
1047 toggle_option (OPTWEED);
1049 unset_option (OPTNEEDRESORT);
1051 if ((Sort & SORT_MASK) == SORT_THREADS && CURHDR->collapsed) {
1052 mutt_uncollapse_thread (Context, CURHDR);
1053 mutt_set_virtual (Context);
1054 if (option (OPTUNCOLLAPSEJUMP))
1055 menu->current = mutt_thread_next_unread (Context, CURHDR);
1058 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1059 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1061 if ((op = mutt_display_message (CURHDR)) == -1) {
1062 unset_option (OPTNEEDRESORT);
1066 menu->menu = MENU_PAGER;
1067 menu->oldcurrent = menu->current;
1072 if (menu->menu == MENU_MAIN && attach_msg) {
1077 if ((menu->menu == MENU_MAIN)
1078 && (query_quadoption2(mod_core.quit,
1079 _("Exit Madmutt without saving?")) == M_YES))
1082 mx_fastclose_mailbox (Context);
1093 mutt_edit_content_type (CURHDR, CURHDR->content, NULL);
1094 /* if we were in the pager, redisplay the message */
1095 if (menu->menu == MENU_PAGER) {
1096 op = OP_DISPLAY_MESSAGE;
1100 menu->redraw = REDRAW_CURRENT;
1103 case OP_MAIN_BREAK_THREAD:
1108 if ((Sort & SORT_MASK) != SORT_THREADS)
1109 mutt_error (_("Threading is not enabled."));
1113 HEADER *oldcur = CURHDR;
1115 mutt_break_thread (CURHDR);
1116 mutt_sort_headers (Context, 1);
1117 menu->current = oldcur->virtual;
1120 Context->changed = 1;
1121 mutt_message _("Thread broken");
1123 if (menu->menu == MENU_PAGER) {
1124 op = OP_DISPLAY_MESSAGE;
1128 menu->redraw |= REDRAW_INDEX;
1132 case OP_MAIN_LINK_THREADS:
1137 if ((Sort & SORT_MASK) != SORT_THREADS)
1138 mutt_error (_("Threading is not enabled."));
1140 else if (!CURHDR->env->message_id)
1141 mutt_error (_("No Message-ID: header available to link thread"));
1143 else if (!tag && (!Context->last_tag || !Context->last_tag->tagged))
1144 mutt_error (_("First, please tag a message to be linked here"));
1147 HEADER *oldcur = CURHDR;
1149 if (mutt_link_threads (CURHDR, tag ? NULL : Context->last_tag,
1151 mutt_sort_headers (Context, 1);
1152 menu->current = oldcur->virtual;
1154 Context->changed = 1;
1155 mutt_message _("Threads linked");
1158 mutt_error (_("No thread linked"));
1161 if (menu->menu == MENU_PAGER) {
1162 op = OP_DISPLAY_MESSAGE;
1166 menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
1169 case OP_MAIN_NEXT_UNDELETED:
1172 if (menu->current >= Context->vcount - 1) {
1173 if (menu->menu == MENU_MAIN)
1174 mutt_error (_("You are on the last message."));
1178 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1179 menu->current = menu->oldcurrent;
1180 if (menu->menu == MENU_MAIN)
1181 mutt_error (_("No undeleted messages."));
1183 else if (menu->menu == MENU_PAGER) {
1184 op = OP_DISPLAY_MESSAGE;
1188 menu->redraw = REDRAW_MOTION;
1194 if (menu->current >= Context->vcount - 1) {
1195 if (menu->menu == MENU_MAIN)
1196 mutt_error (_("You are on the last message."));
1201 if (menu->menu == MENU_PAGER) {
1202 op = OP_DISPLAY_MESSAGE;
1206 menu->redraw = REDRAW_MOTION;
1209 case OP_MAIN_PREV_UNDELETED:
1212 if (menu->current < 1) {
1213 mutt_error (_("You are on the first message."));
1217 if ((menu->current = ci_previous_undeleted (menu->current)) == -1) {
1218 menu->current = menu->oldcurrent;
1219 if (menu->menu == MENU_MAIN)
1220 mutt_error (_("No undeleted messages."));
1222 else if (menu->menu == MENU_PAGER) {
1223 op = OP_DISPLAY_MESSAGE;
1227 menu->redraw = REDRAW_MOTION;
1233 if (menu->current < 1) {
1234 if (menu->menu == MENU_MAIN)
1235 mutt_error (_("You are on the first message."));
1240 if (menu->menu == MENU_PAGER) {
1241 op = OP_DISPLAY_MESSAGE;
1245 menu->redraw = REDRAW_MOTION;
1248 case OP_DECRYPT_COPY:
1249 case OP_DECRYPT_SAVE:
1250 case OP_COPY_MESSAGE:
1252 case OP_DECODE_COPY:
1253 case OP_DECODE_SAVE:
1256 if (mutt_save_message (tag ? NULL : CURHDR,
1257 (op == OP_DECRYPT_SAVE) ||
1258 (op == OP_SAVE) || (op == OP_DECODE_SAVE),
1259 (op == OP_DECODE_SAVE) || (op == OP_DECODE_COPY),
1260 (op == OP_DECRYPT_SAVE)
1261 || (op == OP_DECRYPT_COPY)
1262 || 0, &menu->redraw) == 0 && (op == OP_SAVE
1269 menu->redraw |= REDRAW_INDEX;
1270 else if (option (OPTRESOLVE)) {
1271 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1272 menu->current = menu->oldcurrent;
1273 menu->redraw |= REDRAW_CURRENT;
1276 menu->redraw |= REDRAW_MOTION_RESYNCH;
1279 menu->redraw |= REDRAW_CURRENT;
1283 case OP_MAIN_NEXT_NEW:
1284 case OP_MAIN_NEXT_UNREAD:
1285 case OP_MAIN_PREV_NEW:
1286 case OP_MAIN_PREV_UNREAD:
1287 case OP_MAIN_NEXT_NEW_THEN_UNREAD:
1288 case OP_MAIN_PREV_NEW_THEN_UNREAD:
1290 int first_unread = -1;
1298 for (j = 0; j != Context->vcount; j++) {
1299 #define CURHDRi Context->hdrs[Context->v2r[i]]
1300 if (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_NEXT_UNREAD
1301 || op == OP_MAIN_NEXT_NEW_THEN_UNREAD) {
1303 if (i > Context->vcount - 1) {
1304 mutt_message _("Search wrapped to top.");
1312 mutt_message _("Search wrapped to bottom.");
1314 i = Context->vcount - 1;
1318 if (CURHDRi->collapsed && (Sort & SORT_MASK) == SORT_THREADS) {
1319 if (UNREAD (CURHDRi) && first_unread == -1)
1321 if (UNREAD (CURHDRi) == 1 && first_new == -1)
1324 else if ((!CURHDRi->deleted && !CURHDRi->read)) {
1325 if (first_unread == -1)
1327 if ((!CURHDRi->old) && first_new == -1)
1331 if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD) &&
1334 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1335 op == OP_MAIN_NEXT_NEW_THEN_UNREAD
1336 || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1341 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1342 op == OP_MAIN_NEXT_NEW_THEN_UNREAD
1343 || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1345 menu->current = first_new;
1346 else if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD ||
1347 op == OP_MAIN_NEXT_NEW_THEN_UNREAD
1348 || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1349 && first_unread != -1)
1350 menu->current = first_unread;
1352 if (menu->current == -1) {
1353 menu->current = menu->oldcurrent;
1354 mutt_error ("%s%s.",
1355 (op == OP_MAIN_NEXT_NEW
1357 OP_MAIN_PREV_NEW) ? _("No new messages") :
1358 _("No unread messages"),
1359 Context->pattern ? _(" in this limited view") : "");
1361 else if (menu->menu == MENU_PAGER) {
1362 op = OP_DISPLAY_MESSAGE;
1366 menu->redraw = REDRAW_MOTION;
1369 case OP_FLAG_MESSAGE:
1374 CHECK_MX_ACL (Context, ACL_WRITE, _("Flagging"));
1377 for (j = 0; j < Context->vcount; j++) {
1378 if (Context->hdrs[Context->v2r[j]]->tagged)
1379 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]],
1380 M_FLAG, !Context->hdrs[Context->v2r[j]]->flagged);
1383 menu->redraw |= REDRAW_INDEX;
1386 mutt_set_flag (Context, CURHDR, M_FLAG, !CURHDR->flagged);
1387 if (option (OPTRESOLVE)) {
1388 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1389 menu->current = menu->oldcurrent;
1390 menu->redraw = REDRAW_CURRENT;
1393 menu->redraw = REDRAW_MOTION_RESYNCH;
1396 menu->redraw = REDRAW_CURRENT;
1398 menu->redraw |= REDRAW_STATUS;
1406 CHECK_MX_ACL (Context, ACL_SEEN, _("Toggling"));
1409 for (j = 0; j < Context->vcount; j++) {
1410 if (Context->hdrs[Context->v2r[j]]->tagged) {
1411 if (Context->hdrs[Context->v2r[j]]->read ||
1412 Context->hdrs[Context->v2r[j]]->old)
1413 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_NEW,
1416 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_READ,
1420 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
1423 if (CURHDR->read || CURHDR->old)
1424 mutt_set_flag (Context, CURHDR, M_NEW, 1);
1426 mutt_set_flag (Context, CURHDR, M_READ, 1);
1428 if (option (OPTRESOLVE)) {
1429 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1430 menu->current = menu->oldcurrent;
1431 menu->redraw = REDRAW_CURRENT;
1434 menu->redraw = REDRAW_MOTION_RESYNCH;
1437 menu->redraw = REDRAW_CURRENT;
1438 menu->redraw |= REDRAW_STATUS;
1442 case OP_TOGGLE_WRITE:
1444 if (mx_toggle_write (Context) == 0)
1445 menu->redraw |= REDRAW_STATUS;
1448 case OP_MAIN_NEXT_THREAD:
1449 case OP_MAIN_NEXT_SUBTHREAD:
1450 case OP_MAIN_PREV_THREAD:
1451 case OP_MAIN_PREV_SUBTHREAD:
1455 case OP_MAIN_NEXT_THREAD:
1456 menu->current = mutt_next_thread (CURHDR);
1459 case OP_MAIN_NEXT_SUBTHREAD:
1460 menu->current = mutt_next_subthread (CURHDR);
1463 case OP_MAIN_PREV_THREAD:
1464 menu->current = mutt_previous_thread (CURHDR);
1467 case OP_MAIN_PREV_SUBTHREAD:
1468 menu->current = mutt_previous_subthread (CURHDR);
1472 if (menu->current < 0) {
1473 menu->current = menu->oldcurrent;
1474 if (op == OP_MAIN_NEXT_THREAD || op == OP_MAIN_NEXT_SUBTHREAD)
1475 mutt_error (_("No more threads."));
1478 mutt_error (_("You are on the first thread."));
1480 else if (menu->menu == MENU_PAGER) {
1481 op = OP_DISPLAY_MESSAGE;
1485 menu->redraw = REDRAW_MOTION;
1488 case OP_MAIN_PARENT_MESSAGE:
1492 if ((menu->current = mutt_parent_message (Context, CURHDR)) < 0) {
1493 menu->current = menu->oldcurrent;
1495 else if (menu->menu == MENU_PAGER) {
1496 op = OP_DISPLAY_MESSAGE;
1500 menu->redraw = REDRAW_MOTION;
1503 case OP_MAIN_SET_FLAG:
1504 case OP_MAIN_CLEAR_FLAG:
1509 if (mutt_change_flag (tag ? NULL : CURHDR, (op == OP_MAIN_SET_FLAG)) == 0) {
1510 menu->redraw = REDRAW_STATUS;
1512 menu->redraw |= REDRAW_INDEX;
1513 else if (option (OPTRESOLVE)) {
1514 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1515 menu->current = menu->oldcurrent;
1516 menu->redraw |= REDRAW_CURRENT;
1519 menu->redraw |= REDRAW_MOTION_RESYNCH;
1522 menu->redraw |= REDRAW_CURRENT;
1526 case OP_MAIN_COLLAPSE_THREAD:
1530 if ((Sort & SORT_MASK) != SORT_THREADS) {
1531 mutt_error (_("Threading is not enabled."));
1536 if (CURHDR->collapsed) {
1537 menu->current = mutt_uncollapse_thread (Context, CURHDR);
1538 mutt_set_virtual (Context);
1539 if (option (OPTUNCOLLAPSEJUMP))
1540 menu->current = mutt_thread_next_unread (Context, CURHDR);
1542 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR)) {
1543 menu->current = mutt_collapse_thread (Context, CURHDR);
1544 mutt_set_virtual (Context);
1547 mutt_error (_("Thread contains unread messages."));
1552 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1556 case OP_MAIN_COLLAPSE_ALL:
1560 if ((Sort & SORT_MASK) != SORT_THREADS) {
1561 mutt_error (_("Threading is not enabled."));
1568 THREAD *thread, *top;
1571 if (CURHDR->collapsed)
1572 final = mutt_uncollapse_thread (Context, CURHDR);
1573 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR))
1574 final = mutt_collapse_thread (Context, CURHDR);
1576 final = CURHDR->virtual;
1578 base = Context->hdrs[Context->v2r[final]];
1580 top = Context->tree;
1581 Context->collapsed = !Context->collapsed;
1582 while ((thread = top) != NULL) {
1583 while (!thread->message)
1584 thread = thread->child;
1585 h = thread->message;
1587 if (h->collapsed != Context->collapsed) {
1589 mutt_uncollapse_thread (Context, h);
1590 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (h))
1591 mutt_collapse_thread (Context, h);
1596 mutt_set_virtual (Context);
1597 for (j = 0; j < Context->vcount; j++) {
1598 if (Context->hdrs[Context->v2r[j]]->index == base->index) {
1604 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1608 /* --------------------------------------------------------------------
1609 * These functions are invoked directly from the internal-pager
1612 case OP_BOUNCE_MESSAGE:
1616 ci_bounce_message (tag ? NULL : CURHDR, &menu->redraw);
1619 case OP_CREATE_ALIAS:
1620 mutt_create_alias (Context
1621 && Context->vcount ? CURHDR->env : NULL, NULL);
1622 MAYBE_REDRAW (menu->redraw);
1623 menu->redraw |= REDRAW_CURRENT;
1628 mutt_query_menu (NULL, 0);
1629 MAYBE_REDRAW (menu->redraw);
1632 case OP_PURGE_MESSAGE:
1638 CHECK_MX_ACL (Context, ACL_DELETE, _("Deletion"));
1641 mutt_tag_set_flag (M_DELETE, 1);
1642 mutt_tag_set_flag (M_PURGED, (op != OP_PURGE_MESSAGE) ? 0 : 1);
1643 if (option (OPTDELETEUNTAG))
1644 mutt_tag_set_flag (M_TAG, 0);
1645 menu->redraw = REDRAW_INDEX;
1648 mutt_set_flag (Context, CURHDR, M_DELETE, 1);
1649 mutt_set_flag (Context, CURHDR, M_PURGED,
1650 (op != OP_PURGE_MESSAGE) ? 0 : 1);
1651 if (option (OPTDELETEUNTAG))
1652 mutt_set_flag (Context, CURHDR, M_TAG, 0);
1653 if (option (OPTRESOLVE)) {
1654 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1655 menu->current = menu->oldcurrent;
1656 menu->redraw = REDRAW_CURRENT;
1658 else if (menu->menu == MENU_PAGER) {
1659 op = OP_DISPLAY_MESSAGE;
1663 menu->redraw |= REDRAW_MOTION_RESYNCH;
1666 menu->redraw = REDRAW_CURRENT;
1668 menu->redraw |= REDRAW_STATUS;
1671 case OP_DELETE_THREAD:
1672 case OP_DELETE_SUBTHREAD:
1677 CHECK_MX_ACL (Context, ACL_DELETE, _("Deletion"));
1679 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 1,
1680 op == OP_DELETE_THREAD ? 0 : 1);
1683 if (option (OPTDELETEUNTAG))
1684 mutt_thread_set_flag (CURHDR, M_TAG, 0,
1685 op == OP_DELETE_THREAD ? 0 : 1);
1686 if (option (OPTRESOLVE))
1687 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1688 menu->current = menu->oldcurrent;
1689 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1693 case OP_DISPLAY_ADDRESS:
1696 mutt_display_address (CURHDR->env);
1699 case OP_ENTER_COMMAND:
1700 CurrentMenu = MENU_MAIN;
1701 mutt_enter_command ();
1702 mutt_check_rescore (Context);
1703 if (option (OPTFORCEREDRAWINDEX))
1704 menu->redraw = REDRAW_FULL;
1705 unset_option (OPTFORCEREDRAWINDEX);
1706 unset_option (OPTFORCEREDRAWPAGER);
1709 case OP_EDIT_MESSAGE:
1715 CHECK_MX_ACL (Context, ACL_INSERT, _("Editing"));
1717 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1718 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1719 mutt_edit_message (Context, tag ? NULL : CURHDR);
1720 menu->redraw = REDRAW_FULL;
1724 case OP_FORWARD_MESSAGE:
1729 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1730 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1731 ci_send_message (SENDFORWARD, NULL, NULL, Context, tag ? NULL : CURHDR);
1732 menu->redraw = REDRAW_FULL;
1735 case OP_GROUP_REPLY:
1740 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1741 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1743 ci_send_message (SENDREPLY | SENDGROUPREPLY, NULL, NULL, Context,
1744 tag ? NULL : CURHDR);
1745 menu->redraw = REDRAW_FULL;
1753 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1754 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1756 ci_send_message (SENDREPLY | SENDLISTREPLY, NULL, NULL, Context,
1757 tag ? NULL : CURHDR);
1758 menu->redraw = REDRAW_FULL;
1763 ci_send_message (0, NULL, NULL, Context, NULL);
1764 menu->redraw = REDRAW_FULL;
1767 case OP_EXTRACT_KEYS:
1770 crypt_extract_keys_from_messages (tag ? NULL : CURHDR);
1771 menu->redraw = REDRAW_FULL;
1775 case OP_CHECK_TRADITIONAL:
1778 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1779 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1781 if (menu->menu == MENU_PAGER) {
1782 op = OP_DISPLAY_MESSAGE;
1790 mutt_pipe_message (tag ? NULL : CURHDR);
1791 MAYBE_REDRAW (menu->redraw);
1797 mutt_print_message (tag ? NULL : CURHDR);
1800 case OP_MAIN_READ_THREAD:
1801 case OP_MAIN_READ_SUBTHREAD:
1806 CHECK_MX_ACL (Context, ACL_SEEN, _("Marking as read"));
1808 rc = mutt_thread_set_flag (CURHDR, M_READ, 1,
1809 op == OP_MAIN_READ_THREAD ? 0 : 1);
1812 if (option (OPTRESOLVE)) {
1813 if ((menu->current = (op == OP_MAIN_READ_THREAD ?
1814 mutt_next_thread (CURHDR) :
1815 mutt_next_subthread (CURHDR))) == -1)
1816 menu->current = menu->oldcurrent;
1818 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1822 case OP_RECALL_MESSAGE:
1824 ci_send_message (SENDPOSTPONED, NULL, NULL, Context, NULL);
1825 menu->redraw = REDRAW_FULL;
1834 for (j = 0; j < Context->vcount; j++) {
1835 if (Context->hdrs[Context->v2r[j]]->tagged)
1836 mutt_resend_message (NULL, Context,
1837 Context->hdrs[Context->v2r[j]]);
1841 mutt_resend_message (NULL, Context, CURHDR);
1843 menu->redraw = REDRAW_FULL;
1851 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1852 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1854 ci_send_message (SENDREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
1855 menu->redraw = REDRAW_FULL;
1858 case OP_SHELL_ESCAPE:
1859 mutt_shell_escape ();
1860 MAYBE_REDRAW (menu->redraw);
1864 case OP_TAG_SUBTHREAD:
1867 rc = mutt_thread_set_flag (CURHDR, M_TAG, !CURHDR->tagged,
1868 op == OP_TAG_THREAD ? 0 : 1);
1871 if (option (OPTRESOLVE)) {
1872 menu->current = mutt_next_thread (CURHDR);
1874 if (menu->current == -1)
1875 menu->current = menu->oldcurrent;
1877 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1886 CHECK_MX_ACL (Context, ACL_DELETE, _("Undeletion"));
1889 mutt_tag_set_flag (M_DELETE, 0);
1890 mutt_tag_set_flag (M_PURGED, 0);
1891 menu->redraw = REDRAW_INDEX;
1894 mutt_set_flag (Context, CURHDR, M_DELETE, 0);
1895 mutt_set_flag (Context, CURHDR, M_PURGED, 0);
1896 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1) {
1898 menu->redraw = REDRAW_MOTION_RESYNCH;
1901 menu->redraw = REDRAW_CURRENT;
1903 menu->redraw |= REDRAW_STATUS;
1906 case OP_UNDELETE_THREAD:
1907 case OP_UNDELETE_SUBTHREAD:
1912 CHECK_MX_ACL (Context, ACL_DELETE, _("Undeletion"));
1914 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
1915 op == OP_UNDELETE_THREAD ? 0 : 1)
1916 + mutt_thread_set_flag (CURHDR, M_PURGED, 0,
1917 op == OP_UNDELETE_THREAD ? 0 : 1);
1920 if (option (OPTRESOLVE)) {
1921 if (op == OP_UNDELETE_THREAD)
1922 menu->current = mutt_next_thread (CURHDR);
1924 menu->current = mutt_next_subthread (CURHDR);
1926 if (menu->current == -1)
1927 menu->current = menu->oldcurrent;
1929 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1938 if (option (OPTFORCEBUFFYCHECK))
1941 menu->redraw = REDRAW_FULL;
1944 case OP_VIEW_ATTACHMENTS:
1947 mutt_view_attachments (CURHDR);
1948 if (CURHDR->attach_del)
1949 Context->changed = 1;
1950 menu->redraw = REDRAW_FULL;
1960 case OP_SIDEBAR_SCROLL_UP:
1961 case OP_SIDEBAR_SCROLL_DOWN:
1962 case OP_SIDEBAR_NEXT:
1963 case OP_SIDEBAR_PREV:
1964 case OP_SIDEBAR_NEXT_NEW:
1965 case OP_SIDEBAR_PREV_NEW:
1966 sidebar_scroll (op);
1970 if (menu->menu == MENU_MAIN)
1971 km_error_key (MENU_MAIN);
1974 if (menu->menu == MENU_PAGER) {
1975 menu->menu = MENU_MAIN;
1976 menu->redraw = REDRAW_FULL;
1984 /* Close all open IMAP connections */
1988 mutt_menuDestroy (&menu);
1992 void mutt_set_header_color (CONTEXT * ctx, HEADER * curhdr)
1999 for (color = ColorIndexList; color; color = color->next)
2000 if (mutt_pattern_exec
2001 (color->color_pattern, M_MATCH_FULL_ADDRESS, ctx, curhdr)) {
2002 curhdr->pair = color->pair;
2005 curhdr->pair = ColorDefs[MT_COLOR_NORMAL];