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 && menu->current >= 0)
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 (mutt_atoi (buf, &i) < 0)
755 mutt_error _("Argument must be a message number.");
759 if (i > 0 && i <= Context->msgcount)
761 for (j = i-1; j < Context->msgcount; j++)
763 if (Context->hdrs[j]->virtual != -1)
766 if (j >= Context->msgcount)
768 for (j = i-2; j >= 0; j--)
770 if (Context->hdrs[j]->virtual != -1)
777 menu->current = Context->hdrs[j]->virtual;
778 if (menu->menu == MENU_PAGER)
780 op = OP_DISPLAY_MESSAGE;
784 menu->redraw = REDRAW_MOTION;
787 mutt_error _("That message is not visible.");
790 mutt_error _("Invalid message number.");
794 /* --------------------------------------------------------------------
795 * `index' specific commands
798 case OP_MAIN_DELETE_PATTERN:
803 CHECK_ACL(M_ACL_DELETE, _("delete message(s)"));
806 mutt_pattern_func (M_DELETE, _("Delete messages matching: "));
807 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
811 case OP_MAIN_FETCH_MAIL:
815 menu->redraw = REDRAW_FULL;
821 mutt_help (MENU_MAIN);
822 menu->redraw = REDRAW_FULL;
825 case OP_MAIN_SHOW_LIMIT:
827 if (!Context->pattern)
828 mutt_message _("No limit pattern is in effect.");
832 /* i18n: ask for a limit to apply */
833 snprintf (buf, sizeof(buf), _("Limit: %s"),Context->pattern);
834 mutt_message ("%s", buf);
841 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
843 if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
845 if (menu->oldcurrent >= 0)
847 /* try to find what used to be the current message */
849 for (i = 0; i < Context->vcount; i++)
850 if (Context->hdrs[Context->v2r[i]]->index == menu->oldcurrent)
855 if (menu->current < 0) menu->current = 0;
859 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
860 if (Context->msgcount && (Sort & SORT_MASK) == SORT_THREADS)
861 mutt_draw_tree (Context);
862 menu->redraw = REDRAW_FULL;
864 if (Context->pattern)
865 mutt_message _("To view all messages, limit to \"all\".");
877 if (query_quadoption (OPT_QUIT, _("Quit Mutt?")) == M_YES)
881 oldcount = Context ? Context->msgcount : 0;
883 if (!Context || (check = mx_close_mailbox (Context, &index_hint)) == 0)
887 if (check == M_NEW_MAIL || check == M_REOPENED)
888 update_index (menu, Context, check, oldcount, index_hint);
890 menu->redraw = REDRAW_FULL; /* new mail arrived? */
891 set_option (OPTSEARCHINVALID);
898 clearok (stdscr, TRUE);
899 menu->redraw = REDRAW_FULL;
903 case OP_SEARCH_REVERSE:
905 case OP_SEARCH_OPPOSITE:
909 if ((menu->current = mutt_search_command (menu->current, op)) == -1)
910 menu->current = menu->oldcurrent;
912 menu->redraw = REDRAW_MOTION;
916 case OP_SORT_REVERSE:
918 if (mutt_select_sort ((op == OP_SORT_REVERSE)) == 0)
920 if (Context && Context->msgcount)
923 set_option (OPTSEARCHINVALID);
925 menu->redraw |= REDRAW_STATUS;
933 if (tag && !option (OPTAUTOTAG))
935 for (j = 0; j < Context->vcount; j++)
936 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_TAG, 0);
937 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
941 mutt_set_flag (Context, CURHDR, M_TAG, !CURHDR->tagged);
943 Context->last_tag = CURHDR->tagged ? CURHDR :
944 ((Context->last_tag == CURHDR && !CURHDR->tagged)
945 ? NULL : Context->last_tag);
947 menu->redraw = REDRAW_STATUS;
948 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
951 menu->redraw |= REDRAW_MOTION_RESYNCH;
954 menu->redraw |= REDRAW_CURRENT;
958 case OP_MAIN_TAG_PATTERN:
962 mutt_pattern_func (M_TAG, _("Tag messages matching: "));
963 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
966 case OP_MAIN_UNDELETE_PATTERN:
971 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
973 if (mutt_pattern_func (M_UNDELETE, _("Undelete messages matching: ")) == 0)
974 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
977 case OP_MAIN_UNTAG_PATTERN:
981 if (mutt_pattern_func (M_UNTAG, _("Untag messages matching: ")) == 0)
982 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
985 /* --------------------------------------------------------------------
986 * The following operations can be performed inside of the pager.
990 case OP_MAIN_IMAP_FETCH:
991 if (Context && Context->magic == M_IMAP)
992 imap_check_mailbox (Context, &index_hint, 1);
996 case OP_MAIN_SYNC_FOLDER:
998 if (Context && !Context->msgcount)
1005 int oldvcount = Context->vcount;
1006 int oldcount = Context->msgcount;
1008 HEADER *newhdr = NULL;
1010 /* threads may be reordered, so figure out what header the cursor
1011 * should be on. #3092 */
1012 newidx = menu->current;
1013 if (CURHDR->deleted)
1014 newidx = ci_next_undeleted (menu->current);
1016 newidx = ci_previous_undeleted (menu->current);
1018 newhdr = Context->hdrs[Context->v2r[newidx]];
1020 if ((check = mx_sync_mailbox (Context, &index_hint)) == 0)
1022 if (newhdr && Context->vcount != oldvcount)
1023 for (j = 0; j < Context->vcount; j++)
1025 if (Context->hdrs[Context->v2r[j]] == newhdr)
1031 set_option (OPTSEARCHINVALID);
1033 else if (check == M_NEW_MAIL || check == M_REOPENED)
1034 update_index (menu, Context, check, oldcount, index_hint);
1037 * do a sanity check even if mx_sync_mailbox failed.
1040 if (menu->current < 0 || menu->current >= Context->vcount)
1041 menu->current = ci_first_message ();
1044 /* check for a fatal error, or all messages deleted */
1048 /* if we were in the pager, redisplay the message */
1049 if (menu->menu == MENU_PAGER)
1051 op = OP_DISPLAY_MESSAGE;
1055 menu->redraw = REDRAW_FULL;
1058 case OP_MAIN_CHANGE_FOLDER:
1059 case OP_MAIN_NEXT_UNREAD_MAILBOX:
1062 op = OP_MAIN_CHANGE_FOLDER_READONLY;
1064 /* fallback to the readonly case */
1066 case OP_MAIN_CHANGE_FOLDER_READONLY:
1068 if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1069 cp = _("Open mailbox in read-only mode");
1071 cp = _("Open mailbox");
1074 if ((op == OP_MAIN_NEXT_UNREAD_MAILBOX) && Context && Context->path)
1076 strfcpy (buf, Context->path, sizeof (buf));
1077 mutt_pretty_mailbox (buf, sizeof (buf));
1078 mutt_buffy (buf, sizeof (buf));
1081 mutt_error _("No mailboxes have new mail");
1087 mutt_buffy (buf, sizeof (buf));
1089 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
1091 if (menu->menu == MENU_PAGER)
1093 op = OP_DISPLAY_MESSAGE;
1101 CLEARLINE (LINES-1);
1106 mutt_expand_path (buf, sizeof (buf));
1107 if (mx_get_magic (buf) <= 0)
1109 mutt_error (_("%s is not a mailbox."), buf);
1112 mutt_str_replace (&CurrentFolder, buf);
1118 mutt_str_replace (&LastFolder, Context->path);
1119 oldcount = Context ? Context->msgcount : 0;
1121 if ((check = mx_close_mailbox (Context, &index_hint)) != 0)
1123 if (check == M_NEW_MAIL || check == M_REOPENED)
1124 update_index (menu, Context, check, oldcount, index_hint);
1126 set_option (OPTSEARCHINVALID);
1127 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1135 /* Set CurrentMenu to MENU_MAIN before executing any folder
1136 * hooks so that all the index menu functions are available to
1140 CurrentMenu = MENU_MAIN;
1141 mutt_folder_hook (buf);
1143 if ((Context = mx_open_mailbox (buf,
1144 (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
1145 M_READONLY : 0, NULL)) != NULL)
1147 menu->current = ci_first_message ();
1152 mutt_clear_error ();
1153 mutt_buffy_check(1); /* force the buffy check after we have changed
1155 menu->redraw = REDRAW_FULL;
1156 set_option (OPTSEARCHINVALID);
1159 case OP_DISPLAY_MESSAGE:
1160 case OP_DISPLAY_HEADERS: /* don't weed the headers */
1165 * toggle the weeding of headers so that a user can press the key
1166 * again while reading the message.
1168 if (op == OP_DISPLAY_HEADERS)
1169 toggle_option (OPTWEED);
1171 unset_option (OPTNEEDRESORT);
1173 if ((Sort & SORT_MASK) == SORT_THREADS && CURHDR->collapsed)
1175 mutt_uncollapse_thread (Context, CURHDR);
1176 mutt_set_virtual (Context);
1177 if (option (OPTUNCOLLAPSEJUMP))
1178 menu->current = mutt_thread_next_unread (Context, CURHDR);
1181 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1182 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1183 if ((op = mutt_display_message (CURHDR)) == -1)
1185 unset_option (OPTNEEDRESORT);
1189 menu->menu = MENU_PAGER;
1190 menu->oldcurrent = menu->current;
1196 if (menu->menu == MENU_MAIN && attach_msg)
1202 if ((menu->menu == MENU_MAIN)
1203 && (query_quadoption (OPT_QUIT,
1204 _("Exit Mutt without saving?")) == M_YES))
1208 mx_fastclose_mailbox (Context);
1215 case OP_MAIN_BREAK_THREAD:
1221 if ((Sort & SORT_MASK) != SORT_THREADS)
1222 mutt_error _("Threading is not enabled.");
1226 HEADER *oldcur = CURHDR;
1228 mutt_break_thread (CURHDR);
1229 mutt_sort_headers (Context, 1);
1230 menu->current = oldcur->virtual;
1233 Context->changed = 1;
1234 mutt_message _("Thread broken");
1236 if (menu->menu == MENU_PAGER)
1238 op = OP_DISPLAY_MESSAGE;
1242 menu->redraw |= REDRAW_INDEX;
1247 case OP_MAIN_LINK_THREADS:
1252 CHECK_ACL(M_ACL_DELETE, _("link threads"));
1254 if ((Sort & SORT_MASK) != SORT_THREADS)
1255 mutt_error _("Threading is not enabled.");
1256 else if (!CURHDR->env->message_id)
1257 mutt_error _("No Message-ID: header available to link thread");
1258 else if (!tag && (!Context->last_tag || !Context->last_tag->tagged))
1259 mutt_error _("First, please tag a message to be linked here");
1262 HEADER *oldcur = CURHDR;
1264 if (mutt_link_threads (CURHDR, tag ? NULL : Context->last_tag,
1267 mutt_sort_headers (Context, 1);
1268 menu->current = oldcur->virtual;
1270 Context->changed = 1;
1271 mutt_message _("Threads linked");
1274 mutt_error _("No thread linked");
1277 if (menu->menu == MENU_PAGER)
1279 op = OP_DISPLAY_MESSAGE;
1283 menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
1292 mutt_edit_content_type (CURHDR, CURHDR->content, NULL);
1293 /* if we were in the pager, redisplay the message */
1294 if (menu->menu == MENU_PAGER)
1296 op = OP_DISPLAY_MESSAGE;
1300 menu->redraw = REDRAW_CURRENT;
1303 case OP_MAIN_NEXT_UNDELETED:
1307 if (menu->current >= Context->vcount - 1)
1309 if (menu->menu == MENU_MAIN)
1310 mutt_error _("You are on the last message.");
1313 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1315 menu->current = menu->oldcurrent;
1316 if (menu->menu == MENU_MAIN)
1317 mutt_error _("No undeleted messages.");
1319 else if (menu->menu == MENU_PAGER)
1321 op = OP_DISPLAY_MESSAGE;
1325 menu->redraw = REDRAW_MOTION;
1332 if (menu->current >= Context->vcount - 1)
1334 if (menu->menu == MENU_MAIN)
1335 mutt_error _("You are on the last message.");
1339 if (menu->menu == MENU_PAGER)
1341 op = OP_DISPLAY_MESSAGE;
1345 menu->redraw = REDRAW_MOTION;
1348 case OP_MAIN_PREV_UNDELETED:
1352 if (menu->current < 1)
1354 mutt_error _("You are on the first message.");
1357 if ((menu->current = ci_previous_undeleted (menu->current)) == -1)
1359 menu->current = menu->oldcurrent;
1360 if (menu->menu == MENU_MAIN)
1361 mutt_error _("No undeleted messages.");
1363 else if (menu->menu == MENU_PAGER)
1365 op = OP_DISPLAY_MESSAGE;
1369 menu->redraw = REDRAW_MOTION;
1376 if (menu->current < 1)
1378 if (menu->menu == MENU_MAIN) mutt_error _("You are on the first message.");
1382 if (menu->menu == MENU_PAGER)
1384 op = OP_DISPLAY_MESSAGE;
1388 menu->redraw = REDRAW_MOTION;
1391 case OP_DECRYPT_COPY:
1392 case OP_DECRYPT_SAVE:
1396 case OP_COPY_MESSAGE:
1398 case OP_DECODE_COPY:
1399 case OP_DECODE_SAVE:
1402 if (mutt_save_message (tag ? NULL : CURHDR,
1403 (op == OP_DECRYPT_SAVE) ||
1404 (op == OP_SAVE) || (op == OP_DECODE_SAVE),
1405 (op == OP_DECODE_SAVE) || (op == OP_DECODE_COPY),
1406 (op == OP_DECRYPT_SAVE) || (op == OP_DECRYPT_COPY) ||
1408 &menu->redraw) == 0 &&
1409 (op == OP_SAVE || op == OP_DECODE_SAVE || op == OP_DECRYPT_SAVE)
1413 menu->redraw |= REDRAW_INDEX;
1414 else if (option (OPTRESOLVE))
1416 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1418 menu->current = menu->oldcurrent;
1419 menu->redraw |= REDRAW_CURRENT;
1422 menu->redraw |= REDRAW_MOTION_RESYNCH;
1425 menu->redraw |= REDRAW_CURRENT;
1429 case OP_MAIN_NEXT_NEW:
1430 case OP_MAIN_NEXT_UNREAD:
1431 case OP_MAIN_PREV_NEW:
1432 case OP_MAIN_PREV_UNREAD:
1433 case OP_MAIN_NEXT_NEW_THEN_UNREAD:
1434 case OP_MAIN_PREV_NEW_THEN_UNREAD:
1437 int first_unread = -1;
1445 for (j = 0; j != Context->vcount; j++)
1447 #define CURHDRi Context->hdrs[Context->v2r[i]]
1448 if (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_NEXT_NEW_THEN_UNREAD)
1451 if (i > Context->vcount - 1)
1453 mutt_message _("Search wrapped to top.");
1462 mutt_message _("Search wrapped to bottom.");
1463 i = Context->vcount - 1;
1467 if (CURHDRi->collapsed && (Sort & SORT_MASK) == SORT_THREADS)
1469 if (UNREAD (CURHDRi) && first_unread == -1)
1471 if (UNREAD (CURHDRi) == 1 && first_new == -1)
1474 else if ((!CURHDRi->deleted && !CURHDRi->read))
1476 if (first_unread == -1)
1478 if ((!CURHDRi->old) && first_new == -1)
1482 if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD) &&
1485 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1486 op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1491 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1492 op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1494 menu->current = first_new;
1495 else if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD ||
1496 op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1497 && first_unread != -1)
1498 menu->current = first_unread;
1500 if (menu->current == -1)
1502 menu->current = menu->oldcurrent;
1503 mutt_error ("%s%s.", (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW) ? _("No new messages") : _("No unread messages"),
1504 Context->pattern ? _(" in this limited view") : "");
1506 else if (menu->menu == MENU_PAGER)
1508 op = OP_DISPLAY_MESSAGE;
1512 menu->redraw = REDRAW_MOTION;
1515 case OP_FLAG_MESSAGE:
1520 CHECK_ACL(M_ACL_WRITE, _("flag message"));
1524 for (j = 0; j < Context->vcount; j++)
1526 if (Context->hdrs[Context->v2r[j]]->tagged)
1527 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]],
1528 M_FLAG, !Context->hdrs[Context->v2r[j]]->flagged);
1531 menu->redraw |= REDRAW_INDEX;
1535 mutt_set_flag (Context, CURHDR, M_FLAG, !CURHDR->flagged);
1536 if (option (OPTRESOLVE))
1538 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1540 menu->current = menu->oldcurrent;
1541 menu->redraw = REDRAW_CURRENT;
1544 menu->redraw = REDRAW_MOTION_RESYNCH;
1547 menu->redraw = REDRAW_CURRENT;
1549 menu->redraw |= REDRAW_STATUS;
1557 CHECK_ACL(M_ACL_SEEN, _("toggle new"));
1561 for (j = 0; j < Context->vcount; j++)
1563 if (Context->hdrs[Context->v2r[j]]->tagged)
1565 if (Context->hdrs[Context->v2r[j]]->read ||
1566 Context->hdrs[Context->v2r[j]]->old)
1567 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_NEW, 1);
1569 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_READ, 1);
1572 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
1576 if (CURHDR->read || CURHDR->old)
1577 mutt_set_flag (Context, CURHDR, M_NEW, 1);
1579 mutt_set_flag (Context, CURHDR, M_READ, 1);
1581 if (option (OPTRESOLVE))
1583 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1585 menu->current = menu->oldcurrent;
1586 menu->redraw = REDRAW_CURRENT;
1589 menu->redraw = REDRAW_MOTION_RESYNCH;
1592 menu->redraw = REDRAW_CURRENT;
1593 menu->redraw |= REDRAW_STATUS;
1597 case OP_TOGGLE_WRITE:
1600 if (mx_toggle_write (Context) == 0)
1601 menu->redraw |= REDRAW_STATUS;
1604 case OP_MAIN_NEXT_THREAD:
1605 case OP_MAIN_NEXT_SUBTHREAD:
1606 case OP_MAIN_PREV_THREAD:
1607 case OP_MAIN_PREV_SUBTHREAD:
1613 case OP_MAIN_NEXT_THREAD:
1614 menu->current = mutt_next_thread (CURHDR);
1617 case OP_MAIN_NEXT_SUBTHREAD:
1618 menu->current = mutt_next_subthread (CURHDR);
1621 case OP_MAIN_PREV_THREAD:
1622 menu->current = mutt_previous_thread (CURHDR);
1625 case OP_MAIN_PREV_SUBTHREAD:
1626 menu->current = mutt_previous_subthread (CURHDR);
1630 if (menu->current < 0)
1632 menu->current = menu->oldcurrent;
1633 if (op == OP_MAIN_NEXT_THREAD || op == OP_MAIN_NEXT_SUBTHREAD)
1634 mutt_error _("No more threads.");
1636 mutt_error _("You are on the first thread.");
1638 else if (menu->menu == MENU_PAGER)
1640 op = OP_DISPLAY_MESSAGE;
1644 menu->redraw = REDRAW_MOTION;
1647 case OP_MAIN_PARENT_MESSAGE:
1652 if ((menu->current = mutt_parent_message (Context, CURHDR)) < 0)
1654 menu->current = menu->oldcurrent;
1656 else if (menu->menu == MENU_PAGER)
1658 op = OP_DISPLAY_MESSAGE;
1662 menu->redraw = REDRAW_MOTION;
1665 case OP_MAIN_SET_FLAG:
1666 case OP_MAIN_CLEAR_FLAG:
1671 /* CHECK_ACL(M_ACL_WRITE); */
1673 if (mutt_change_flag (tag ? NULL : CURHDR, (op == OP_MAIN_SET_FLAG)) == 0)
1675 menu->redraw = REDRAW_STATUS;
1677 menu->redraw |= REDRAW_INDEX;
1678 else if (option (OPTRESOLVE))
1680 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1682 menu->current = menu->oldcurrent;
1683 menu->redraw |= REDRAW_CURRENT;
1686 menu->redraw |= REDRAW_MOTION_RESYNCH;
1689 menu->redraw |= REDRAW_CURRENT;
1693 case OP_MAIN_COLLAPSE_THREAD:
1697 if ((Sort & SORT_MASK) != SORT_THREADS)
1699 mutt_error _("Threading is not enabled.");
1703 if (CURHDR->collapsed)
1705 menu->current = mutt_uncollapse_thread (Context, CURHDR);
1706 mutt_set_virtual (Context);
1707 if (option (OPTUNCOLLAPSEJUMP))
1708 menu->current = mutt_thread_next_unread (Context, CURHDR);
1710 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR))
1712 menu->current = mutt_collapse_thread (Context, CURHDR);
1713 mutt_set_virtual (Context);
1717 mutt_error _("Thread contains unread messages.");
1721 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1725 case OP_MAIN_COLLAPSE_ALL:
1729 if ((Sort & SORT_MASK) != SORT_THREADS)
1731 mutt_error _("Threading is not enabled.");
1737 THREAD *thread, *top;
1740 if (CURHDR->collapsed)
1741 final = mutt_uncollapse_thread (Context, CURHDR);
1742 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR))
1743 final = mutt_collapse_thread (Context, CURHDR);
1745 final = CURHDR->virtual;
1747 base = Context->hdrs[Context->v2r[final]];
1749 top = Context->tree;
1750 Context->collapsed = !Context->collapsed;
1751 while ((thread = top) != NULL)
1753 while (!thread->message)
1754 thread = thread->child;
1755 h = thread->message;
1757 if (h->collapsed != Context->collapsed)
1760 mutt_uncollapse_thread (Context, h);
1761 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (h))
1762 mutt_collapse_thread (Context, h);
1767 mutt_set_virtual (Context);
1768 for (j = 0; j < Context->vcount; j++)
1770 if (Context->hdrs[Context->v2r[j]]->index == base->index)
1777 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1781 /* --------------------------------------------------------------------
1782 * These functions are invoked directly from the internal-pager
1785 case OP_BOUNCE_MESSAGE:
1790 ci_bounce_message (tag ? NULL : CURHDR, &menu->redraw);
1793 case OP_CREATE_ALIAS:
1795 mutt_create_alias (Context && Context->vcount ? CURHDR->env : NULL, NULL);
1796 MAYBE_REDRAW (menu->redraw);
1797 menu->redraw |= REDRAW_CURRENT;
1802 mutt_query_menu (NULL, 0);
1803 MAYBE_REDRAW (menu->redraw);
1811 CHECK_ACL(M_ACL_DELETE, _("delete message"));
1815 mutt_tag_set_flag (M_DELETE, 1);
1816 if (option (OPTDELETEUNTAG))
1817 mutt_tag_set_flag (M_TAG, 0);
1818 menu->redraw = REDRAW_INDEX;
1822 mutt_set_flag (Context, CURHDR, M_DELETE, 1);
1823 if (option (OPTDELETEUNTAG))
1824 mutt_set_flag (Context, CURHDR, M_TAG, 0);
1825 if (option (OPTRESOLVE))
1827 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1829 menu->current = menu->oldcurrent;
1830 menu->redraw = REDRAW_CURRENT;
1832 else if (menu->menu == MENU_PAGER)
1834 op = OP_DISPLAY_MESSAGE;
1838 menu->redraw |= REDRAW_MOTION_RESYNCH;
1841 menu->redraw = REDRAW_CURRENT;
1843 menu->redraw |= REDRAW_STATUS;
1846 case OP_DELETE_THREAD:
1847 case OP_DELETE_SUBTHREAD:
1852 CHECK_ACL(M_ACL_DELETE, _("delete message(s)"));
1854 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 1,
1855 op == OP_DELETE_THREAD ? 0 : 1);
1859 if (option (OPTDELETEUNTAG))
1860 mutt_thread_set_flag (CURHDR, M_TAG, 0,
1861 op == OP_DELETE_THREAD ? 0 : 1);
1862 if (option (OPTRESOLVE))
1863 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1864 menu->current = menu->oldcurrent;
1865 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1869 case OP_DISPLAY_ADDRESS:
1873 mutt_display_address (CURHDR->env);
1876 case OP_ENTER_COMMAND:
1878 CurrentMenu = MENU_MAIN;
1879 mutt_enter_command ();
1880 mutt_check_rescore (Context);
1881 if (option (OPTFORCEREDRAWINDEX))
1882 menu->redraw = REDRAW_FULL;
1883 unset_option (OPTFORCEREDRAWINDEX);
1884 unset_option (OPTFORCEREDRAWPAGER);
1887 case OP_EDIT_MESSAGE:
1893 CHECK_ACL(M_ACL_INSERT, _("edit message"));
1895 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1896 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1897 mutt_edit_message (Context, tag ? NULL : CURHDR);
1898 menu->redraw = REDRAW_FULL;
1902 case OP_FORWARD_MESSAGE:
1907 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1908 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1909 ci_send_message (SENDFORWARD, NULL, NULL, Context, tag ? NULL : CURHDR);
1910 menu->redraw = REDRAW_FULL;
1914 case OP_FORGET_PASSPHRASE:
1915 crypt_forget_passphrase ();
1918 case OP_GROUP_REPLY:
1923 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1924 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1925 ci_send_message (SENDREPLY|SENDGROUPREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
1926 menu->redraw = REDRAW_FULL;
1934 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1935 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1936 ci_send_message (SENDREPLY|SENDLISTREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
1937 menu->redraw = REDRAW_FULL;
1943 ci_send_message (0, NULL, NULL, Context, NULL);
1944 menu->redraw = REDRAW_FULL;
1948 if (!(WithCrypto & APPLICATION_PGP))
1951 ci_send_message (SENDKEY, NULL, NULL, NULL, NULL);
1952 menu->redraw = REDRAW_FULL;
1956 case OP_EXTRACT_KEYS:
1961 crypt_extract_keys_from_messages(tag ? NULL : CURHDR);
1962 menu->redraw = REDRAW_FULL;
1966 case OP_CHECK_TRADITIONAL:
1967 if (!(WithCrypto & APPLICATION_PGP))
1971 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1972 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1974 if (menu->menu == MENU_PAGER)
1976 op = OP_DISPLAY_MESSAGE;
1985 mutt_pipe_message (tag ? NULL : CURHDR);
1988 /* in an IMAP folder index with imap_peek=no, piping could change
1989 * new or old messages status to read. Redraw what's needed.
1991 if (Context->magic == M_IMAP && !option (OPTIMAPPEEK))
1993 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
1997 MAYBE_REDRAW (menu->redraw);
2004 mutt_print_message (tag ? NULL : CURHDR);
2007 /* in an IMAP folder index with imap_peek=no, printing could change
2008 * new or old messages status to read. Redraw what's needed.
2010 if (Context->magic == M_IMAP && !option (OPTIMAPPEEK))
2012 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
2018 case OP_MAIN_READ_THREAD:
2019 case OP_MAIN_READ_SUBTHREAD:
2024 CHECK_ACL(M_ACL_SEEN, _("mark message(s) as read"));
2026 rc = mutt_thread_set_flag (CURHDR, M_READ, 1,
2027 op == OP_MAIN_READ_THREAD ? 0 : 1);
2031 if (option (OPTRESOLVE))
2033 if ((menu->current = (op == OP_MAIN_READ_THREAD ?
2034 mutt_next_thread (CURHDR) : mutt_next_subthread (CURHDR))) == -1)
2035 menu->current = menu->oldcurrent;
2037 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2041 case OP_RECALL_MESSAGE:
2044 ci_send_message (SENDPOSTPONED, NULL, NULL, Context, NULL);
2045 menu->redraw = REDRAW_FULL;
2056 for (j = 0; j < Context->vcount; j++)
2058 if (Context->hdrs[Context->v2r[j]]->tagged)
2059 mutt_resend_message (NULL, Context, Context->hdrs[Context->v2r[j]]);
2063 mutt_resend_message (NULL, Context, CURHDR);
2065 menu->redraw = REDRAW_FULL;
2073 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
2074 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
2075 ci_send_message (SENDREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
2076 menu->redraw = REDRAW_FULL;
2079 case OP_SHELL_ESCAPE:
2081 mutt_shell_escape ();
2082 MAYBE_REDRAW (menu->redraw);
2086 case OP_TAG_SUBTHREAD:
2090 rc = mutt_thread_set_flag (CURHDR, M_TAG, !CURHDR->tagged,
2091 op == OP_TAG_THREAD ? 0 : 1);
2095 if (option (OPTRESOLVE))
2097 if (op == OP_TAG_THREAD)
2098 menu->current = mutt_next_thread (CURHDR);
2100 menu->current = mutt_next_subthread (CURHDR);
2102 if (menu->current == -1)
2103 menu->current = menu->oldcurrent;
2105 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2114 CHECK_ACL(M_ACL_DELETE, _("undelete message"));
2118 mutt_tag_set_flag (M_DELETE, 0);
2119 menu->redraw = REDRAW_INDEX;
2123 mutt_set_flag (Context, CURHDR, M_DELETE, 0);
2124 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
2127 menu->redraw = REDRAW_MOTION_RESYNCH;
2130 menu->redraw = REDRAW_CURRENT;
2132 menu->redraw |= REDRAW_STATUS;
2135 case OP_UNDELETE_THREAD:
2136 case OP_UNDELETE_SUBTHREAD:
2141 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
2143 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2144 op == OP_UNDELETE_THREAD ? 0 : 1);
2148 if (option (OPTRESOLVE))
2150 if (op == OP_UNDELETE_THREAD)
2151 menu->current = mutt_next_thread (CURHDR);
2153 menu->current = mutt_next_subthread (CURHDR);
2155 if (menu->current == -1)
2156 menu->current = menu->oldcurrent;
2158 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2170 case OP_VIEW_ATTACHMENTS:
2173 mutt_view_attachments (CURHDR);
2174 if (CURHDR->attach_del)
2175 Context->changed = 1;
2176 menu->redraw = REDRAW_FULL;
2187 if (menu->menu == MENU_MAIN)
2188 km_error_key (MENU_MAIN);
2191 if (menu->menu == MENU_PAGER)
2193 menu->menu = MENU_MAIN;
2194 menu->redraw = REDRAW_FULL;
2196 set_option (OPTWEED); /* turn header weeding back on. */
2203 mutt_menuDestroy (&menu);
2207 void mutt_set_header_color (CONTEXT *ctx, HEADER *curhdr)
2214 for (color = ColorIndexList; color; color = color->next)
2215 if (mutt_pattern_exec (color->color_pattern, M_MATCH_FULL_ADDRESS, ctx, curhdr))
2217 curhdr->pair = color->pair;
2220 curhdr->pair = ColorDefs[MT_COLOR_NORMAL];