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.)
476 index_hint = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ? CURHDR->index : 0;
478 if ((check = mx_check_mailbox (Context, &index_hint, 0)) < 0)
482 /* fatal error occurred */
484 menu->redraw = REDRAW_FULL;
487 set_option (OPTSEARCHINVALID);
489 else if (check == M_NEW_MAIL || check == M_REOPENED || check == M_FLAGS)
491 update_index (menu, Context, check, oldcount, index_hint);
493 /* notify the user of new mail */
494 if (check == M_REOPENED)
495 mutt_error _("Mailbox was externally modified. Flags may be wrong.");
496 else if (check == M_NEW_MAIL)
498 mutt_message _("New mail in this mailbox.");
499 if (option (OPTBEEPNEW))
501 } else if (check == M_FLAGS)
502 mutt_message _("Mailbox was externally modified.");
504 /* avoid the message being overwritten by buffy */
507 menu->redraw = REDRAW_FULL;
508 menu->max = Context->vcount;
510 set_option (OPTSEARCHINVALID);
516 /* check for new mail in the incoming folders */
518 if ((newcount = mutt_buffy_check (0)) != oldcount)
519 menu->redraw |= REDRAW_STATUS;
522 if (mutt_buffy_notify () && option (OPTBEEPNEW))
532 if (menu->redraw & REDRAW_FULL)
534 menu_redraw_full (menu);
538 if (menu->menu == MENU_MAIN)
540 if (Context && Context->hdrs && !(menu->current >= Context->vcount))
542 menu_check_recenter (menu);
544 if (menu->redraw & REDRAW_INDEX)
546 menu_redraw_index (menu);
547 menu->redraw |= REDRAW_STATUS;
549 else if (menu->redraw & (REDRAW_MOTION_RESYNCH | REDRAW_MOTION))
550 menu_redraw_motion (menu);
551 else if (menu->redraw & REDRAW_CURRENT)
552 menu_redraw_current (menu);
555 if (menu->redraw & REDRAW_STATUS)
557 menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
558 CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
559 SETCOLOR (MT_COLOR_STATUS);
560 BKGDSET (MT_COLOR_STATUS);
561 mutt_paddstr (COLS, buf);
562 SETCOLOR (MT_COLOR_NORMAL);
563 BKGDSET (MT_COLOR_NORMAL);
564 menu->redraw &= ~REDRAW_STATUS;
568 if (menu->current < menu->max)
569 menu->oldcurrent = menu->current;
571 menu->oldcurrent = -1;
573 if (option (OPTARROWCURSOR))
574 move (menu->current - menu->top + menu->offset, 2);
575 else if (option (OPTBRAILLEFRIENDLY))
576 move (menu->current - menu->top + menu->offset, 0);
578 move (menu->current - menu->top + menu->offset, COLS - 1);
581 #if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
585 mutt_resize_screen ();
586 menu->redraw = REDRAW_FULL;
587 menu->menu = MENU_MAIN;
589 menu->top = 0; /* so we scroll the right amount */
591 * force a real complete redraw. clrtobot() doesn't seem to be able
592 * to handle every case without this.
594 clearok(stdscr,TRUE);
599 op = km_dokey (MENU_MAIN);
601 dprint(4, (debugfile, "mutt_index_menu[%d]: Got op %d\n", __LINE__, op));
604 continue; /* either user abort or timeout */
608 /* special handling for the tag-prefix function */
609 if (op == OP_TAG_PREFIX)
613 mutt_error _("No mailbox is open.");
617 if (!Context->tagged)
619 mutt_error _("No tagged messages.");
624 /* give visual indication that the next command is a tag- command */
625 mvaddstr (LINES - 1, 0, "tag-");
628 /* get the real command */
629 if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX)
631 /* abort tag sequence */
636 else if (option (OPTAUTOTAG) && Context && Context->tagged)
639 if (op == OP_TAG_PREFIX_COND)
643 mutt_error _("No mailbox is open.");
647 if (!Context->tagged)
653 if(tmp.op==OP_END_COND)break;
655 mutt_message _("Nothing to do.");
660 /* give visual indication that the next command is a tag- command */
661 mvaddstr (LINES - 1, 0, "tag-");
664 /* get the real command */
665 if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX)
667 /* abort tag sequence */
677 if (menu->current < menu->max)
678 menu->oldcurrent = menu->current;
680 menu->oldcurrent = -1;
682 mutt_curs_set (1); /* fallback from the pager */
688 /* ----------------------------------------------------------------------
693 menu_bottom_page (menu);
696 menu_first_entry (menu);
699 menu_middle_page (menu);
705 menu_half_down (menu);
708 menu_next_line (menu);
711 menu_prev_line (menu);
714 menu_next_page (menu);
717 menu_prev_page (menu);
720 menu_last_entry (menu);
723 menu_top_page (menu);
726 menu_current_top (menu);
728 case OP_CURRENT_MIDDLE:
729 menu_current_middle (menu);
731 case OP_CURRENT_BOTTOM:
732 menu_current_bottom (menu);
739 if (isdigit (LastKey)) mutt_ungetch (LastKey, 0);
741 if (mutt_get_field (_("Jump to message: "), buf, sizeof (buf), 0) != 0
745 if (mutt_atoi (buf, &i) < 0)
747 mutt_error _("Argument must be a message number.");
751 if (i > 0 && i <= Context->msgcount)
753 for (j = i-1; j < Context->msgcount; j++)
755 if (Context->hdrs[j]->virtual != -1)
758 if (j >= Context->msgcount)
760 for (j = i-2; j >= 0; j--)
762 if (Context->hdrs[j]->virtual != -1)
769 menu->current = Context->hdrs[j]->virtual;
770 if (menu->menu == MENU_PAGER)
772 op = OP_DISPLAY_MESSAGE;
776 menu->redraw = REDRAW_MOTION;
779 mutt_error _("That message is not visible.");
782 mutt_error _("Invalid message number.");
786 /* --------------------------------------------------------------------
787 * `index' specific commands
790 case OP_MAIN_DELETE_PATTERN:
795 CHECK_ACL(M_ACL_DELETE, _("delete message(s)"));
798 mutt_pattern_func (M_DELETE, _("Delete messages matching: "));
799 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
803 case OP_MAIN_FETCH_MAIL:
807 menu->redraw = REDRAW_FULL;
813 mutt_help (MENU_MAIN);
814 menu->redraw = REDRAW_FULL;
817 case OP_MAIN_SHOW_LIMIT:
819 if (!Context->pattern)
820 mutt_message _("No limit pattern is in effect.");
824 /* i18n: ask for a limit to apply */
825 snprintf (buf, sizeof(buf), _("Limit: %s"),Context->pattern);
826 mutt_message ("%s", buf);
833 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
835 if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
837 if (menu->oldcurrent >= 0)
839 /* try to find what used to be the current message */
841 for (i = 0; i < Context->vcount; i++)
842 if (Context->hdrs[Context->v2r[i]]->index == menu->oldcurrent)
847 if (menu->current < 0) menu->current = 0;
851 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
852 if (Context->msgcount && (Sort & SORT_MASK) == SORT_THREADS)
853 mutt_draw_tree (Context);
854 menu->redraw = REDRAW_FULL;
856 if (Context->pattern)
857 mutt_message _("To view all messages, limit to \"all\".");
869 if (query_quadoption (OPT_QUIT, _("Quit Mutt?")) == M_YES)
873 oldcount = Context ? Context->msgcount : 0;
875 if (!Context || (check = mx_close_mailbox (Context, &index_hint)) == 0)
879 if (check == M_NEW_MAIL || check == M_REOPENED)
880 update_index (menu, Context, check, oldcount, index_hint);
882 menu->redraw = REDRAW_FULL; /* new mail arrived? */
883 set_option (OPTSEARCHINVALID);
890 clearok (stdscr, TRUE);
891 menu->redraw = REDRAW_FULL;
895 case OP_SEARCH_REVERSE:
897 case OP_SEARCH_OPPOSITE:
901 if ((menu->current = mutt_search_command (menu->current, op)) == -1)
902 menu->current = menu->oldcurrent;
904 menu->redraw = REDRAW_MOTION;
908 case OP_SORT_REVERSE:
910 if (mutt_select_sort ((op == OP_SORT_REVERSE)) == 0)
912 if (Context && Context->msgcount)
915 set_option (OPTSEARCHINVALID);
917 if (menu->menu == MENU_PAGER)
919 op = OP_DISPLAY_MESSAGE;
922 menu->redraw |= REDRAW_STATUS;
930 if (tag && !option (OPTAUTOTAG))
932 for (j = 0; j < Context->vcount; j++)
933 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_TAG, 0);
934 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
938 mutt_set_flag (Context, CURHDR, M_TAG, !CURHDR->tagged);
940 Context->last_tag = CURHDR->tagged ? CURHDR :
941 ((Context->last_tag == CURHDR && !CURHDR->tagged)
942 ? NULL : Context->last_tag);
944 menu->redraw = REDRAW_STATUS;
945 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
948 menu->redraw |= REDRAW_MOTION_RESYNCH;
951 menu->redraw |= REDRAW_CURRENT;
955 case OP_MAIN_TAG_PATTERN:
959 mutt_pattern_func (M_TAG, _("Tag messages matching: "));
960 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
963 case OP_MAIN_UNDELETE_PATTERN:
968 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
970 if (mutt_pattern_func (M_UNDELETE, _("Undelete messages matching: ")) == 0)
971 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
974 case OP_MAIN_UNTAG_PATTERN:
978 if (mutt_pattern_func (M_UNTAG, _("Untag messages matching: ")) == 0)
979 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
982 /* --------------------------------------------------------------------
983 * The following operations can be performed inside of the pager.
987 case OP_MAIN_IMAP_FETCH:
988 if (Context && Context->magic == M_IMAP)
989 imap_check_mailbox (Context, &index_hint, 1);
992 case OP_MAIN_IMAP_LOGOUT_ALL:
993 if (Context && Context->magic == M_IMAP)
995 if (mx_close_mailbox (Context, &index_hint) != 0)
997 set_option (OPTSEARCHINVALID);
998 menu->redraw = REDRAW_FULL;
1004 mutt_message _("Logged out of IMAP servers.");
1005 set_option (OPTSEARCHINVALID);
1006 menu->redraw = REDRAW_FULL;
1010 case OP_MAIN_SYNC_FOLDER:
1012 if (Context && !Context->msgcount)
1019 int oldvcount = Context->vcount;
1020 int oldcount = Context->msgcount;
1022 HEADER *newhdr = NULL;
1024 /* threads may be reordered, so figure out what header the cursor
1025 * should be on. #3092 */
1026 newidx = menu->current;
1027 if (CURHDR->deleted)
1028 newidx = ci_next_undeleted (menu->current);
1030 newidx = ci_previous_undeleted (menu->current);
1032 newhdr = Context->hdrs[Context->v2r[newidx]];
1034 if ((check = mx_sync_mailbox (Context, &index_hint)) == 0)
1036 if (newhdr && Context->vcount != oldvcount)
1037 for (j = 0; j < Context->vcount; j++)
1039 if (Context->hdrs[Context->v2r[j]] == newhdr)
1045 set_option (OPTSEARCHINVALID);
1047 else if (check == M_NEW_MAIL || check == M_REOPENED)
1048 update_index (menu, Context, check, oldcount, index_hint);
1051 * do a sanity check even if mx_sync_mailbox failed.
1054 if (menu->current < 0 || menu->current >= Context->vcount)
1055 menu->current = ci_first_message ();
1058 /* check for a fatal error, or all messages deleted */
1062 /* if we were in the pager, redisplay the message */
1063 if (menu->menu == MENU_PAGER)
1065 op = OP_DISPLAY_MESSAGE;
1069 menu->redraw = REDRAW_FULL;
1072 case OP_MAIN_CHANGE_FOLDER:
1073 case OP_MAIN_NEXT_UNREAD_MAILBOX:
1076 op = OP_MAIN_CHANGE_FOLDER_READONLY;
1078 /* fallback to the readonly case */
1080 case OP_MAIN_CHANGE_FOLDER_READONLY:
1082 if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1083 cp = _("Open mailbox in read-only mode");
1085 cp = _("Open mailbox");
1088 if ((op == OP_MAIN_NEXT_UNREAD_MAILBOX) && Context && Context->path)
1090 strfcpy (buf, Context->path, sizeof (buf));
1091 mutt_pretty_mailbox (buf, sizeof (buf));
1092 mutt_buffy (buf, sizeof (buf));
1095 mutt_error _("No mailboxes have new mail");
1101 mutt_buffy (buf, sizeof (buf));
1103 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
1105 if (menu->menu == MENU_PAGER)
1107 op = OP_DISPLAY_MESSAGE;
1115 CLEARLINE (LINES-1);
1120 mutt_expand_path (buf, sizeof (buf));
1121 if (mx_get_magic (buf) <= 0)
1123 mutt_error (_("%s is not a mailbox."), buf);
1126 mutt_str_replace (&CurrentFolder, buf);
1128 /* keepalive failure in mutt_enter_fname may kill connection. #3028 */
1129 if (Context && !Context->path)
1136 mutt_str_replace (&LastFolder, Context->path);
1137 oldcount = Context ? Context->msgcount : 0;
1139 if ((check = mx_close_mailbox (Context, &index_hint)) != 0)
1141 if (check == M_NEW_MAIL || check == M_REOPENED)
1142 update_index (menu, Context, check, oldcount, index_hint);
1144 set_option (OPTSEARCHINVALID);
1145 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1153 /* Set CurrentMenu to MENU_MAIN before executing any folder
1154 * hooks so that all the index menu functions are available to
1158 CurrentMenu = MENU_MAIN;
1159 mutt_folder_hook (buf);
1161 if ((Context = mx_open_mailbox (buf,
1162 (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
1163 M_READONLY : 0, NULL)) != NULL)
1165 menu->current = ci_first_message ();
1170 mutt_clear_error ();
1171 mutt_buffy_check(1); /* force the buffy check after we have changed
1173 menu->redraw = REDRAW_FULL;
1174 set_option (OPTSEARCHINVALID);
1177 case OP_DISPLAY_MESSAGE:
1178 case OP_DISPLAY_HEADERS: /* don't weed the headers */
1183 * toggle the weeding of headers so that a user can press the key
1184 * again while reading the message.
1186 if (op == OP_DISPLAY_HEADERS)
1187 toggle_option (OPTWEED);
1189 unset_option (OPTNEEDRESORT);
1191 if ((Sort & SORT_MASK) == SORT_THREADS && CURHDR->collapsed)
1193 mutt_uncollapse_thread (Context, CURHDR);
1194 mutt_set_virtual (Context);
1195 if (option (OPTUNCOLLAPSEJUMP))
1196 menu->current = mutt_thread_next_unread (Context, CURHDR);
1199 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1200 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1201 if ((op = mutt_display_message (CURHDR)) == -1)
1203 unset_option (OPTNEEDRESORT);
1207 menu->menu = MENU_PAGER;
1208 menu->oldcurrent = menu->current;
1214 if (menu->menu == MENU_MAIN && attach_msg)
1220 if ((menu->menu == MENU_MAIN)
1221 && (query_quadoption (OPT_QUIT,
1222 _("Exit Mutt without saving?")) == M_YES))
1226 mx_fastclose_mailbox (Context);
1233 case OP_MAIN_BREAK_THREAD:
1239 if ((Sort & SORT_MASK) != SORT_THREADS)
1240 mutt_error _("Threading is not enabled.");
1241 else if (CURHDR->env->in_reply_to || CURHDR->env->references)
1244 HEADER *oldcur = CURHDR;
1246 mutt_break_thread (CURHDR);
1247 mutt_sort_headers (Context, 1);
1248 menu->current = oldcur->virtual;
1251 Context->changed = 1;
1252 mutt_message _("Thread broken");
1254 if (menu->menu == MENU_PAGER)
1256 op = OP_DISPLAY_MESSAGE;
1260 menu->redraw |= REDRAW_INDEX;
1263 mutt_error _("Thread cannot be broken, message is not part of a thread");
1267 case OP_MAIN_LINK_THREADS:
1272 CHECK_ACL(M_ACL_DELETE, _("link threads"));
1274 if ((Sort & SORT_MASK) != SORT_THREADS)
1275 mutt_error _("Threading is not enabled.");
1276 else if (!CURHDR->env->message_id)
1277 mutt_error _("No Message-ID: header available to link thread");
1278 else if (!tag && (!Context->last_tag || !Context->last_tag->tagged))
1279 mutt_error _("First, please tag a message to be linked here");
1282 HEADER *oldcur = CURHDR;
1284 if (mutt_link_threads (CURHDR, tag ? NULL : Context->last_tag,
1287 mutt_sort_headers (Context, 1);
1288 menu->current = oldcur->virtual;
1290 Context->changed = 1;
1291 mutt_message _("Threads linked");
1294 mutt_error _("No thread linked");
1297 if (menu->menu == MENU_PAGER)
1299 op = OP_DISPLAY_MESSAGE;
1303 menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
1312 mutt_edit_content_type (CURHDR, CURHDR->content, NULL);
1313 /* if we were in the pager, redisplay the message */
1314 if (menu->menu == MENU_PAGER)
1316 op = OP_DISPLAY_MESSAGE;
1320 menu->redraw = REDRAW_CURRENT;
1323 case OP_MAIN_NEXT_UNDELETED:
1327 if (menu->current >= Context->vcount - 1)
1329 if (menu->menu == MENU_MAIN)
1330 mutt_error _("You are on the last message.");
1333 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1335 menu->current = menu->oldcurrent;
1336 if (menu->menu == MENU_MAIN)
1337 mutt_error _("No undeleted messages.");
1339 else if (menu->menu == MENU_PAGER)
1341 op = OP_DISPLAY_MESSAGE;
1345 menu->redraw = REDRAW_MOTION;
1352 if (menu->current >= Context->vcount - 1)
1354 if (menu->menu == MENU_MAIN)
1355 mutt_error _("You are on the last message.");
1359 if (menu->menu == MENU_PAGER)
1361 op = OP_DISPLAY_MESSAGE;
1365 menu->redraw = REDRAW_MOTION;
1368 case OP_MAIN_PREV_UNDELETED:
1372 if (menu->current < 1)
1374 mutt_error _("You are on the first message.");
1377 if ((menu->current = ci_previous_undeleted (menu->current)) == -1)
1379 menu->current = menu->oldcurrent;
1380 if (menu->menu == MENU_MAIN)
1381 mutt_error _("No undeleted messages.");
1383 else if (menu->menu == MENU_PAGER)
1385 op = OP_DISPLAY_MESSAGE;
1389 menu->redraw = REDRAW_MOTION;
1396 if (menu->current < 1)
1398 if (menu->menu == MENU_MAIN) mutt_error _("You are on the first message.");
1402 if (menu->menu == MENU_PAGER)
1404 op = OP_DISPLAY_MESSAGE;
1408 menu->redraw = REDRAW_MOTION;
1411 case OP_DECRYPT_COPY:
1412 case OP_DECRYPT_SAVE:
1416 case OP_COPY_MESSAGE:
1418 case OP_DECODE_COPY:
1419 case OP_DECODE_SAVE:
1422 if (mutt_save_message (tag ? NULL : CURHDR,
1423 (op == OP_DECRYPT_SAVE) ||
1424 (op == OP_SAVE) || (op == OP_DECODE_SAVE),
1425 (op == OP_DECODE_SAVE) || (op == OP_DECODE_COPY),
1426 (op == OP_DECRYPT_SAVE) || (op == OP_DECRYPT_COPY) ||
1428 &menu->redraw) == 0 &&
1429 (op == OP_SAVE || op == OP_DECODE_SAVE || op == OP_DECRYPT_SAVE)
1433 menu->redraw |= REDRAW_INDEX;
1434 else if (option (OPTRESOLVE))
1436 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1438 menu->current = menu->oldcurrent;
1439 menu->redraw |= REDRAW_CURRENT;
1442 menu->redraw |= REDRAW_MOTION_RESYNCH;
1445 menu->redraw |= REDRAW_CURRENT;
1449 case OP_MAIN_NEXT_NEW:
1450 case OP_MAIN_NEXT_UNREAD:
1451 case OP_MAIN_PREV_NEW:
1452 case OP_MAIN_PREV_UNREAD:
1453 case OP_MAIN_NEXT_NEW_THEN_UNREAD:
1454 case OP_MAIN_PREV_NEW_THEN_UNREAD:
1457 int first_unread = -1;
1465 for (j = 0; j != Context->vcount; j++)
1467 #define CURHDRi Context->hdrs[Context->v2r[i]]
1468 if (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_NEXT_NEW_THEN_UNREAD)
1471 if (i > Context->vcount - 1)
1473 mutt_message _("Search wrapped to top.");
1482 mutt_message _("Search wrapped to bottom.");
1483 i = Context->vcount - 1;
1487 if (CURHDRi->collapsed && (Sort & SORT_MASK) == SORT_THREADS)
1489 if (UNREAD (CURHDRi) && first_unread == -1)
1491 if (UNREAD (CURHDRi) == 1 && first_new == -1)
1494 else if ((!CURHDRi->deleted && !CURHDRi->read))
1496 if (first_unread == -1)
1498 if ((!CURHDRi->old) && first_new == -1)
1502 if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD) &&
1505 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1506 op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1511 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1512 op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1514 menu->current = first_new;
1515 else if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD ||
1516 op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1517 && first_unread != -1)
1518 menu->current = first_unread;
1520 if (menu->current == -1)
1522 menu->current = menu->oldcurrent;
1523 mutt_error ("%s%s.", (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW) ? _("No new messages") : _("No unread messages"),
1524 Context->pattern ? _(" in this limited view") : "");
1526 else if (menu->menu == MENU_PAGER)
1528 op = OP_DISPLAY_MESSAGE;
1532 menu->redraw = REDRAW_MOTION;
1535 case OP_FLAG_MESSAGE:
1540 CHECK_ACL(M_ACL_WRITE, _("flag message"));
1544 for (j = 0; j < Context->vcount; j++)
1546 if (Context->hdrs[Context->v2r[j]]->tagged)
1547 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]],
1548 M_FLAG, !Context->hdrs[Context->v2r[j]]->flagged);
1551 menu->redraw |= REDRAW_INDEX;
1555 mutt_set_flag (Context, CURHDR, M_FLAG, !CURHDR->flagged);
1556 if (option (OPTRESOLVE))
1558 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1560 menu->current = menu->oldcurrent;
1561 menu->redraw = REDRAW_CURRENT;
1564 menu->redraw = REDRAW_MOTION_RESYNCH;
1567 menu->redraw = REDRAW_CURRENT;
1569 menu->redraw |= REDRAW_STATUS;
1577 CHECK_ACL(M_ACL_SEEN, _("toggle new"));
1581 for (j = 0; j < Context->vcount; j++)
1583 if (Context->hdrs[Context->v2r[j]]->tagged)
1585 if (Context->hdrs[Context->v2r[j]]->read ||
1586 Context->hdrs[Context->v2r[j]]->old)
1587 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_NEW, 1);
1589 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_READ, 1);
1592 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
1596 if (CURHDR->read || CURHDR->old)
1597 mutt_set_flag (Context, CURHDR, M_NEW, 1);
1599 mutt_set_flag (Context, CURHDR, M_READ, 1);
1601 if (option (OPTRESOLVE))
1603 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1605 menu->current = menu->oldcurrent;
1606 menu->redraw = REDRAW_CURRENT;
1609 menu->redraw = REDRAW_MOTION_RESYNCH;
1612 menu->redraw = REDRAW_CURRENT;
1613 menu->redraw |= REDRAW_STATUS;
1617 case OP_TOGGLE_WRITE:
1620 if (mx_toggle_write (Context) == 0)
1621 menu->redraw |= REDRAW_STATUS;
1624 case OP_MAIN_NEXT_THREAD:
1625 case OP_MAIN_NEXT_SUBTHREAD:
1626 case OP_MAIN_PREV_THREAD:
1627 case OP_MAIN_PREV_SUBTHREAD:
1633 case OP_MAIN_NEXT_THREAD:
1634 menu->current = mutt_next_thread (CURHDR);
1637 case OP_MAIN_NEXT_SUBTHREAD:
1638 menu->current = mutt_next_subthread (CURHDR);
1641 case OP_MAIN_PREV_THREAD:
1642 menu->current = mutt_previous_thread (CURHDR);
1645 case OP_MAIN_PREV_SUBTHREAD:
1646 menu->current = mutt_previous_subthread (CURHDR);
1650 if (menu->current < 0)
1652 menu->current = menu->oldcurrent;
1653 if (op == OP_MAIN_NEXT_THREAD || op == OP_MAIN_NEXT_SUBTHREAD)
1654 mutt_error _("No more threads.");
1656 mutt_error _("You are on the first thread.");
1658 else if (menu->menu == MENU_PAGER)
1660 op = OP_DISPLAY_MESSAGE;
1664 menu->redraw = REDRAW_MOTION;
1667 case OP_MAIN_PARENT_MESSAGE:
1672 if ((menu->current = mutt_parent_message (Context, CURHDR)) < 0)
1674 menu->current = menu->oldcurrent;
1676 else if (menu->menu == MENU_PAGER)
1678 op = OP_DISPLAY_MESSAGE;
1682 menu->redraw = REDRAW_MOTION;
1685 case OP_MAIN_SET_FLAG:
1686 case OP_MAIN_CLEAR_FLAG:
1691 /* CHECK_ACL(M_ACL_WRITE); */
1693 if (mutt_change_flag (tag ? NULL : CURHDR, (op == OP_MAIN_SET_FLAG)) == 0)
1695 menu->redraw = REDRAW_STATUS;
1697 menu->redraw |= REDRAW_INDEX;
1698 else if (option (OPTRESOLVE))
1700 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1702 menu->current = menu->oldcurrent;
1703 menu->redraw |= REDRAW_CURRENT;
1706 menu->redraw |= REDRAW_MOTION_RESYNCH;
1709 menu->redraw |= REDRAW_CURRENT;
1713 case OP_MAIN_COLLAPSE_THREAD:
1717 if ((Sort & SORT_MASK) != SORT_THREADS)
1719 mutt_error _("Threading is not enabled.");
1723 if (CURHDR->collapsed)
1725 menu->current = mutt_uncollapse_thread (Context, CURHDR);
1726 mutt_set_virtual (Context);
1727 if (option (OPTUNCOLLAPSEJUMP))
1728 menu->current = mutt_thread_next_unread (Context, CURHDR);
1730 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR))
1732 menu->current = mutt_collapse_thread (Context, CURHDR);
1733 mutt_set_virtual (Context);
1737 mutt_error _("Thread contains unread messages.");
1741 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1745 case OP_MAIN_COLLAPSE_ALL:
1749 if ((Sort & SORT_MASK) != SORT_THREADS)
1751 mutt_error _("Threading is not enabled.");
1757 THREAD *thread, *top;
1760 if (CURHDR->collapsed)
1761 final = mutt_uncollapse_thread (Context, CURHDR);
1762 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR))
1763 final = mutt_collapse_thread (Context, CURHDR);
1765 final = CURHDR->virtual;
1767 base = Context->hdrs[Context->v2r[final]];
1769 top = Context->tree;
1770 Context->collapsed = !Context->collapsed;
1771 while ((thread = top) != NULL)
1773 while (!thread->message)
1774 thread = thread->child;
1775 h = thread->message;
1777 if (h->collapsed != Context->collapsed)
1780 mutt_uncollapse_thread (Context, h);
1781 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (h))
1782 mutt_collapse_thread (Context, h);
1787 mutt_set_virtual (Context);
1788 for (j = 0; j < Context->vcount; j++)
1790 if (Context->hdrs[Context->v2r[j]]->index == base->index)
1797 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1801 /* --------------------------------------------------------------------
1802 * These functions are invoked directly from the internal-pager
1805 case OP_BOUNCE_MESSAGE:
1810 ci_bounce_message (tag ? NULL : CURHDR, &menu->redraw);
1813 case OP_CREATE_ALIAS:
1815 mutt_create_alias (Context && Context->vcount ? CURHDR->env : NULL, NULL);
1816 MAYBE_REDRAW (menu->redraw);
1817 menu->redraw |= REDRAW_CURRENT;
1822 mutt_query_menu (NULL, 0);
1823 MAYBE_REDRAW (menu->redraw);
1831 CHECK_ACL(M_ACL_DELETE, _("delete message"));
1835 mutt_tag_set_flag (M_DELETE, 1);
1836 if (option (OPTDELETEUNTAG))
1837 mutt_tag_set_flag (M_TAG, 0);
1838 menu->redraw = REDRAW_INDEX;
1842 mutt_set_flag (Context, CURHDR, M_DELETE, 1);
1843 if (option (OPTDELETEUNTAG))
1844 mutt_set_flag (Context, CURHDR, M_TAG, 0);
1845 if (option (OPTRESOLVE))
1847 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1849 menu->current = menu->oldcurrent;
1850 menu->redraw = REDRAW_CURRENT;
1852 else if (menu->menu == MENU_PAGER)
1854 op = OP_DISPLAY_MESSAGE;
1858 menu->redraw |= REDRAW_MOTION_RESYNCH;
1861 menu->redraw = REDRAW_CURRENT;
1863 menu->redraw |= REDRAW_STATUS;
1866 case OP_DELETE_THREAD:
1867 case OP_DELETE_SUBTHREAD:
1872 CHECK_ACL(M_ACL_DELETE, _("delete message(s)"));
1874 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 1,
1875 op == OP_DELETE_THREAD ? 0 : 1);
1879 if (option (OPTDELETEUNTAG))
1880 mutt_thread_set_flag (CURHDR, M_TAG, 0,
1881 op == OP_DELETE_THREAD ? 0 : 1);
1882 if (option (OPTRESOLVE))
1883 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1884 menu->current = menu->oldcurrent;
1885 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1889 case OP_DISPLAY_ADDRESS:
1893 mutt_display_address (CURHDR->env);
1896 case OP_ENTER_COMMAND:
1898 CurrentMenu = MENU_MAIN;
1899 mutt_enter_command ();
1900 mutt_check_rescore (Context);
1901 if (option (OPTFORCEREDRAWINDEX))
1902 menu->redraw = REDRAW_FULL;
1903 unset_option (OPTFORCEREDRAWINDEX);
1904 unset_option (OPTFORCEREDRAWPAGER);
1907 case OP_EDIT_MESSAGE:
1913 CHECK_ACL(M_ACL_INSERT, _("edit message"));
1915 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1916 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1917 mutt_edit_message (Context, tag ? NULL : CURHDR);
1918 menu->redraw = REDRAW_FULL;
1922 case OP_FORWARD_MESSAGE:
1927 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1928 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1929 ci_send_message (SENDFORWARD, NULL, NULL, Context, tag ? NULL : CURHDR);
1930 menu->redraw = REDRAW_FULL;
1934 case OP_FORGET_PASSPHRASE:
1935 crypt_forget_passphrase ();
1938 case OP_GROUP_REPLY:
1943 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1944 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1945 ci_send_message (SENDREPLY|SENDGROUPREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
1946 menu->redraw = REDRAW_FULL;
1954 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
1955 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1956 ci_send_message (SENDREPLY|SENDLISTREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
1957 menu->redraw = REDRAW_FULL;
1963 ci_send_message (0, NULL, NULL, Context, NULL);
1964 menu->redraw = REDRAW_FULL;
1968 if (!(WithCrypto & APPLICATION_PGP))
1971 ci_send_message (SENDKEY, NULL, NULL, NULL, NULL);
1972 menu->redraw = REDRAW_FULL;
1976 case OP_EXTRACT_KEYS:
1981 crypt_extract_keys_from_messages(tag ? NULL : CURHDR);
1982 menu->redraw = REDRAW_FULL;
1986 case OP_CHECK_TRADITIONAL:
1987 if (!(WithCrypto & APPLICATION_PGP))
1991 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1992 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1994 if (menu->menu == MENU_PAGER)
1996 op = OP_DISPLAY_MESSAGE;
2005 mutt_pipe_message (tag ? NULL : CURHDR);
2008 /* in an IMAP folder index with imap_peek=no, piping could change
2009 * new or old messages status to read. Redraw what's needed.
2011 if (Context->magic == M_IMAP && !option (OPTIMAPPEEK))
2013 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
2017 MAYBE_REDRAW (menu->redraw);
2024 mutt_print_message (tag ? NULL : CURHDR);
2027 /* in an IMAP folder index with imap_peek=no, printing could change
2028 * new or old messages status to read. Redraw what's needed.
2030 if (Context->magic == M_IMAP && !option (OPTIMAPPEEK))
2032 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
2038 case OP_MAIN_READ_THREAD:
2039 case OP_MAIN_READ_SUBTHREAD:
2044 CHECK_ACL(M_ACL_SEEN, _("mark message(s) as read"));
2046 rc = mutt_thread_set_flag (CURHDR, M_READ, 1,
2047 op == OP_MAIN_READ_THREAD ? 0 : 1);
2051 if (option (OPTRESOLVE))
2053 if ((menu->current = (op == OP_MAIN_READ_THREAD ?
2054 mutt_next_thread (CURHDR) : mutt_next_subthread (CURHDR))) == -1)
2055 menu->current = menu->oldcurrent;
2056 else if (menu->menu == MENU_PAGER)
2058 op = OP_DISPLAY_MESSAGE;
2062 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2066 case OP_RECALL_MESSAGE:
2069 ci_send_message (SENDPOSTPONED, NULL, NULL, Context, NULL);
2070 menu->redraw = REDRAW_FULL;
2081 for (j = 0; j < Context->vcount; j++)
2083 if (Context->hdrs[Context->v2r[j]]->tagged)
2084 mutt_resend_message (NULL, Context, Context->hdrs[Context->v2r[j]]);
2088 mutt_resend_message (NULL, Context, CURHDR);
2090 menu->redraw = REDRAW_FULL;
2098 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
2099 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
2100 ci_send_message (SENDREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
2101 menu->redraw = REDRAW_FULL;
2104 case OP_SHELL_ESCAPE:
2106 mutt_shell_escape ();
2107 MAYBE_REDRAW (menu->redraw);
2111 case OP_TAG_SUBTHREAD:
2115 rc = mutt_thread_set_flag (CURHDR, M_TAG, !CURHDR->tagged,
2116 op == OP_TAG_THREAD ? 0 : 1);
2120 if (option (OPTRESOLVE))
2122 if (op == OP_TAG_THREAD)
2123 menu->current = mutt_next_thread (CURHDR);
2125 menu->current = mutt_next_subthread (CURHDR);
2127 if (menu->current == -1)
2128 menu->current = menu->oldcurrent;
2130 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2139 CHECK_ACL(M_ACL_DELETE, _("undelete message"));
2143 mutt_tag_set_flag (M_DELETE, 0);
2144 menu->redraw = REDRAW_INDEX;
2148 mutt_set_flag (Context, CURHDR, M_DELETE, 0);
2149 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
2152 menu->redraw = REDRAW_MOTION_RESYNCH;
2155 menu->redraw = REDRAW_CURRENT;
2157 menu->redraw |= REDRAW_STATUS;
2160 case OP_UNDELETE_THREAD:
2161 case OP_UNDELETE_SUBTHREAD:
2166 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
2168 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2169 op == OP_UNDELETE_THREAD ? 0 : 1);
2173 if (option (OPTRESOLVE))
2175 if (op == OP_UNDELETE_THREAD)
2176 menu->current = mutt_next_thread (CURHDR);
2178 menu->current = mutt_next_subthread (CURHDR);
2180 if (menu->current == -1)
2181 menu->current = menu->oldcurrent;
2183 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2195 case OP_VIEW_ATTACHMENTS:
2198 mutt_view_attachments (CURHDR);
2199 if (CURHDR->attach_del)
2200 Context->changed = 1;
2201 menu->redraw = REDRAW_FULL;
2212 if (menu->menu == MENU_MAIN)
2213 km_error_key (MENU_MAIN);
2216 if (menu->menu == MENU_PAGER)
2218 menu->menu = MENU_MAIN;
2219 menu->redraw = REDRAW_FULL;
2221 set_option (OPTWEED); /* turn header weeding back on. */
2228 mutt_menuDestroy (&menu);
2232 void mutt_set_header_color (CONTEXT *ctx, HEADER *curhdr)
2239 for (color = ColorIndexList; color; color = color->next)
2240 if (mutt_pattern_exec (color->color_pattern, M_MATCH_FULL_ADDRESS, ctx, curhdr))
2242 curhdr->pair = color->pair;
2245 curhdr->pair = ColorDefs[MT_COLOR_NORMAL];