2 * Copyright (C) 1996-2000,2002 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"
36 #include "imap_private.h"
39 #include "mutt_crypt.h"
52 static const char *No_mailbox_is_open = N_("No mailbox is open.");
53 static const char *There_are_no_messages = N_("There are no messages.");
54 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
55 static const char *Function_not_permitted_in_attach_message_mode = N_("Function not permitted in attach-message mode.");
56 static const char *No_visible = N_("No visible messages.");
58 #define CHECK_IN_MAILBOX if (!Context) \
61 mutt_error _(No_mailbox_is_open); \
65 #define CHECK_MSGCOUNT if (!Context) \
68 mutt_error _(No_mailbox_is_open); \
71 else if (!Context->msgcount) \
74 mutt_error _(There_are_no_messages); \
78 #define CHECK_VISIBLE if (Context && menu->current >= Context->vcount) \
81 mutt_error _(No_visible); \
86 #define CHECK_READONLY if (Context->readonly) \
89 mutt_error _(Mailbox_is_read_only); \
93 #define CHECK_ACL(aclbit,action) \
94 if (!mutt_bit_isset(Context->rights,aclbit)) { \
96 mutt_error (_("Cannot %s: Operation not permitted by ACL"), action); \
100 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
103 mutt_error _(Function_not_permitted_in_attach_message_mode); \
107 #define CURHDR Context->hdrs[Context->v2r[menu->current]]
108 #define OLDHDR Context->hdrs[Context->v2r[menu->oldcurrent]]
109 #define UNREAD(h) mutt_thread_contains_unread (Context, h)
111 extern size_t UngetCount;
113 void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num)
115 format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR | M_FORMAT_INDEX;
116 int edgemsgno, reverse = Sort & SORT_REVERSE;
117 HEADER *h = Context->hdrs[Context->v2r[num]];
120 if ((Sort & SORT_MASK) == SORT_THREADS && h->tree)
122 flag |= M_FORMAT_TREE; /* display the thread tree */
123 if (h->display_subject)
124 flag |= M_FORMAT_FORCESUBJ;
129 if (menu->top + menu->pagelen > menu->max)
130 edgemsgno = Context->v2r[menu->max - 1];
132 edgemsgno = Context->v2r[menu->top + menu->pagelen - 1];
135 edgemsgno = Context->v2r[menu->top];
137 for (tmp = h->thread->parent; tmp; tmp = tmp->parent)
142 /* if no ancestor is visible on current screen, provisionally force
144 if (reverse ? tmp->message->msgno > edgemsgno : tmp->message->msgno < edgemsgno)
146 flag |= M_FORMAT_FORCESUBJ;
149 else if (tmp->message->virtual >= 0)
152 if (flag & M_FORMAT_FORCESUBJ)
154 for (tmp = h->thread->prev; tmp; tmp = tmp->prev)
159 /* ...but if a previous sibling is available, don't force it */
160 if (reverse ? tmp->message->msgno > edgemsgno : tmp->message->msgno < edgemsgno)
162 else if (tmp->message->virtual >= 0)
164 flag &= ~M_FORMAT_FORCESUBJ;
172 _mutt_make_string (s, l, NONULL (HdrFmt), Context, h, flag);
175 int index_color (int index_no)
177 HEADER *h = Context->hdrs[Context->v2r[index_no]];
182 mutt_set_header_color (Context, h);
186 static int ci_next_undeleted (int msgno)
190 for (i=msgno+1; i < Context->vcount; i++)
191 if (! Context->hdrs[Context->v2r[i]]->deleted)
196 static int ci_previous_undeleted (int msgno)
200 for (i=msgno-1; i>=0; i--)
201 if (! Context->hdrs[Context->v2r[i]]->deleted)
206 /* Return the index of the first new message, or failing that, the first
209 static int ci_first_message (void)
213 if (Context && Context->msgcount)
215 for (i=0; i < Context->vcount; i++)
217 if (! Context->hdrs[Context->v2r[i]]->read &&
218 ! Context->hdrs[Context->v2r[i]]->deleted)
220 if (! Context->hdrs[Context->v2r[i]]->old)
229 /* If Sort is reverse and not threaded, the latest message is first.
230 * If Sort is threaded, the latest message is first iff exactly one
231 * of Sort and SortAux are reverse.
233 if (((Sort & SORT_REVERSE) && (Sort & SORT_MASK) != SORT_THREADS) ||
234 ((Sort & SORT_MASK) == SORT_THREADS &&
235 ((Sort ^ SortAux) & SORT_REVERSE)))
238 return (Context->vcount ? Context->vcount - 1 : 0);
243 /* This should be in mx.c, but it only gets used here. */
244 static int mx_toggle_write (CONTEXT *ctx)
251 mutt_error _("Cannot toggle write on a readonly mailbox!");
258 mutt_message _("Changes to folder will be written on folder exit.");
263 mutt_message _("Changes to folder will not be written.");
269 static void update_index (MUTTMENU *menu, CONTEXT *ctx, int check,
270 int oldcount, int index_hint)
272 /* store pointers to the newly added messages */
273 HEADER **save_new = NULL;
276 /* take note of the current message */
279 if (menu->current < ctx->vcount)
280 menu->oldcurrent = index_hint;
282 oldcount = 0; /* invalid message number! */
285 /* We are in a limited view. Check if the new message(s) satisfy
286 * the limit criteria. If they do, set their virtual msgno so that
287 * they will be visible in the limited view */
290 #define THIS_BODY ctx->hdrs[j]->content
291 for (j = (check == M_REOPENED) ? 0 : oldcount; j < ctx->msgcount; j++)
296 if (mutt_pattern_exec (ctx->limit_pattern,
297 M_MATCH_FULL_ADDRESS,
300 assert (ctx->vcount < ctx->msgcount);
301 ctx->hdrs[j]->virtual = ctx->vcount;
302 ctx->v2r[ctx->vcount] = j;
303 ctx->hdrs[j]->limited = 1;
305 ctx->vsize += THIS_BODY->length + THIS_BODY->offset - THIS_BODY->hdr_offset;
311 /* save the list of new messages */
312 if (oldcount && check != M_REOPENED
313 && ((Sort & SORT_MASK) == SORT_THREADS))
315 save_new = (HEADER **) safe_malloc (sizeof (HEADER *) * (ctx->msgcount - oldcount));
316 for (j = oldcount; j < ctx->msgcount; j++)
317 save_new[j-oldcount] = ctx->hdrs[j];
320 /* if the mailbox was reopened, need to rethread from scratch */
321 mutt_sort_headers (ctx, (check == M_REOPENED));
323 /* uncollapse threads with new mail */
324 if ((Sort & SORT_MASK) == SORT_THREADS)
326 if (check == M_REOPENED)
332 for (h = ctx->tree; h; h = h->next)
334 for (j = h; !j->message; j = j->child)
336 mutt_uncollapse_thread (ctx, j->message);
338 mutt_set_virtual (ctx);
342 for (j = 0; j < ctx->msgcount - oldcount; j++)
346 for (k = 0; k < ctx->msgcount; k++)
348 HEADER *h = ctx->hdrs[k];
349 if (h == save_new[j] && (!ctx->pattern || h->limited))
350 mutt_uncollapse_thread (ctx, h);
354 mutt_set_virtual (ctx);
361 /* restore the current message to the message it was pointing to */
362 for (j = 0; j < ctx->vcount; j++)
364 if (ctx->hdrs[ctx->v2r[j]]->index == menu->oldcurrent)
372 if (menu->current < 0)
373 menu->current = ci_first_message ();
377 static void resort_index (MUTTMENU *menu)
380 HEADER *current = CURHDR;
383 mutt_sort_headers (Context, 0);
384 /* Restore the current message */
386 for (i = 0; i < Context->vcount; i++)
388 if (Context->hdrs[Context->v2r[i]] == current)
395 if ((Sort & SORT_MASK) == SORT_THREADS && menu->current < 0)
396 menu->current = mutt_parent_message (Context, current);
398 if (menu->current < 0)
399 menu->current = ci_first_message ();
401 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
404 static struct mapping_t IndexHelp[] = {
405 { N_("Quit"), OP_QUIT },
406 { N_("Del"), OP_DELETE },
407 { N_("Undel"), OP_UNDELETE },
408 { N_("Save"), OP_SAVE },
409 { N_("Mail"), OP_MAIL },
410 { N_("Reply"), OP_REPLY },
411 { N_("Group"), OP_GROUP_REPLY },
412 { N_("Help"), OP_HELP },
416 /* This function handles the message index window as well as commands returned
417 * from the pager (MENU_PAGER).
419 int mutt_index_menu (void)
421 char buf[LONG_STRING], helpstr[LONG_STRING];
423 int done = 0; /* controls when to exit the "event" loop */
425 int tag = 0; /* has the tag-prefix command been pressed? */
430 char *cp; /* temporary variable. */
431 int index_hint; /* used to restore cursor position */
432 int do_buffy_notify = 1;
433 int close = 0; /* did we OP_QUIT or OP_EXIT out of this menu? */
434 int attach_msg = option(OPTATTACHMSG);
436 menu = mutt_new_menu (MENU_MAIN);
438 menu->pagelen = LINES - 3;
439 menu->make_entry = index_make_entry;
440 menu->color = index_color;
441 menu->current = ci_first_message ();
442 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
445 mutt_buffy_check(1); /* force the buffy check after we enter the folder */
449 tag = 0; /* clear the tag-prefix */
451 /* check if we need to resort the index because just about
452 * any 'op' below could do mutt_enter_command(), either here or
453 * from any new menu launched, and change $sort/$sort_aux
455 if (option (OPTNEEDRESORT) && Context && Context->msgcount)
458 menu->max = Context ? Context->vcount : 0;
459 oldcount = Context ? Context->msgcount : 0;
461 if (option (OPTREDRAWTREE) && Context && Context->msgcount && (Sort & SORT_MASK) == SORT_THREADS)
463 mutt_draw_tree (Context);
464 menu->redraw |= REDRAW_STATUS;
465 unset_option (OPTREDRAWTREE);
468 if (Context && !attach_msg)
471 /* check for new mail in the mailbox. If nonzero, then something has
472 * changed about the file (either we got new mail or the file was
473 * modified underneath us.)
477 imap_allow_reopen (Context);
480 index_hint = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ? CURHDR->index : 0;
482 if ((check = mx_check_mailbox (Context, &index_hint, 0)) < 0)
486 /* fatal error occurred */
488 menu->redraw = REDRAW_FULL;
491 set_option (OPTSEARCHINVALID);
493 else if (check == M_NEW_MAIL || check == M_REOPENED || check == M_FLAGS)
495 update_index (menu, Context, check, oldcount, index_hint);
497 /* notify the user of new mail */
498 if (check == M_REOPENED)
499 mutt_error _("Mailbox was externally modified. Flags may be wrong.");
500 else if (check == M_NEW_MAIL)
502 mutt_message _("New mail in this mailbox.");
503 if (option (OPTBEEPNEW))
505 } else if (check == M_FLAGS)
506 mutt_message _("Mailbox was externally modified.");
508 /* avoid the message being overwritten by buffy */
511 menu->redraw = REDRAW_FULL;
512 menu->max = Context->vcount;
514 set_option (OPTSEARCHINVALID);
520 /* check for new mail in the incoming folders */
522 if ((newcount = mutt_buffy_check (0)) != oldcount)
523 menu->redraw |= REDRAW_STATUS;
526 if (mutt_buffy_notify () && option (OPTBEEPNEW))
536 if (menu->redraw & REDRAW_FULL)
538 menu_redraw_full (menu);
542 if (menu->menu == MENU_MAIN)
544 if (Context && Context->hdrs && !(menu->current >= Context->vcount))
546 menu_check_recenter (menu);
548 if (menu->redraw & REDRAW_INDEX)
550 menu_redraw_index (menu);
551 menu->redraw |= REDRAW_STATUS;
553 else if (menu->redraw & (REDRAW_MOTION_RESYNCH | REDRAW_MOTION))
554 menu_redraw_motion (menu);
555 else if (menu->redraw & REDRAW_CURRENT)
556 menu_redraw_current (menu);
559 if (menu->redraw & REDRAW_STATUS)
561 menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
562 CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
563 SETCOLOR (MT_COLOR_STATUS);
564 BKGDSET (MT_COLOR_STATUS);
565 mutt_paddstr (COLS, buf);
566 SETCOLOR (MT_COLOR_NORMAL);
567 BKGDSET (MT_COLOR_NORMAL);
568 menu->redraw &= ~REDRAW_STATUS;
572 if (menu->current < menu->max)
573 menu->oldcurrent = menu->current;
575 menu->oldcurrent = -1;
577 if (option (OPTARROWCURSOR))
578 move (menu->current - menu->top + menu->offset, 2);
579 else if (option (OPTBRAILLEFRIENDLY))
580 move (menu->current - menu->top + menu->offset, 0);
582 move (menu->current - menu->top + menu->offset, COLS - 1);
585 #if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
589 mutt_resize_screen ();
590 menu->redraw = REDRAW_FULL;
591 menu->menu = MENU_MAIN;
593 menu->top = 0; /* so we scroll the right amount */
595 * force a real complete redraw. clrtobot() doesn't seem to be able
596 * to handle every case without this.
598 clearok(stdscr,TRUE);
603 op = km_dokey (MENU_MAIN);
605 dprint(4, (debugfile, "mutt_index_menu[%d]: Got op %d\n", __LINE__, op));
608 continue; /* either user abort or timeout */
612 /* special handling for the tag-prefix function */
613 if (op == OP_TAG_PREFIX)
617 mutt_error _("No mailbox is open.");
621 if (!Context->tagged)
623 mutt_error _("No tagged messages.");
628 /* give visual indication that the next command is a tag- command */
629 mvaddstr (LINES - 1, 0, "tag-");
632 /* get the real command */
633 if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX)
635 /* abort tag sequence */
640 else if (option (OPTAUTOTAG) && Context && Context->tagged)
643 if (op == OP_TAG_PREFIX_COND)
647 mutt_error _("No mailbox is open.");
651 if (!Context->tagged)
657 if(tmp.op==OP_END_COND)break;
659 mutt_message _("Nothing to do.");
664 /* give visual indication that the next command is a tag- command */
665 mvaddstr (LINES - 1, 0, "tag-");
668 /* get the real command */
669 if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX)
671 /* abort tag sequence */
681 if (menu->current < menu->max)
682 menu->oldcurrent = menu->current;
684 menu->oldcurrent = -1;
686 mutt_curs_set (1); /* fallback from the pager */
690 imap_disallow_reopen (Context);
696 /* ----------------------------------------------------------------------
701 menu_bottom_page (menu);
704 menu_first_entry (menu);
707 menu_middle_page (menu);
713 menu_half_down (menu);
716 menu_next_line (menu);
719 menu_prev_line (menu);
722 menu_next_page (menu);
725 menu_prev_page (menu);
728 menu_last_entry (menu);
731 menu_top_page (menu);
734 menu_current_top (menu);
736 case OP_CURRENT_MIDDLE:
737 menu_current_middle (menu);
739 case OP_CURRENT_BOTTOM:
740 menu_current_bottom (menu);
747 if (isdigit (LastKey)) mutt_ungetch (LastKey, 0);
749 if (mutt_get_field (_("Jump to message: "), buf, sizeof (buf), 0) != 0
753 if (! isdigit ((unsigned char) buf[0]))
755 mutt_error _("Argument must be a message number.");
760 if (i > 0 && i <= Context->msgcount)
762 for (j = i-1; j < Context->msgcount; j++)
764 if (Context->hdrs[j]->virtual != -1)
767 if (j >= Context->msgcount)
769 for (j = i-2; j >= 0; j--)
771 if (Context->hdrs[j]->virtual != -1)
778 menu->current = Context->hdrs[j]->virtual;
779 if (menu->menu == MENU_PAGER)
781 op = OP_DISPLAY_MESSAGE;
785 menu->redraw = REDRAW_MOTION;
788 mutt_error _("That message is not visible.");
791 mutt_error _("Invalid message number.");
795 /* --------------------------------------------------------------------
796 * `index' specific commands
799 case OP_MAIN_DELETE_PATTERN:
804 CHECK_ACL(M_ACL_DELETE, _("delete message(s)"));
807 mutt_pattern_func (M_DELETE, _("Delete messages matching: "));
808 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
812 case OP_MAIN_FETCH_MAIL:
816 menu->redraw = REDRAW_FULL;
822 mutt_help (MENU_MAIN);
823 menu->redraw = REDRAW_FULL;
826 case OP_MAIN_SHOW_LIMIT:
828 if (!Context->pattern)
829 mutt_message _("No limit pattern is in effect.");
833 /* i18n: ask for a limit to apply */
834 snprintf (buf, sizeof(buf), _("Limit: %s"),Context->pattern);
835 mutt_message ("%s", buf);
842 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
844 if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
846 if (menu->oldcurrent >= 0)
848 /* try to find what used to be the current message */
850 for (i = 0; i < Context->vcount; i++)
851 if (Context->hdrs[Context->v2r[i]]->index == menu->oldcurrent)
856 if (menu->current < 0) menu->current = 0;
860 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
861 if (Context->msgcount && (Sort & SORT_MASK) == SORT_THREADS)
862 mutt_draw_tree (Context);
863 menu->redraw = REDRAW_FULL;
865 if (Context->pattern)
866 mutt_message _("To view all messages, limit to \"all\".");
878 if (query_quadoption (OPT_QUIT, _("Quit Mutt?")) == M_YES)
882 oldcount = Context ? Context->msgcount : 0;
884 if (!Context || (check = mx_close_mailbox (Context, &index_hint)) == 0)
888 if (check == M_NEW_MAIL || check == M_REOPENED)
889 update_index (menu, Context, check, oldcount, index_hint);
891 menu->redraw = REDRAW_FULL; /* new mail arrived? */
892 set_option (OPTSEARCHINVALID);
899 clearok (stdscr, TRUE);
900 menu->redraw = REDRAW_FULL;
904 case OP_SEARCH_REVERSE:
906 case OP_SEARCH_OPPOSITE:
910 if ((menu->current = mutt_search_command (menu->current, op)) == -1)
911 menu->current = menu->oldcurrent;
913 menu->redraw = REDRAW_MOTION;
917 case OP_SORT_REVERSE:
919 if (mutt_select_sort ((op == OP_SORT_REVERSE)) == 0)
921 if (Context && Context->msgcount)
924 set_option (OPTSEARCHINVALID);
926 menu->redraw |= REDRAW_STATUS;
934 if (tag && !option (OPTAUTOTAG))
936 for (j = 0; j < Context->vcount; j++)
937 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_TAG, 0);
938 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
942 mutt_set_flag (Context, CURHDR, M_TAG, !CURHDR->tagged);
944 Context->last_tag = CURHDR->tagged ? CURHDR :
945 ((Context->last_tag == CURHDR && !CURHDR->tagged)
946 ? NULL : Context->last_tag);
948 menu->redraw = REDRAW_STATUS;
949 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
952 menu->redraw |= REDRAW_MOTION_RESYNCH;
955 menu->redraw |= REDRAW_CURRENT;
959 case OP_MAIN_TAG_PATTERN:
963 mutt_pattern_func (M_TAG, _("Tag messages matching: "));
964 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
967 case OP_MAIN_UNDELETE_PATTERN:
972 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
974 if (mutt_pattern_func (M_UNDELETE, _("Undelete messages matching: ")) == 0)
975 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
978 case OP_MAIN_UNTAG_PATTERN:
982 if (mutt_pattern_func (M_UNTAG, _("Untag messages matching: ")) == 0)
983 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
986 /* --------------------------------------------------------------------
987 * The following operations can be performed inside of the pager.
991 case OP_MAIN_IMAP_FETCH:
992 if (Context && Context->magic == M_IMAP)
993 imap_check_mailbox (Context, &index_hint, 1);
997 case OP_MAIN_SYNC_FOLDER:
999 if (Context && !Context->msgcount)
1006 int oldvcount = Context->vcount;
1007 int oldcount = Context->msgcount;
1011 /* calculate the number of messages _above_ the cursor,
1012 * so we can keep the cursor on the current message
1014 for (j = 0; j <= menu->current; j++)
1016 if (Context->hdrs[Context->v2r[j]]->deleted)
1020 if ((check = mx_sync_mailbox (Context, &index_hint)) == 0)
1022 if (Context->vcount != oldvcount)
1023 menu->current -= dcount;
1024 set_option (OPTSEARCHINVALID);
1026 else if (check == M_NEW_MAIL || check == M_REOPENED)
1027 update_index (menu, Context, check, oldcount, index_hint);
1030 * do a sanity check even if mx_sync_mailbox failed.
1033 if (menu->current < 0 || menu->current >= Context->vcount)
1034 menu->current = ci_first_message ();
1037 /* check for a fatal error, or all messages deleted */
1041 /* if we were in the pager, redisplay the message */
1042 if (menu->menu == MENU_PAGER)
1044 op = OP_DISPLAY_MESSAGE;
1048 menu->redraw = REDRAW_FULL;
1051 case OP_MAIN_CHANGE_FOLDER:
1052 case OP_MAIN_NEXT_UNREAD_MAILBOX:
1055 op = OP_MAIN_CHANGE_FOLDER_READONLY;
1057 /* fallback to the readonly case */
1059 case OP_MAIN_CHANGE_FOLDER_READONLY:
1061 if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1062 cp = _("Open mailbox in read-only mode");
1064 cp = _("Open mailbox");
1067 if ((op == OP_MAIN_NEXT_UNREAD_MAILBOX) && Context && Context->path)
1069 strfcpy (buf, Context->path, sizeof (buf));
1070 mutt_pretty_mailbox (buf, sizeof (buf));
1071 mutt_buffy (buf, sizeof (buf));
1074 mutt_error _("No mailboxes have new mail");
1080 mutt_buffy (buf, sizeof (buf));
1082 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
1084 if (menu->menu == MENU_PAGER)
1086 op = OP_DISPLAY_MESSAGE;
1094 CLEARLINE (LINES-1);
1099 mutt_expand_path (buf, sizeof (buf));
1100 if (mx_get_magic (buf) <= 0)
1102 mutt_error (_("%s is not a mailbox."), buf);
1105 mutt_str_replace (&CurrentFolder, buf);
1111 mutt_str_replace (&LastFolder, Context->path);
1112 oldcount = Context ? Context->msgcount : 0;
1114 if ((check = mx_close_mailbox (Context, &index_hint)) != 0)
1116 if (check == M_NEW_MAIL || check == M_REOPENED)
1117 update_index (menu, Context, check, oldcount, index_hint);
1119 set_option (OPTSEARCHINVALID);
1120 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1128 /* Set CurrentMenu to MENU_MAIN before executing any folder
1129 * hooks so that all the index menu functions are available to
1133 CurrentMenu = MENU_MAIN;
1134 mutt_folder_hook (buf);
1136 if ((Context = mx_open_mailbox (buf,
1137 (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
1138 M_READONLY : 0, NULL)) != NULL)
1140 menu->current = ci_first_message ();
1145 mutt_clear_error ();
1146 mutt_buffy_check(1); /* force the buffy check after we have changed
1148 menu->redraw = REDRAW_FULL;
1149 set_option (OPTSEARCHINVALID);
1152 case OP_DISPLAY_MESSAGE:
1153 case OP_DISPLAY_HEADERS: /* don't weed the headers */
1158 * toggle the weeding of headers so that a user can press the key
1159 * again while reading the message.
1161 if (op == OP_DISPLAY_HEADERS)
1162 toggle_option (OPTWEED);
1164 unset_option (OPTNEEDRESORT);
1166 if ((Sort & SORT_MASK) == SORT_THREADS && CURHDR->collapsed)
1168 mutt_uncollapse_thread (Context, CURHDR);
1169 mutt_set_virtual (Context);
1170 if (option (OPTUNCOLLAPSEJUMP))
1171 menu->current = mutt_thread_next_unread (Context, CURHDR);
1174 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1175 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1176 if ((op = mutt_display_message (CURHDR)) == -1)
1178 unset_option (OPTNEEDRESORT);
1182 menu->menu = MENU_PAGER;
1183 menu->oldcurrent = menu->current;
1189 if (menu->menu == MENU_MAIN && attach_msg)
1195 if ((menu->menu == MENU_MAIN)
1196 && (query_quadoption (OPT_QUIT,
1197 _("Exit Mutt without saving?")) == M_YES))
1201 mx_fastclose_mailbox (Context);
1208 case OP_MAIN_BREAK_THREAD:
1214 if ((Sort & SORT_MASK) != SORT_THREADS)
1215 mutt_error _("Threading is not enabled.");
1219 HEADER *oldcur = CURHDR;
1221 mutt_break_thread (CURHDR);
1222 mutt_sort_headers (Context, 1);
1223 menu->current = oldcur->virtual;
1226 Context->changed = 1;
1227 mutt_message _("Thread broken");
1229 if (menu->menu == MENU_PAGER)
1231 op = OP_DISPLAY_MESSAGE;
1235 menu->redraw |= REDRAW_INDEX;
1240 case OP_MAIN_LINK_THREADS:
1245 CHECK_ACL(M_ACL_DELETE, _("link threads"));
1247 if ((Sort & SORT_MASK) != SORT_THREADS)
1248 mutt_error _("Threading is not enabled.");
1249 else if (!CURHDR->env->message_id)
1250 mutt_error _("No Message-ID: header available to link thread");
1251 else if (!tag && (!Context->last_tag || !Context->last_tag->tagged))
1252 mutt_error _("First, please tag a message to be linked here");
1255 HEADER *oldcur = CURHDR;
1257 if (mutt_link_threads (CURHDR, tag ? NULL : Context->last_tag,
1260 mutt_sort_headers (Context, 1);
1261 menu->current = oldcur->virtual;
1263 Context->changed = 1;
1264 mutt_message _("Threads linked");
1267 mutt_error _("No thread linked");
1270 if (menu->menu == MENU_PAGER)
1272 op = OP_DISPLAY_MESSAGE;
1276 menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
1285 mutt_edit_content_type (CURHDR, CURHDR->content, NULL);
1286 /* if we were in the pager, redisplay the message */
1287 if (menu->menu == MENU_PAGER)
1289 op = OP_DISPLAY_MESSAGE;
1293 menu->redraw = REDRAW_CURRENT;
1296 case OP_MAIN_NEXT_UNDELETED:
1300 if (menu->current >= Context->vcount - 1)
1302 if (menu->menu == MENU_MAIN)
1303 mutt_error _("You are on the last message.");
1306 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1308 menu->current = menu->oldcurrent;
1309 if (menu->menu == MENU_MAIN)
1310 mutt_error _("No undeleted messages.");
1312 else if (menu->menu == MENU_PAGER)
1314 op = OP_DISPLAY_MESSAGE;
1318 menu->redraw = REDRAW_MOTION;
1325 if (menu->current >= Context->vcount - 1)
1327 if (menu->menu == MENU_MAIN)
1328 mutt_error _("You are on the last message.");
1332 if (menu->menu == MENU_PAGER)
1334 op = OP_DISPLAY_MESSAGE;
1338 menu->redraw = REDRAW_MOTION;
1341 case OP_MAIN_PREV_UNDELETED:
1345 if (menu->current < 1)
1347 mutt_error _("You are on the first message.");
1350 if ((menu->current = ci_previous_undeleted (menu->current)) == -1)
1352 menu->current = menu->oldcurrent;
1353 if (menu->menu == MENU_MAIN)
1354 mutt_error _("No undeleted messages.");
1356 else if (menu->menu == MENU_PAGER)
1358 op = OP_DISPLAY_MESSAGE;
1362 menu->redraw = REDRAW_MOTION;
1369 if (menu->current < 1)
1371 if (menu->menu == MENU_MAIN) mutt_error _("You are on the first message.");
1375 if (menu->menu == MENU_PAGER)
1377 op = OP_DISPLAY_MESSAGE;
1381 menu->redraw = REDRAW_MOTION;
1384 case OP_DECRYPT_COPY:
1385 case OP_DECRYPT_SAVE:
1389 case OP_COPY_MESSAGE:
1391 case OP_DECODE_COPY:
1392 case OP_DECODE_SAVE:
1395 if (mutt_save_message (tag ? NULL : CURHDR,
1396 (op == OP_DECRYPT_SAVE) ||
1397 (op == OP_SAVE) || (op == OP_DECODE_SAVE),
1398 (op == OP_DECODE_SAVE) || (op == OP_DECODE_COPY),
1399 (op == OP_DECRYPT_SAVE) || (op == OP_DECRYPT_COPY) ||
1401 &menu->redraw) == 0 &&
1402 (op == OP_SAVE || op == OP_DECODE_SAVE || op == OP_DECRYPT_SAVE)
1406 menu->redraw |= REDRAW_INDEX;
1407 else if (option (OPTRESOLVE))
1409 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1411 menu->current = menu->oldcurrent;
1412 menu->redraw |= REDRAW_CURRENT;
1415 menu->redraw |= REDRAW_MOTION_RESYNCH;
1418 menu->redraw |= REDRAW_CURRENT;
1422 case OP_MAIN_NEXT_NEW:
1423 case OP_MAIN_NEXT_UNREAD:
1424 case OP_MAIN_PREV_NEW:
1425 case OP_MAIN_PREV_UNREAD:
1426 case OP_MAIN_NEXT_NEW_THEN_UNREAD:
1427 case OP_MAIN_PREV_NEW_THEN_UNREAD:
1430 int first_unread = -1;
1438 for (j = 0; j != Context->vcount; j++)
1440 #define CURHDRi Context->hdrs[Context->v2r[i]]
1441 if (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_NEXT_NEW_THEN_UNREAD)
1444 if (i > Context->vcount - 1)
1446 mutt_message _("Search wrapped to top.");
1455 mutt_message _("Search wrapped to bottom.");
1456 i = Context->vcount - 1;
1460 if (CURHDRi->collapsed && (Sort & SORT_MASK) == SORT_THREADS)
1462 if (UNREAD (CURHDRi) && first_unread == -1)
1464 if (UNREAD (CURHDRi) == 1 && first_new == -1)
1467 else if ((!CURHDRi->deleted && !CURHDRi->read))
1469 if (first_unread == -1)
1471 if ((!CURHDRi->old) && first_new == -1)
1475 if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD) &&
1478 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1479 op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1484 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1485 op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1487 menu->current = first_new;
1488 else if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD ||
1489 op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1490 && first_unread != -1)
1491 menu->current = first_unread;
1493 if (menu->current == -1)
1495 menu->current = menu->oldcurrent;
1496 mutt_error ("%s%s.", (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW) ? _("No new messages") : _("No unread messages"),
1497 Context->pattern ? _(" in this limited view") : "");
1499 else if (menu->menu == MENU_PAGER)
1501 op = OP_DISPLAY_MESSAGE;
1505 menu->redraw = REDRAW_MOTION;
1508 case OP_FLAG_MESSAGE:
1513 CHECK_ACL(M_ACL_WRITE, _("flag message"));
1517 for (j = 0; j < Context->vcount; j++)
1519 if (Context->hdrs[Context->v2r[j]]->tagged)
1520 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]],
1521 M_FLAG, !Context->hdrs[Context->v2r[j]]->flagged);
1524 menu->redraw |= REDRAW_INDEX;
1528 mutt_set_flag (Context, CURHDR, M_FLAG, !CURHDR->flagged);
1529 if (option (OPTRESOLVE))
1531 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1533 menu->current = menu->oldcurrent;
1534 menu->redraw = REDRAW_CURRENT;
1537 menu->redraw = REDRAW_MOTION_RESYNCH;
1540 menu->redraw = REDRAW_CURRENT;
1542 menu->redraw |= REDRAW_STATUS;
1550 CHECK_ACL(M_ACL_SEEN, _("toggle new"));
1554 for (j = 0; j < Context->vcount; j++)
1556 if (Context->hdrs[Context->v2r[j]]->tagged)
1558 if (Context->hdrs[Context->v2r[j]]->read ||
1559 Context->hdrs[Context->v2r[j]]->old)
1560 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_NEW, 1);
1562 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_READ, 1);
1565 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
1569 if (CURHDR->read || CURHDR->old)
1570 mutt_set_flag (Context, CURHDR, M_NEW, 1);
1572 mutt_set_flag (Context, CURHDR, M_READ, 1);
1574 if (option (OPTRESOLVE))
1576 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1578 menu->current = menu->oldcurrent;
1579 menu->redraw = REDRAW_CURRENT;
1582 menu->redraw = REDRAW_MOTION_RESYNCH;
1585 menu->redraw = REDRAW_CURRENT;
1586 menu->redraw |= REDRAW_STATUS;
1590 case OP_TOGGLE_WRITE:
1593 if (mx_toggle_write (Context) == 0)
1594 menu->redraw |= REDRAW_STATUS;
1597 case OP_MAIN_NEXT_THREAD:
1598 case OP_MAIN_NEXT_SUBTHREAD:
1599 case OP_MAIN_PREV_THREAD:
1600 case OP_MAIN_PREV_SUBTHREAD:
1606 case OP_MAIN_NEXT_THREAD:
1607 menu->current = mutt_next_thread (CURHDR);
1610 case OP_MAIN_NEXT_SUBTHREAD:
1611 menu->current = mutt_next_subthread (CURHDR);
1614 case OP_MAIN_PREV_THREAD:
1615 menu->current = mutt_previous_thread (CURHDR);
1618 case OP_MAIN_PREV_SUBTHREAD:
1619 menu->current = mutt_previous_subthread (CURHDR);
1623 if (menu->current < 0)
1625 menu->current = menu->oldcurrent;
1626 if (op == OP_MAIN_NEXT_THREAD || op == OP_MAIN_NEXT_SUBTHREAD)
1627 mutt_error _("No more threads.");
1629 mutt_error _("You are on the first thread.");
1631 else if (menu->menu == MENU_PAGER)
1633 op = OP_DISPLAY_MESSAGE;
1637 menu->redraw = REDRAW_MOTION;
1640 case OP_MAIN_PARENT_MESSAGE:
1645 if ((menu->current = mutt_parent_message (Context, CURHDR)) < 0)
1647 menu->current = menu->oldcurrent;
1649 else if (menu->menu == MENU_PAGER)
1651 op = OP_DISPLAY_MESSAGE;
1655 menu->redraw = REDRAW_MOTION;
1658 case OP_MAIN_SET_FLAG:
1659 case OP_MAIN_CLEAR_FLAG:
1664 /* CHECK_ACL(M_ACL_WRITE); */
1666 if (mutt_change_flag (tag ? NULL : CURHDR, (op == OP_MAIN_SET_FLAG)) == 0)
1668 menu->redraw = REDRAW_STATUS;
1670 menu->redraw |= REDRAW_INDEX;
1671 else if (option (OPTRESOLVE))
1673 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1675 menu->current = menu->oldcurrent;
1676 menu->redraw |= REDRAW_CURRENT;
1679 menu->redraw |= REDRAW_MOTION_RESYNCH;
1682 menu->redraw |= REDRAW_CURRENT;
1686 case OP_MAIN_COLLAPSE_THREAD:
1690 if ((Sort & SORT_MASK) != SORT_THREADS)
1692 mutt_error _("Threading is not enabled.");
1696 if (CURHDR->collapsed)
1698 menu->current = mutt_uncollapse_thread (Context, CURHDR);
1699 mutt_set_virtual (Context);
1700 if (option (OPTUNCOLLAPSEJUMP))
1701 menu->current = mutt_thread_next_unread (Context, CURHDR);
1703 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR))
1705 menu->current = mutt_collapse_thread (Context, CURHDR);
1706 mutt_set_virtual (Context);
1710 mutt_error _("Thread contains unread messages.");
1714 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1718 case OP_MAIN_COLLAPSE_ALL:
1722 if ((Sort & SORT_MASK) != SORT_THREADS)
1724 mutt_error _("Threading is not enabled.");
1730 THREAD *thread, *top;
1733 if (CURHDR->collapsed)
1734 final = mutt_uncollapse_thread (Context, CURHDR);
1735 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR))
1736 final = mutt_collapse_thread (Context, CURHDR);
1738 final = CURHDR->virtual;
1740 base = Context->hdrs[Context->v2r[final]];
1742 top = Context->tree;
1743 Context->collapsed = !Context->collapsed;
1744 while ((thread = top) != NULL)
1746 while (!thread->message)
1747 thread = thread->child;
1748 h = thread->message;
1750 if (h->collapsed != Context->collapsed)
1753 mutt_uncollapse_thread (Context, h);
1754 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (h))
1755 mutt_collapse_thread (Context, h);
1760 mutt_set_virtual (Context);
1761 for (j = 0; j < Context->vcount; j++)
1763 if (Context->hdrs[Context->v2r[j]]->index == base->index)
1770 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1774 /* --------------------------------------------------------------------
1775 * These functions are invoked directly from the internal-pager
1778 case OP_BOUNCE_MESSAGE:
1783 ci_bounce_message (tag ? NULL : CURHDR, &menu->redraw);
1786 case OP_CREATE_ALIAS:
1788 mutt_create_alias (Context && Context->vcount ? CURHDR->env : NULL, NULL);
1789 MAYBE_REDRAW (menu->redraw);
1790 menu->redraw |= REDRAW_CURRENT;
1795 mutt_query_menu (NULL, 0);
1796 MAYBE_REDRAW (menu->redraw);
1804 CHECK_ACL(M_ACL_DELETE, _("delete message"));
1808 mutt_tag_set_flag (M_DELETE, 1);
1809 if (option (OPTDELETEUNTAG))
1810 mutt_tag_set_flag (M_TAG, 0);
1811 menu->redraw = REDRAW_INDEX;
1815 mutt_set_flag (Context, CURHDR, M_DELETE, 1);
1816 if (option (OPTDELETEUNTAG))
1817 mutt_set_flag (Context, CURHDR, M_TAG, 0);
1818 if (option (OPTRESOLVE))
1820 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1822 menu->current = menu->oldcurrent;
1823 menu->redraw = REDRAW_CURRENT;
1825 else if (menu->menu == MENU_PAGER)
1827 op = OP_DISPLAY_MESSAGE;
1831 menu->redraw |= REDRAW_MOTION_RESYNCH;
1834 menu->redraw = REDRAW_CURRENT;
1836 menu->redraw |= REDRAW_STATUS;
1839 case OP_DELETE_THREAD:
1840 case OP_DELETE_SUBTHREAD:
1845 CHECK_ACL(M_ACL_DELETE, _("delete message(s)"));
1847 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 1,
1848 op == OP_DELETE_THREAD ? 0 : 1);
1852 if (option (OPTDELETEUNTAG))
1853 mutt_thread_set_flag (CURHDR, M_TAG, 0,
1854 op == OP_DELETE_THREAD ? 0 : 1);
1855 if (option (OPTRESOLVE))
1856 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1857 menu->current = menu->oldcurrent;
1858 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1862 case OP_DISPLAY_ADDRESS:
1866 mutt_display_address (CURHDR->env);
1869 case OP_ENTER_COMMAND:
1871 CurrentMenu = MENU_MAIN;
1872 mutt_enter_command ();
1873 mutt_check_rescore (Context);
1874 if (option (OPTFORCEREDRAWINDEX))
1875 menu->redraw = REDRAW_FULL;
1876 unset_option (OPTFORCEREDRAWINDEX);
1877 unset_option (OPTFORCEREDRAWPAGER);
1880 case OP_EDIT_MESSAGE:
1886 CHECK_ACL(M_ACL_INSERT, _("edit message"));
1888 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1889 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1890 mutt_edit_message (Context, tag ? NULL : CURHDR);
1891 menu->redraw = REDRAW_FULL;
1895 case OP_FORWARD_MESSAGE:
1900 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1901 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1902 ci_send_message (SENDFORWARD, NULL, NULL, Context, tag ? NULL : CURHDR);
1903 menu->redraw = REDRAW_FULL;
1907 case OP_FORGET_PASSPHRASE:
1908 crypt_forget_passphrase ();
1911 case OP_GROUP_REPLY:
1916 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1917 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1918 ci_send_message (SENDREPLY|SENDGROUPREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
1919 menu->redraw = REDRAW_FULL;
1927 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1928 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1929 ci_send_message (SENDREPLY|SENDLISTREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
1930 menu->redraw = REDRAW_FULL;
1936 ci_send_message (0, NULL, NULL, Context, NULL);
1937 menu->redraw = REDRAW_FULL;
1941 if (!(WithCrypto & APPLICATION_PGP))
1944 ci_send_message (SENDKEY, NULL, NULL, NULL, NULL);
1945 menu->redraw = REDRAW_FULL;
1949 case OP_EXTRACT_KEYS:
1954 crypt_extract_keys_from_messages(tag ? NULL : CURHDR);
1955 menu->redraw = REDRAW_FULL;
1959 case OP_CHECK_TRADITIONAL:
1960 if (!(WithCrypto & APPLICATION_PGP))
1964 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1965 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1967 if (menu->menu == MENU_PAGER)
1969 op = OP_DISPLAY_MESSAGE;
1978 mutt_pipe_message (tag ? NULL : CURHDR);
1981 /* in an IMAP folder index with imap_peek=no, piping could change
1982 * new or old messages status to read. Redraw what's needed.
1984 if (Context->magic == M_IMAP && !option (OPTIMAPPEEK))
1986 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
1990 MAYBE_REDRAW (menu->redraw);
1997 mutt_print_message (tag ? NULL : CURHDR);
2000 /* in an IMAP folder index with imap_peek=no, printing could change
2001 * new or old messages status to read. Redraw what's needed.
2003 if (Context->magic == M_IMAP && !option (OPTIMAPPEEK))
2005 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
2011 case OP_MAIN_READ_THREAD:
2012 case OP_MAIN_READ_SUBTHREAD:
2017 CHECK_ACL(M_ACL_SEEN, _("mark message(s) as read"));
2019 rc = mutt_thread_set_flag (CURHDR, M_READ, 1,
2020 op == OP_MAIN_READ_THREAD ? 0 : 1);
2024 if (option (OPTRESOLVE))
2026 if ((menu->current = (op == OP_MAIN_READ_THREAD ?
2027 mutt_next_thread (CURHDR) : mutt_next_subthread (CURHDR))) == -1)
2028 menu->current = menu->oldcurrent;
2030 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2034 case OP_RECALL_MESSAGE:
2037 ci_send_message (SENDPOSTPONED, NULL, NULL, Context, NULL);
2038 menu->redraw = REDRAW_FULL;
2049 for (j = 0; j < Context->vcount; j++)
2051 if (Context->hdrs[Context->v2r[j]]->tagged)
2052 mutt_resend_message (NULL, Context, Context->hdrs[Context->v2r[j]]);
2056 mutt_resend_message (NULL, Context, CURHDR);
2058 menu->redraw = REDRAW_FULL;
2066 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
2067 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
2068 ci_send_message (SENDREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
2069 menu->redraw = REDRAW_FULL;
2072 case OP_SHELL_ESCAPE:
2074 mutt_shell_escape ();
2075 MAYBE_REDRAW (menu->redraw);
2079 case OP_TAG_SUBTHREAD:
2083 rc = mutt_thread_set_flag (CURHDR, M_TAG, !CURHDR->tagged,
2084 op == OP_TAG_THREAD ? 0 : 1);
2088 if (option (OPTRESOLVE))
2090 if (op == OP_TAG_THREAD)
2091 menu->current = mutt_next_thread (CURHDR);
2093 menu->current = mutt_next_subthread (CURHDR);
2095 if (menu->current == -1)
2096 menu->current = menu->oldcurrent;
2098 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2107 CHECK_ACL(M_ACL_DELETE, _("undelete message"));
2111 mutt_tag_set_flag (M_DELETE, 0);
2112 menu->redraw = REDRAW_INDEX;
2116 mutt_set_flag (Context, CURHDR, M_DELETE, 0);
2117 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
2120 menu->redraw = REDRAW_MOTION_RESYNCH;
2123 menu->redraw = REDRAW_CURRENT;
2125 menu->redraw |= REDRAW_STATUS;
2128 case OP_UNDELETE_THREAD:
2129 case OP_UNDELETE_SUBTHREAD:
2134 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
2136 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2137 op == OP_UNDELETE_THREAD ? 0 : 1);
2141 if (option (OPTRESOLVE))
2143 if (op == OP_UNDELETE_THREAD)
2144 menu->current = mutt_next_thread (CURHDR);
2146 menu->current = mutt_next_subthread (CURHDR);
2148 if (menu->current == -1)
2149 menu->current = menu->oldcurrent;
2151 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2163 case OP_VIEW_ATTACHMENTS:
2166 mutt_view_attachments (CURHDR);
2167 if (CURHDR->attach_del)
2168 Context->changed = 1;
2169 menu->redraw = REDRAW_FULL;
2180 if (menu->menu == MENU_MAIN)
2181 km_error_key (MENU_MAIN);
2184 if (menu->menu == MENU_PAGER)
2186 menu->menu = MENU_MAIN;
2187 menu->redraw = REDRAW_FULL;
2189 set_option (OPTWEED); /* turn header weeding back on. */
2196 mutt_menuDestroy (&menu);
2200 void mutt_set_header_color (CONTEXT *ctx, HEADER *curhdr)
2207 for (color = ColorIndexList; color; color = color->next)
2208 if (mutt_pattern_exec (color->color_pattern, M_MATCH_FULL_ADDRESS, ctx, curhdr))
2210 curhdr->pair = color->pair;
2213 curhdr->pair = ColorDefs[MT_COLOR_NORMAL];