2 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 #include "mutt_curses.h"
25 #include "mutt_menu.h"
38 #include "imap_private.h"
41 #include "mutt_crypt.h"
54 static const char *No_mailbox_is_open = N_("No mailbox is open.");
55 static const char *There_are_no_messages = N_("There are no messages.");
56 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
57 static const char *Function_not_permitted_in_attach_message_mode = N_("Function not permitted in attach-message mode.");
58 static const char *No_visible = N_("No visible messages.");
60 #define CHECK_IN_MAILBOX if (!Context) \
63 mutt_error _(No_mailbox_is_open); \
67 #define CHECK_MSGCOUNT if (!Context) \
70 mutt_error _(No_mailbox_is_open); \
73 else if (!Context->msgcount) \
76 mutt_error _(There_are_no_messages); \
80 #define CHECK_VISIBLE if (Context && menu->current >= Context->vcount) \
83 mutt_error _(No_visible); \
88 #define CHECK_READONLY if (Context->readonly) \
91 mutt_error _(Mailbox_is_read_only); \
95 #define CHECK_ACL(aclbit,action) \
96 if (!mutt_bit_isset(Context->rights,aclbit)) { \
98 mutt_error (_("Cannot %s: Operation not permitted by ACL"), action); \
102 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
105 mutt_error _(Function_not_permitted_in_attach_message_mode); \
109 #define CURHDR Context->hdrs[Context->v2r[menu->current]]
110 #define OLDHDR Context->hdrs[Context->v2r[menu->oldcurrent]]
111 #define UNREAD(h) mutt_thread_contains_unread (Context, h)
113 extern size_t UngetCount;
115 void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num)
117 format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR | M_FORMAT_INDEX;
118 int edgemsgno, reverse = Sort & SORT_REVERSE;
119 HEADER *h = Context->hdrs[Context->v2r[num]];
122 if ((Sort & SORT_MASK) == SORT_THREADS && h->tree)
124 flag |= M_FORMAT_TREE; /* display the thread tree */
125 if (h->display_subject)
126 flag |= M_FORMAT_FORCESUBJ;
131 if (menu->top + menu->pagelen > menu->max)
132 edgemsgno = Context->v2r[menu->max - 1];
134 edgemsgno = Context->v2r[menu->top + menu->pagelen - 1];
137 edgemsgno = Context->v2r[menu->top];
139 for (tmp = h->thread->parent; tmp; tmp = tmp->parent)
144 /* if no ancestor is visible on current screen, provisionally force
146 if (reverse ? tmp->message->msgno > edgemsgno : tmp->message->msgno < edgemsgno)
148 flag |= M_FORMAT_FORCESUBJ;
151 else if (tmp->message->virtual >= 0)
154 if (flag & M_FORMAT_FORCESUBJ)
156 for (tmp = h->thread->prev; tmp; tmp = tmp->prev)
161 /* ...but if a previous sibling is available, don't force it */
162 if (reverse ? tmp->message->msgno > edgemsgno : tmp->message->msgno < edgemsgno)
164 else if (tmp->message->virtual >= 0)
166 flag &= ~M_FORMAT_FORCESUBJ;
174 _mutt_make_string (s, l, NONULL (HdrFmt), Context, h, flag);
177 int index_color (int index_no)
179 HEADER *h = Context->hdrs[Context->v2r[index_no]];
184 mutt_set_header_color (Context, h);
188 static int ci_next_undeleted (int msgno)
192 for (i=msgno+1; i < Context->vcount; i++)
193 if (! Context->hdrs[Context->v2r[i]]->deleted)
198 static int ci_previous_undeleted (int msgno)
202 for (i=msgno-1; i>=0; i--)
203 if (! Context->hdrs[Context->v2r[i]]->deleted)
208 /* Return the index of the first new message, or failing that, the first
211 static int ci_first_message (void)
215 if (Context && Context->msgcount)
217 for (i=0; i < Context->vcount; i++)
219 if (! Context->hdrs[Context->v2r[i]]->read &&
220 ! Context->hdrs[Context->v2r[i]]->deleted)
222 if (! Context->hdrs[Context->v2r[i]]->old)
231 /* If Sort is reverse and not threaded, the latest message is first.
232 * If Sort is threaded, the latest message is first iff exactly one
233 * of Sort and SortAux are reverse.
235 if (((Sort & SORT_REVERSE) && (Sort & SORT_MASK) != SORT_THREADS) ||
236 ((Sort & SORT_MASK) == SORT_THREADS &&
237 ((Sort ^ SortAux) & SORT_REVERSE)))
240 return (Context->vcount ? Context->vcount - 1 : 0);
245 /* This should be in mx.c, but it only gets used here. */
246 static int mx_toggle_write (CONTEXT *ctx)
253 mutt_error _("Cannot toggle write on a readonly mailbox!");
260 mutt_message _("Changes to folder will be written on folder exit.");
265 mutt_message _("Changes to folder will not be written.");
271 static void update_index (MUTTMENU *menu, CONTEXT *ctx, int check,
272 int oldcount, int index_hint)
274 /* store pointers to the newly added messages */
275 HEADER **save_new = NULL;
278 /* take note of the current message */
281 if (menu->current < ctx->vcount)
282 menu->oldcurrent = index_hint;
284 oldcount = 0; /* invalid message number! */
287 /* We are in a limited view. Check if the new message(s) satisfy
288 * the limit criteria. If they do, set their virtual msgno so that
289 * they will be visible in the limited view */
292 #define THIS_BODY ctx->hdrs[j]->content
293 for (j = (check == M_REOPENED) ? 0 : oldcount; j < ctx->msgcount; j++)
298 if (mutt_pattern_exec (ctx->limit_pattern,
299 M_MATCH_FULL_ADDRESS,
302 assert (ctx->vcount < ctx->msgcount);
303 ctx->hdrs[j]->virtual = ctx->vcount;
304 ctx->v2r[ctx->vcount] = j;
305 ctx->hdrs[j]->limited = 1;
307 ctx->vsize += THIS_BODY->length + THIS_BODY->offset - THIS_BODY->hdr_offset;
313 /* save the list of new messages */
314 if (oldcount && check != M_REOPENED
315 && ((Sort & SORT_MASK) == SORT_THREADS))
317 save_new = (HEADER **) safe_malloc (sizeof (HEADER *) * (ctx->msgcount - oldcount));
318 for (j = oldcount; j < ctx->msgcount; j++)
319 save_new[j-oldcount] = ctx->hdrs[j];
322 /* if the mailbox was reopened, need to rethread from scratch */
323 mutt_sort_headers (ctx, (check == M_REOPENED));
325 /* uncollapse threads with new mail */
326 if ((Sort & SORT_MASK) == SORT_THREADS)
328 if (check == M_REOPENED)
334 for (h = ctx->tree; h; h = h->next)
336 for (j = h; !j->message; j = j->child)
338 mutt_uncollapse_thread (ctx, j->message);
340 mutt_set_virtual (ctx);
344 for (j = 0; j < ctx->msgcount - oldcount; j++)
348 for (k = 0; k < ctx->msgcount; k++)
350 HEADER *h = ctx->hdrs[k];
351 if (h == save_new[j] && (!ctx->pattern || h->limited))
352 mutt_uncollapse_thread (ctx, h);
356 mutt_set_virtual (ctx);
363 /* restore the current message to the message it was pointing to */
364 for (j = 0; j < ctx->vcount; j++)
366 if (ctx->hdrs[ctx->v2r[j]]->index == menu->oldcurrent)
374 if (menu->current < 0)
375 menu->current = ci_first_message ();
379 static void resort_index (MUTTMENU *menu)
382 HEADER *current = CURHDR;
385 mutt_sort_headers (Context, 0);
386 /* Restore the current message */
388 for (i = 0; i < Context->vcount; i++)
390 if (Context->hdrs[Context->v2r[i]] == current)
397 if ((Sort & SORT_MASK) == SORT_THREADS && menu->current < 0)
398 menu->current = mutt_parent_message (Context, current);
400 if (menu->current < 0)
401 menu->current = ci_first_message ();
403 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
406 struct mapping_t IndexHelp[] = {
407 { N_("Quit"), OP_QUIT },
408 { N_("Del"), OP_DELETE },
409 { N_("Undel"), OP_UNDELETE },
410 { N_("Save"), OP_SAVE },
411 { N_("Mail"), OP_MAIL },
412 { N_("Reply"), OP_REPLY },
413 { N_("Group"), OP_GROUP_REPLY },
414 { N_("Help"), OP_HELP },
418 /* This function handles the message index window as well as commands returned
419 * from the pager (MENU_PAGER).
421 int mutt_index_menu (void)
423 char buf[LONG_STRING], helpstr[LONG_STRING];
425 int done = 0; /* controls when to exit the "event" loop */
427 int tag = 0; /* has the tag-prefix command been pressed? */
432 char *cp; /* temporary variable. */
433 int index_hint; /* used to restore cursor position */
434 int do_buffy_notify = 1;
435 int close = 0; /* did we OP_QUIT or OP_EXIT out of this menu? */
436 int attach_msg = option(OPTATTACHMSG);
438 menu = mutt_new_menu ();
439 menu->menu = MENU_MAIN;
441 menu->pagelen = LINES - 3;
442 menu->make_entry = index_make_entry;
443 menu->color = index_color;
444 menu->current = ci_first_message ();
445 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
448 mutt_buffy_check(1); /* force the buffy check after we enter the folder */
452 tag = 0; /* clear the tag-prefix */
454 menu->max = Context ? Context->vcount : 0;
455 oldcount = Context ? Context->msgcount : 0;
457 /* check if we need to resort the index because just about
458 * any 'op' below could do mutt_enter_command(), either here or
459 * from any new menu launched, and change $sort/$sort_aux
461 if (option (OPTNEEDRESORT) && Context && Context->msgcount)
464 if (option (OPTREDRAWTREE) && Context && Context->msgcount && (Sort & SORT_MASK) == SORT_THREADS)
466 mutt_draw_tree (Context);
467 menu->redraw |= REDRAW_STATUS;
468 unset_option (OPTREDRAWTREE);
471 if (Context && !attach_msg)
474 /* check for new mail in the mailbox. If nonzero, then something has
475 * changed about the file (either we got new mail or the file was
476 * modified underneath us.)
480 imap_allow_reopen (Context);
483 index_hint = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ? CURHDR->index : 0;
485 if ((check = mx_check_mailbox (Context, &index_hint, 0)) < 0)
489 /* fatal error occurred */
491 menu->redraw = REDRAW_FULL;
494 set_option (OPTSEARCHINVALID);
496 else if (check == M_NEW_MAIL || check == M_REOPENED || check == M_FLAGS)
498 update_index (menu, Context, check, oldcount, index_hint);
500 /* notify the user of new mail */
501 if (check == M_REOPENED)
502 mutt_error _("Mailbox was externally modified. Flags may be wrong.");
503 else if (check == M_NEW_MAIL)
505 mutt_message _("New mail in this mailbox.");
506 if (option (OPTBEEPNEW))
508 } else if (check == M_FLAGS)
509 mutt_message _("Mailbox was externally modified.");
511 /* avoid the message being overwritten by buffy */
514 menu->redraw = REDRAW_FULL;
515 menu->max = Context->vcount;
517 set_option (OPTSEARCHINVALID);
523 imap_disallow_reopen (Context);
528 /* check for new mail in the incoming folders */
530 if ((newcount = mutt_buffy_check (0)) != oldcount)
531 menu->redraw |= REDRAW_STATUS;
534 if (mutt_buffy_notify () && option (OPTBEEPNEW))
544 if (menu->redraw & REDRAW_FULL)
546 menu_redraw_full (menu);
550 if (menu->menu == MENU_MAIN)
552 if (Context && Context->hdrs && !(menu->current >= Context->vcount))
554 menu_check_recenter (menu);
556 if (menu->redraw & REDRAW_INDEX)
558 menu_redraw_index (menu);
559 menu->redraw |= REDRAW_STATUS;
561 else if (menu->redraw & (REDRAW_MOTION_RESYNCH | REDRAW_MOTION))
562 menu_redraw_motion (menu);
563 else if (menu->redraw & REDRAW_CURRENT)
564 menu_redraw_current (menu);
567 if (menu->redraw & REDRAW_STATUS)
569 menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
570 CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
571 SETCOLOR (MT_COLOR_STATUS);
572 BKGDSET (MT_COLOR_STATUS);
573 mutt_paddstr (COLS, buf);
574 SETCOLOR (MT_COLOR_NORMAL);
575 BKGDSET (MT_COLOR_NORMAL);
576 menu->redraw &= ~REDRAW_STATUS;
580 if (menu->current < menu->max)
581 menu->oldcurrent = menu->current;
583 menu->oldcurrent = -1;
585 if (option (OPTARROWCURSOR))
586 move (menu->current - menu->top + menu->offset, 2);
587 else if (option (OPTBRAILLEFRIENDLY))
588 move (menu->current - menu->top + menu->offset, 0);
590 move (menu->current - menu->top + menu->offset, COLS - 1);
593 #if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
597 mutt_resize_screen ();
598 menu->redraw = REDRAW_FULL;
599 menu->menu = MENU_MAIN;
601 menu->top = 0; /* so we scroll the right amount */
603 * force a real complete redraw. clrtobot() doesn't seem to be able
604 * to handle every case without this.
606 clearok(stdscr,TRUE);
611 op = km_dokey (MENU_MAIN);
613 dprint(4, (debugfile, "mutt_index_menu[%d]: Got op %d\n", __LINE__, op));
616 continue; /* either user abort or timeout */
620 /* special handling for the tag-prefix function */
621 if (op == OP_TAG_PREFIX)
625 mutt_error _("No mailbox is open.");
629 if (!Context->tagged)
631 mutt_error _("No tagged messages.");
636 /* give visual indication that the next command is a tag- command */
637 mvaddstr (LINES - 1, 0, "tag-");
640 /* get the real command */
641 if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX)
643 /* abort tag sequence */
648 else if (option (OPTAUTOTAG) && Context && Context->tagged)
651 if (op == OP_TAG_PREFIX_COND)
655 mutt_error _("No mailbox is open.");
659 if (!Context->tagged)
665 if(tmp.op==OP_END_COND)break;
667 mutt_message _("Nothing to do.");
672 /* give visual indication that the next command is a tag- command */
673 mvaddstr (LINES - 1, 0, "tag-");
676 /* get the real command */
677 if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX)
679 /* abort tag sequence */
689 if (menu->current < menu->max)
690 menu->oldcurrent = menu->current;
692 menu->oldcurrent = -1;
694 mutt_curs_set (1); /* fallback from the pager */
700 /* ----------------------------------------------------------------------
705 menu_bottom_page (menu);
708 menu_first_entry (menu);
711 menu_middle_page (menu);
717 menu_half_down (menu);
720 menu_next_line (menu);
723 menu_prev_line (menu);
726 menu_next_page (menu);
729 menu_prev_page (menu);
732 menu_last_entry (menu);
735 menu_top_page (menu);
738 menu_current_top (menu);
740 case OP_CURRENT_MIDDLE:
741 menu_current_middle (menu);
743 case OP_CURRENT_BOTTOM:
744 menu_current_bottom (menu);
751 if (isdigit (LastKey)) mutt_ungetch (LastKey, 0);
753 if (mutt_get_field (_("Jump to message: "), buf, sizeof (buf), 0) != 0
757 if (! isdigit ((unsigned char) buf[0]))
759 mutt_error _("Argument must be a message number.");
764 if (i > 0 && i <= Context->msgcount)
766 for (j = i-1; j < Context->msgcount; j++)
768 if (Context->hdrs[j]->virtual != -1)
771 if (j >= Context->msgcount)
773 for (j = i-2; j >= 0; j--)
775 if (Context->hdrs[j]->virtual != -1)
782 menu->current = Context->hdrs[j]->virtual;
783 if (menu->menu == MENU_PAGER)
785 op = OP_DISPLAY_MESSAGE;
789 menu->redraw = REDRAW_MOTION;
792 mutt_error _("That message is not visible.");
795 mutt_error _("Invalid message number.");
799 /* --------------------------------------------------------------------
800 * `index' specific commands
803 case OP_MAIN_DELETE_PATTERN:
808 CHECK_ACL(M_ACL_DELETE, _("delete message(s)"));
811 mutt_pattern_func (M_DELETE, _("Delete messages matching: "));
812 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
816 case OP_MAIN_FETCH_MAIL:
820 menu->redraw = REDRAW_FULL;
826 mutt_help (MENU_MAIN);
827 menu->redraw = REDRAW_FULL;
830 case OP_MAIN_SHOW_LIMIT:
832 if (!Context->pattern)
833 mutt_message _("No limit pattern is in effect.");
837 /* i18n: ask for a limit to apply */
838 snprintf (buf, sizeof(buf), _("Limit: %s"),Context->pattern);
839 mutt_message ("%s", buf);
846 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
848 if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
850 if (menu->oldcurrent >= 0)
852 /* try to find what used to be the current message */
854 for (i = 0; i < Context->vcount; i++)
855 if (Context->hdrs[Context->v2r[i]]->index == menu->oldcurrent)
860 if (menu->current < 0) menu->current = 0;
864 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
865 if (Context->msgcount && (Sort & SORT_MASK) == SORT_THREADS)
866 mutt_draw_tree (Context);
867 menu->redraw = REDRAW_FULL;
869 if (Context->pattern)
870 mutt_message _("To view all messages, limit to \"all\".");
882 if (query_quadoption (OPT_QUIT, _("Quit Mutt?")) == M_YES)
886 oldcount = Context ? Context->msgcount : 0;
888 if (!Context || (check = mx_close_mailbox (Context, &index_hint)) == 0)
892 if (check == M_NEW_MAIL || check == M_REOPENED)
893 update_index (menu, Context, check, oldcount, index_hint);
895 menu->redraw = REDRAW_FULL; /* new mail arrived? */
896 set_option (OPTSEARCHINVALID);
903 clearok (stdscr, TRUE);
904 menu->redraw = REDRAW_FULL;
908 case OP_SEARCH_REVERSE:
910 case OP_SEARCH_OPPOSITE:
914 if ((menu->current = mutt_search_command (menu->current, op)) == -1)
915 menu->current = menu->oldcurrent;
917 menu->redraw = REDRAW_MOTION;
921 case OP_SORT_REVERSE:
923 if (mutt_select_sort ((op == OP_SORT_REVERSE)) == 0)
925 if (Context && Context->msgcount)
928 set_option (OPTSEARCHINVALID);
930 menu->redraw |= REDRAW_STATUS;
938 if (tag && !option (OPTAUTOTAG))
940 for (j = 0; j < Context->vcount; j++)
941 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_TAG, 0);
942 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
946 mutt_set_flag (Context, CURHDR, M_TAG, !CURHDR->tagged);
948 Context->last_tag = CURHDR->tagged ? CURHDR :
949 ((Context->last_tag == CURHDR && !CURHDR->tagged)
950 ? NULL : Context->last_tag);
952 menu->redraw = REDRAW_STATUS;
953 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
956 menu->redraw |= REDRAW_MOTION_RESYNCH;
959 menu->redraw |= REDRAW_CURRENT;
963 case OP_MAIN_TAG_PATTERN:
967 mutt_pattern_func (M_TAG, _("Tag messages matching: "));
968 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
971 case OP_MAIN_UNDELETE_PATTERN:
976 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
978 if (mutt_pattern_func (M_UNDELETE, _("Undelete messages matching: ")) == 0)
979 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
982 case OP_MAIN_UNTAG_PATTERN:
986 if (mutt_pattern_func (M_UNTAG, _("Untag messages matching: ")) == 0)
987 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
990 /* --------------------------------------------------------------------
991 * The following operations can be performed inside of the pager.
995 case OP_MAIN_IMAP_FETCH:
996 if (Context && Context->magic == M_IMAP)
997 imap_check_mailbox (Context, &index_hint, 1);
1001 case OP_MAIN_SYNC_FOLDER:
1003 if (Context && !Context->msgcount)
1010 int oldvcount = Context->vcount;
1011 int oldcount = Context->msgcount;
1015 /* calculate the number of messages _above_ the cursor,
1016 * so we can keep the cursor on the current message
1018 for (j = 0; j <= menu->current; j++)
1020 if (Context->hdrs[Context->v2r[j]]->deleted)
1024 if ((check = mx_sync_mailbox (Context, &index_hint)) == 0)
1026 if (Context->vcount != oldvcount)
1027 menu->current -= dcount;
1028 set_option (OPTSEARCHINVALID);
1030 else if (check == M_NEW_MAIL || check == M_REOPENED)
1031 update_index (menu, Context, check, oldcount, index_hint);
1034 * do a sanity check even if mx_sync_mailbox failed.
1037 if (menu->current < 0 || menu->current >= Context->vcount)
1038 menu->current = ci_first_message ();
1041 /* check for a fatal error, or all messages deleted */
1045 /* if we were in the pager, redisplay the message */
1046 if (menu->menu == MENU_PAGER)
1048 op = OP_DISPLAY_MESSAGE;
1052 menu->redraw = REDRAW_FULL;
1055 case OP_MAIN_CHANGE_FOLDER:
1056 case OP_MAIN_NEXT_UNREAD_MAILBOX:
1059 op = OP_MAIN_CHANGE_FOLDER_READONLY;
1061 /* fallback to the readonly case */
1063 case OP_MAIN_CHANGE_FOLDER_READONLY:
1065 if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1066 cp = _("Open mailbox in read-only mode");
1068 cp = _("Open mailbox");
1071 if ((op == OP_MAIN_NEXT_UNREAD_MAILBOX) && Context && Context->path)
1073 strfcpy (buf, Context->path, sizeof (buf));
1074 mutt_pretty_mailbox (buf);
1075 mutt_buffy (buf, sizeof (buf));
1078 mutt_error _("No mailboxes have new mail");
1084 mutt_buffy (buf, sizeof (buf));
1086 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
1088 if (menu->menu == MENU_PAGER)
1090 op = OP_DISPLAY_MESSAGE;
1098 CLEARLINE (LINES-1);
1103 mutt_expand_path (buf, sizeof (buf));
1104 if (mx_get_magic (buf) <= 0)
1106 mutt_error (_("%s is not a mailbox."), buf);
1109 mutt_str_replace (&CurrentFolder, buf);
1115 mutt_str_replace (&LastFolder, Context->path);
1116 oldcount = Context ? Context->msgcount : 0;
1118 if ((check = mx_close_mailbox (Context, &index_hint)) != 0)
1120 if (check == M_NEW_MAIL || check == M_REOPENED)
1121 update_index (menu, Context, check, oldcount, index_hint);
1123 set_option (OPTSEARCHINVALID);
1124 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1132 /* Set CurrentMenu to MENU_MAIN before executing any folder
1133 * hooks so that all the index menu functions are available to
1137 CurrentMenu = MENU_MAIN;
1138 mutt_folder_hook (buf);
1140 if ((Context = mx_open_mailbox (buf,
1141 (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
1142 M_READONLY : 0, NULL)) != NULL)
1144 menu->current = ci_first_message ();
1149 mutt_clear_error ();
1150 mutt_buffy_check(1); /* force the buffy check after we have changed
1152 menu->redraw = REDRAW_FULL;
1153 set_option (OPTSEARCHINVALID);
1156 case OP_DISPLAY_MESSAGE:
1157 case OP_DISPLAY_HEADERS: /* don't weed the headers */
1162 * toggle the weeding of headers so that a user can press the key
1163 * again while reading the message.
1165 if (op == OP_DISPLAY_HEADERS)
1166 toggle_option (OPTWEED);
1168 unset_option (OPTNEEDRESORT);
1170 if ((Sort & SORT_MASK) == SORT_THREADS && CURHDR->collapsed)
1172 mutt_uncollapse_thread (Context, CURHDR);
1173 mutt_set_virtual (Context);
1174 if (option (OPTUNCOLLAPSEJUMP))
1175 menu->current = mutt_thread_next_unread (Context, CURHDR);
1178 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1179 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1180 if ((op = mutt_display_message (CURHDR)) == -1)
1182 unset_option (OPTNEEDRESORT);
1186 menu->menu = MENU_PAGER;
1187 menu->oldcurrent = menu->current;
1193 if (menu->menu == MENU_MAIN && attach_msg)
1199 if ((menu->menu == MENU_MAIN)
1200 && (query_quadoption (OPT_QUIT,
1201 _("Exit Mutt without saving?")) == M_YES))
1205 mx_fastclose_mailbox (Context);
1212 case OP_MAIN_BREAK_THREAD:
1218 if ((Sort & SORT_MASK) != SORT_THREADS)
1219 mutt_error _("Threading is not enabled.");
1223 HEADER *oldcur = CURHDR;
1225 mutt_break_thread (CURHDR);
1226 mutt_sort_headers (Context, 1);
1227 menu->current = oldcur->virtual;
1230 Context->changed = 1;
1231 mutt_message _("Thread broken");
1233 if (menu->menu == MENU_PAGER)
1235 op = OP_DISPLAY_MESSAGE;
1239 menu->redraw |= REDRAW_INDEX;
1244 case OP_MAIN_LINK_THREADS:
1249 CHECK_ACL(M_ACL_DELETE, _("link threads"));
1251 if ((Sort & SORT_MASK) != SORT_THREADS)
1252 mutt_error _("Threading is not enabled.");
1253 else if (!CURHDR->env->message_id)
1254 mutt_error _("No Message-ID: header available to link thread");
1255 else if (!tag && (!Context->last_tag || !Context->last_tag->tagged))
1256 mutt_error _("First, please tag a message to be linked here");
1259 HEADER *oldcur = CURHDR;
1261 if (mutt_link_threads (CURHDR, tag ? NULL : Context->last_tag,
1264 mutt_sort_headers (Context, 1);
1265 menu->current = oldcur->virtual;
1267 Context->changed = 1;
1268 mutt_message _("Threads linked");
1271 mutt_error _("No thread linked");
1274 if (menu->menu == MENU_PAGER)
1276 op = OP_DISPLAY_MESSAGE;
1280 menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
1289 mutt_edit_content_type (CURHDR, CURHDR->content, NULL);
1290 /* if we were in the pager, redisplay the message */
1291 if (menu->menu == MENU_PAGER)
1293 op = OP_DISPLAY_MESSAGE;
1297 menu->redraw = REDRAW_CURRENT;
1300 case OP_MAIN_NEXT_UNDELETED:
1304 if (menu->current >= Context->vcount - 1)
1306 if (menu->menu == MENU_MAIN)
1307 mutt_error _("You are on the last message.");
1310 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1312 menu->current = menu->oldcurrent;
1313 if (menu->menu == MENU_MAIN)
1314 mutt_error _("No undeleted messages.");
1316 else if (menu->menu == MENU_PAGER)
1318 op = OP_DISPLAY_MESSAGE;
1322 menu->redraw = REDRAW_MOTION;
1329 if (menu->current >= Context->vcount - 1)
1331 if (menu->menu == MENU_MAIN)
1332 mutt_error _("You are on the last message.");
1336 if (menu->menu == MENU_PAGER)
1338 op = OP_DISPLAY_MESSAGE;
1342 menu->redraw = REDRAW_MOTION;
1345 case OP_MAIN_PREV_UNDELETED:
1349 if (menu->current < 1)
1351 mutt_error _("You are on the first message.");
1354 if ((menu->current = ci_previous_undeleted (menu->current)) == -1)
1356 menu->current = menu->oldcurrent;
1357 if (menu->menu == MENU_MAIN)
1358 mutt_error _("No undeleted messages.");
1360 else if (menu->menu == MENU_PAGER)
1362 op = OP_DISPLAY_MESSAGE;
1366 menu->redraw = REDRAW_MOTION;
1373 if (menu->current < 1)
1375 if (menu->menu == MENU_MAIN) mutt_error _("You are on the first message.");
1379 if (menu->menu == MENU_PAGER)
1381 op = OP_DISPLAY_MESSAGE;
1385 menu->redraw = REDRAW_MOTION;
1388 case OP_DECRYPT_COPY:
1389 case OP_DECRYPT_SAVE:
1393 case OP_COPY_MESSAGE:
1395 case OP_DECODE_COPY:
1396 case OP_DECODE_SAVE:
1399 if (mutt_save_message (tag ? NULL : CURHDR,
1400 (op == OP_DECRYPT_SAVE) ||
1401 (op == OP_SAVE) || (op == OP_DECODE_SAVE),
1402 (op == OP_DECODE_SAVE) || (op == OP_DECODE_COPY),
1403 (op == OP_DECRYPT_SAVE) || (op == OP_DECRYPT_COPY) ||
1405 &menu->redraw) == 0 &&
1406 (op == OP_SAVE || op == OP_DECODE_SAVE || op == OP_DECRYPT_SAVE)
1410 menu->redraw |= REDRAW_INDEX;
1411 else if (option (OPTRESOLVE))
1413 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1415 menu->current = menu->oldcurrent;
1416 menu->redraw |= REDRAW_CURRENT;
1419 menu->redraw |= REDRAW_MOTION_RESYNCH;
1422 menu->redraw |= REDRAW_CURRENT;
1426 case OP_MAIN_NEXT_NEW:
1427 case OP_MAIN_NEXT_UNREAD:
1428 case OP_MAIN_PREV_NEW:
1429 case OP_MAIN_PREV_UNREAD:
1430 case OP_MAIN_NEXT_NEW_THEN_UNREAD:
1431 case OP_MAIN_PREV_NEW_THEN_UNREAD:
1434 int first_unread = -1;
1442 for (j = 0; j != Context->vcount; j++)
1444 #define CURHDRi Context->hdrs[Context->v2r[i]]
1445 if (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_NEXT_NEW_THEN_UNREAD)
1448 if (i > Context->vcount - 1)
1450 mutt_message _("Search wrapped to top.");
1459 mutt_message _("Search wrapped to bottom.");
1460 i = Context->vcount - 1;
1464 if (CURHDRi->collapsed && (Sort & SORT_MASK) == SORT_THREADS)
1466 if (UNREAD (CURHDRi) && first_unread == -1)
1468 if (UNREAD (CURHDRi) == 1 && first_new == -1)
1471 else if ((!CURHDRi->deleted && !CURHDRi->read))
1473 if (first_unread == -1)
1475 if ((!CURHDRi->old) && first_new == -1)
1479 if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD) &&
1482 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1483 op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1488 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1489 op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1491 menu->current = first_new;
1492 else if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD ||
1493 op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1494 && first_unread != -1)
1495 menu->current = first_unread;
1497 if (menu->current == -1)
1499 menu->current = menu->oldcurrent;
1500 mutt_error ("%s%s.", (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW) ? _("No new messages") : _("No unread messages"),
1501 Context->pattern ? _(" in this limited view") : "");
1503 else if (menu->menu == MENU_PAGER)
1505 op = OP_DISPLAY_MESSAGE;
1509 menu->redraw = REDRAW_MOTION;
1512 case OP_FLAG_MESSAGE:
1517 CHECK_ACL(M_ACL_WRITE, _("flag message"));
1521 for (j = 0; j < Context->vcount; j++)
1523 if (Context->hdrs[Context->v2r[j]]->tagged)
1524 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]],
1525 M_FLAG, !Context->hdrs[Context->v2r[j]]->flagged);
1528 menu->redraw |= REDRAW_INDEX;
1532 mutt_set_flag (Context, CURHDR, M_FLAG, !CURHDR->flagged);
1533 if (option (OPTRESOLVE))
1535 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1537 menu->current = menu->oldcurrent;
1538 menu->redraw = REDRAW_CURRENT;
1541 menu->redraw = REDRAW_MOTION_RESYNCH;
1544 menu->redraw = REDRAW_CURRENT;
1546 menu->redraw |= REDRAW_STATUS;
1554 CHECK_ACL(M_ACL_SEEN, _("toggle new"));
1558 for (j = 0; j < Context->vcount; j++)
1560 if (Context->hdrs[Context->v2r[j]]->tagged)
1562 if (Context->hdrs[Context->v2r[j]]->read ||
1563 Context->hdrs[Context->v2r[j]]->old)
1564 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_NEW, 1);
1566 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_READ, 1);
1569 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
1573 if (CURHDR->read || CURHDR->old)
1574 mutt_set_flag (Context, CURHDR, M_NEW, 1);
1576 mutt_set_flag (Context, CURHDR, M_READ, 1);
1578 if (option (OPTRESOLVE))
1580 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1582 menu->current = menu->oldcurrent;
1583 menu->redraw = REDRAW_CURRENT;
1586 menu->redraw = REDRAW_MOTION_RESYNCH;
1589 menu->redraw = REDRAW_CURRENT;
1590 menu->redraw |= REDRAW_STATUS;
1594 case OP_TOGGLE_WRITE:
1597 if (mx_toggle_write (Context) == 0)
1598 menu->redraw |= REDRAW_STATUS;
1601 case OP_MAIN_NEXT_THREAD:
1602 case OP_MAIN_NEXT_SUBTHREAD:
1603 case OP_MAIN_PREV_THREAD:
1604 case OP_MAIN_PREV_SUBTHREAD:
1610 case OP_MAIN_NEXT_THREAD:
1611 menu->current = mutt_next_thread (CURHDR);
1614 case OP_MAIN_NEXT_SUBTHREAD:
1615 menu->current = mutt_next_subthread (CURHDR);
1618 case OP_MAIN_PREV_THREAD:
1619 menu->current = mutt_previous_thread (CURHDR);
1622 case OP_MAIN_PREV_SUBTHREAD:
1623 menu->current = mutt_previous_subthread (CURHDR);
1627 if (menu->current < 0)
1629 menu->current = menu->oldcurrent;
1630 if (op == OP_MAIN_NEXT_THREAD || op == OP_MAIN_NEXT_SUBTHREAD)
1631 mutt_error _("No more threads.");
1633 mutt_error _("You are on the first thread.");
1635 else if (menu->menu == MENU_PAGER)
1637 op = OP_DISPLAY_MESSAGE;
1641 menu->redraw = REDRAW_MOTION;
1644 case OP_MAIN_PARENT_MESSAGE:
1649 if ((menu->current = mutt_parent_message (Context, CURHDR)) < 0)
1651 menu->current = menu->oldcurrent;
1653 else if (menu->menu == MENU_PAGER)
1655 op = OP_DISPLAY_MESSAGE;
1659 menu->redraw = REDRAW_MOTION;
1662 case OP_MAIN_SET_FLAG:
1663 case OP_MAIN_CLEAR_FLAG:
1668 /* CHECK_ACL(M_ACL_WRITE); */
1670 if (mutt_change_flag (tag ? NULL : CURHDR, (op == OP_MAIN_SET_FLAG)) == 0)
1672 menu->redraw = REDRAW_STATUS;
1674 menu->redraw |= REDRAW_INDEX;
1675 else if (option (OPTRESOLVE))
1677 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1679 menu->current = menu->oldcurrent;
1680 menu->redraw |= REDRAW_CURRENT;
1683 menu->redraw |= REDRAW_MOTION_RESYNCH;
1686 menu->redraw |= REDRAW_CURRENT;
1690 case OP_MAIN_COLLAPSE_THREAD:
1694 if ((Sort & SORT_MASK) != SORT_THREADS)
1696 mutt_error _("Threading is not enabled.");
1700 if (CURHDR->collapsed)
1702 menu->current = mutt_uncollapse_thread (Context, CURHDR);
1703 mutt_set_virtual (Context);
1704 if (option (OPTUNCOLLAPSEJUMP))
1705 menu->current = mutt_thread_next_unread (Context, CURHDR);
1707 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR))
1709 menu->current = mutt_collapse_thread (Context, CURHDR);
1710 mutt_set_virtual (Context);
1714 mutt_error _("Thread contains unread messages.");
1718 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1722 case OP_MAIN_COLLAPSE_ALL:
1726 if ((Sort & SORT_MASK) != SORT_THREADS)
1728 mutt_error _("Threading is not enabled.");
1734 THREAD *thread, *top;
1737 if (CURHDR->collapsed)
1738 final = mutt_uncollapse_thread (Context, CURHDR);
1739 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR))
1740 final = mutt_collapse_thread (Context, CURHDR);
1742 final = CURHDR->virtual;
1744 base = Context->hdrs[Context->v2r[final]];
1746 top = Context->tree;
1747 Context->collapsed = !Context->collapsed;
1748 while ((thread = top) != NULL)
1750 while (!thread->message)
1751 thread = thread->child;
1752 h = thread->message;
1754 if (h->collapsed != Context->collapsed)
1757 mutt_uncollapse_thread (Context, h);
1758 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (h))
1759 mutt_collapse_thread (Context, h);
1764 mutt_set_virtual (Context);
1765 for (j = 0; j < Context->vcount; j++)
1767 if (Context->hdrs[Context->v2r[j]]->index == base->index)
1774 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1778 /* --------------------------------------------------------------------
1779 * These functions are invoked directly from the internal-pager
1782 case OP_BOUNCE_MESSAGE:
1787 ci_bounce_message (tag ? NULL : CURHDR, &menu->redraw);
1790 case OP_CREATE_ALIAS:
1792 mutt_create_alias (Context && Context->vcount ? CURHDR->env : NULL, NULL);
1793 MAYBE_REDRAW (menu->redraw);
1794 menu->redraw |= REDRAW_CURRENT;
1799 mutt_query_menu (NULL, 0);
1800 MAYBE_REDRAW (menu->redraw);
1808 CHECK_ACL(M_ACL_DELETE, _("delete message"));
1812 mutt_tag_set_flag (M_DELETE, 1);
1813 if (option (OPTDELETEUNTAG))
1814 mutt_tag_set_flag (M_TAG, 0);
1815 menu->redraw = REDRAW_INDEX;
1819 mutt_set_flag (Context, CURHDR, M_DELETE, 1);
1820 if (option (OPTDELETEUNTAG))
1821 mutt_set_flag (Context, CURHDR, M_TAG, 0);
1822 if (option (OPTRESOLVE))
1824 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1826 menu->current = menu->oldcurrent;
1827 menu->redraw = REDRAW_CURRENT;
1829 else if (menu->menu == MENU_PAGER)
1831 op = OP_DISPLAY_MESSAGE;
1835 menu->redraw |= REDRAW_MOTION_RESYNCH;
1838 menu->redraw = REDRAW_CURRENT;
1840 menu->redraw |= REDRAW_STATUS;
1843 case OP_DELETE_THREAD:
1844 case OP_DELETE_SUBTHREAD:
1849 CHECK_ACL(M_ACL_DELETE, _("delete message(s)"));
1851 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 1,
1852 op == OP_DELETE_THREAD ? 0 : 1);
1856 if (option (OPTDELETEUNTAG))
1857 mutt_thread_set_flag (CURHDR, M_TAG, 0,
1858 op == OP_DELETE_THREAD ? 0 : 1);
1859 if (option (OPTRESOLVE))
1860 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1861 menu->current = menu->oldcurrent;
1862 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1866 case OP_DISPLAY_ADDRESS:
1870 mutt_display_address (CURHDR->env);
1873 case OP_ENTER_COMMAND:
1875 CurrentMenu = MENU_MAIN;
1876 mutt_enter_command ();
1877 mutt_check_rescore (Context);
1878 if (option (OPTFORCEREDRAWINDEX))
1879 menu->redraw = REDRAW_FULL;
1880 unset_option (OPTFORCEREDRAWINDEX);
1881 unset_option (OPTFORCEREDRAWPAGER);
1884 case OP_EDIT_MESSAGE:
1890 CHECK_ACL(M_ACL_INSERT, _("edit message"));
1892 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1893 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1894 mutt_edit_message (Context, tag ? NULL : CURHDR);
1895 menu->redraw = REDRAW_FULL;
1899 case OP_FORWARD_MESSAGE:
1904 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1905 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1906 ci_send_message (SENDFORWARD, NULL, NULL, Context, tag ? NULL : CURHDR);
1907 menu->redraw = REDRAW_FULL;
1911 case OP_FORGET_PASSPHRASE:
1912 crypt_forget_passphrase ();
1915 case OP_GROUP_REPLY:
1920 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1921 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1922 ci_send_message (SENDREPLY|SENDGROUPREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
1923 menu->redraw = REDRAW_FULL;
1931 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1932 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1933 ci_send_message (SENDREPLY|SENDLISTREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
1934 menu->redraw = REDRAW_FULL;
1940 ci_send_message (0, NULL, NULL, Context, NULL);
1941 menu->redraw = REDRAW_FULL;
1945 if (!(WithCrypto & APPLICATION_PGP))
1948 ci_send_message (SENDKEY, NULL, NULL, NULL, NULL);
1949 menu->redraw = REDRAW_FULL;
1953 case OP_EXTRACT_KEYS:
1958 crypt_extract_keys_from_messages(tag ? NULL : CURHDR);
1959 menu->redraw = REDRAW_FULL;
1963 case OP_CHECK_TRADITIONAL:
1964 if (!(WithCrypto & APPLICATION_PGP))
1968 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1969 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1971 if (menu->menu == MENU_PAGER)
1973 op = OP_DISPLAY_MESSAGE;
1982 mutt_pipe_message (tag ? NULL : CURHDR);
1985 /* in an IMAP folder index with imap_peek=no, piping could change
1986 * new or old messages status to read. Redraw what's needed.
1988 if (Context->magic == M_IMAP && !option (OPTIMAPPEEK))
1990 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
1994 MAYBE_REDRAW (menu->redraw);
2001 mutt_print_message (tag ? NULL : CURHDR);
2004 /* in an IMAP folder index with imap_peek=no, printing could change
2005 * new or old messages status to read. Redraw what's needed.
2007 if (Context->magic == M_IMAP && !option (OPTIMAPPEEK))
2009 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
2015 case OP_MAIN_READ_THREAD:
2016 case OP_MAIN_READ_SUBTHREAD:
2021 CHECK_ACL(M_ACL_SEEN, _("mark message(s) as read"));
2023 rc = mutt_thread_set_flag (CURHDR, M_READ, 1,
2024 op == OP_MAIN_READ_THREAD ? 0 : 1);
2028 if (option (OPTRESOLVE))
2030 if ((menu->current = (op == OP_MAIN_READ_THREAD ?
2031 mutt_next_thread (CURHDR) : mutt_next_subthread (CURHDR))) == -1)
2032 menu->current = menu->oldcurrent;
2034 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2038 case OP_RECALL_MESSAGE:
2041 ci_send_message (SENDPOSTPONED, NULL, NULL, Context, NULL);
2042 menu->redraw = REDRAW_FULL;
2053 for (j = 0; j < Context->vcount; j++)
2055 if (Context->hdrs[Context->v2r[j]]->tagged)
2056 mutt_resend_message (NULL, Context, Context->hdrs[Context->v2r[j]]);
2060 mutt_resend_message (NULL, Context, CURHDR);
2062 menu->redraw = REDRAW_FULL;
2070 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
2071 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
2072 ci_send_message (SENDREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
2073 menu->redraw = REDRAW_FULL;
2076 case OP_SHELL_ESCAPE:
2078 mutt_shell_escape ();
2079 MAYBE_REDRAW (menu->redraw);
2083 case OP_TAG_SUBTHREAD:
2087 rc = mutt_thread_set_flag (CURHDR, M_TAG, !CURHDR->tagged,
2088 op == OP_TAG_THREAD ? 0 : 1);
2092 if (option (OPTRESOLVE))
2094 if (op == OP_TAG_THREAD)
2095 menu->current = mutt_next_thread (CURHDR);
2097 menu->current = mutt_next_subthread (CURHDR);
2099 if (menu->current == -1)
2100 menu->current = menu->oldcurrent;
2102 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2111 CHECK_ACL(M_ACL_DELETE, _("undelete message"));
2115 mutt_tag_set_flag (M_DELETE, 0);
2116 menu->redraw = REDRAW_INDEX;
2120 mutt_set_flag (Context, CURHDR, M_DELETE, 0);
2121 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
2124 menu->redraw = REDRAW_MOTION_RESYNCH;
2127 menu->redraw = REDRAW_CURRENT;
2129 menu->redraw |= REDRAW_STATUS;
2132 case OP_UNDELETE_THREAD:
2133 case OP_UNDELETE_SUBTHREAD:
2138 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
2140 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2141 op == OP_UNDELETE_THREAD ? 0 : 1);
2145 if (option (OPTRESOLVE))
2147 if (op == OP_UNDELETE_THREAD)
2148 menu->current = mutt_next_thread (CURHDR);
2150 menu->current = mutt_next_subthread (CURHDR);
2152 if (menu->current == -1)
2153 menu->current = menu->oldcurrent;
2155 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2167 case OP_VIEW_ATTACHMENTS:
2170 mutt_view_attachments (CURHDR);
2171 if (CURHDR->attach_del)
2172 Context->changed = 1;
2173 menu->redraw = REDRAW_FULL;
2184 if (menu->menu == MENU_MAIN)
2185 km_error_key (MENU_MAIN);
2188 if (menu->menu == MENU_PAGER)
2190 menu->menu = MENU_MAIN;
2191 menu->redraw = REDRAW_FULL;
2193 set_option (OPTWEED); /* turn header weeding back on. */
2200 mutt_menuDestroy (&menu);
2204 void mutt_set_header_color (CONTEXT *ctx, HEADER *curhdr)
2211 for (color = ColorIndexList; color; color = color->next)
2212 if (mutt_pattern_exec (color->color_pattern, M_MATCH_FULL_ADDRESS, ctx, curhdr))
2214 curhdr->pair = color->pair;
2217 curhdr->pair = ColorDefs[MT_COLOR_NORMAL];