2 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
20 #include "mutt_curses.h"
22 #include "mutt_menu.h"
34 #include "imap_private.h"
37 #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_MSGCOUNT if (!Context) \
61 mutt_error _(No_mailbox_is_open); \
64 else if (!Context->msgcount) \
67 mutt_error _(There_are_no_messages); \
71 #define CHECK_VISIBLE if (Context && menu->current >= Context->vcount) \
74 mutt_error _(No_visible); \
79 #define CHECK_READONLY if (Context->readonly) \
82 mutt_error _(Mailbox_is_read_only); \
87 /* the error message returned here could be better. */
88 #define CHECK_IMAP_ACL(aclbit) if (Context->magic == M_IMAP) \
89 if (mutt_bit_isset (((IMAP_DATA *)Context->data)->capabilities, ACL) \
90 && !mutt_bit_isset(((IMAP_DATA *)Context->data)->rights,aclbit)){ \
92 mutt_error ("Operation not permitted by the IMAP ACL for this mailbox"); \
97 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
100 mutt_error _(Function_not_permitted_in_attach_message_mode); \
104 #define CURHDR Context->hdrs[Context->v2r[menu->current]]
105 #define OLDHDR Context->hdrs[Context->v2r[menu->oldcurrent]]
106 #define UNREAD(h) mutt_thread_contains_unread (Context, h)
108 extern const char *ReleaseDate;
109 extern size_t UngetCount;
111 void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num)
113 format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR | M_FORMAT_INDEX;
114 int edgemsgno, reverse = Sort & SORT_REVERSE;
115 HEADER *h = Context->hdrs[Context->v2r[num]];
118 if ((Sort & SORT_MASK) == SORT_THREADS && h->tree)
120 flag |= M_FORMAT_TREE; /* display the thread tree */
121 if (h->display_subject)
122 flag |= M_FORMAT_FORCESUBJ;
127 if (menu->top + menu->pagelen > menu->max)
128 edgemsgno = Context->v2r[menu->max - 1];
130 edgemsgno = Context->v2r[menu->top + menu->pagelen - 1];
133 edgemsgno = Context->v2r[menu->top];
135 for (tmp = h->thread->parent; tmp; tmp = tmp->parent)
140 /* if no ancestor is visible on current screen, provisionally force
142 if (reverse ? tmp->message->msgno > edgemsgno : tmp->message->msgno < edgemsgno)
144 flag |= M_FORMAT_FORCESUBJ;
147 else if (tmp->message->virtual >= 0)
150 if (flag & M_FORMAT_FORCESUBJ)
152 for (tmp = h->thread->prev; tmp; tmp = tmp->prev)
157 /* ...but if a previous sibling is available, don't force it */
158 if (reverse ? tmp->message->msgno > edgemsgno : tmp->message->msgno < edgemsgno)
160 else if (tmp->message->virtual >= 0)
162 flag &= ~M_FORMAT_FORCESUBJ;
170 _mutt_make_string (s, l, NONULL (HdrFmt), Context, h, flag);
173 int index_color (int index_no)
175 HEADER *h = Context->hdrs[Context->v2r[index_no]];
180 mutt_set_header_color (Context, h);
184 static int ci_next_undeleted (int msgno)
188 for (i=msgno+1; i < Context->vcount; i++)
189 if (! Context->hdrs[Context->v2r[i]]->deleted)
194 static int ci_previous_undeleted (int msgno)
198 for (i=msgno-1; i>=0; i--)
199 if (! Context->hdrs[Context->v2r[i]]->deleted)
204 /* Return the index of the first new message, or failing that, the first
207 static int ci_first_message (void)
211 if (Context && Context->msgcount)
213 for (i=0; i < Context->vcount; i++)
215 if (! Context->hdrs[Context->v2r[i]]->read &&
216 ! Context->hdrs[Context->v2r[i]]->deleted)
218 if (! Context->hdrs[Context->v2r[i]]->old)
227 /* If Sort is reverse and not threaded, the latest message is first.
228 * If Sort is threaded, the latest message is first iff exactly one
229 * of Sort and SortAux are reverse.
231 if (((Sort & SORT_REVERSE) && (Sort & SORT_MASK) != SORT_THREADS) ||
232 ((Sort & SORT_MASK) == SORT_THREADS &&
233 ((Sort ^ SortAux) & SORT_REVERSE)))
236 return (Context->vcount ? Context->vcount - 1 : 0);
241 /* This should be in mx.c, but it only gets used here. */
242 static int mx_toggle_write (CONTEXT *ctx)
249 mutt_error _("Cannot toggle write on a readonly mailbox!");
256 mutt_message _("Changes to folder will be written on folder exit.");
261 mutt_message _("Changes to folder will not be written.");
267 static void update_index (MUTTMENU *menu, CONTEXT *ctx, int check,
268 int oldcount, int index_hint)
270 /* store pointers to the newly added messages */
271 HEADER **save_new = NULL;
274 /* take note of the current message */
277 if (menu->current < Context->vcount)
278 menu->oldcurrent = index_hint;
280 oldcount = 0; /* invalid message number! */
283 /* We are in a limited view. Check if the new message(s) satisfy
284 * the limit criteria. If they do, set their virtual msgno so that
285 * they will be visible in the limited view */
286 if (Context->pattern)
288 #define THIS_BODY Context->hdrs[j]->content
289 if (oldcount || check == M_REOPENED)
291 for (j = (check == M_REOPENED) ? 0 : oldcount; j < Context->msgcount; j++)
293 if (mutt_pattern_exec (Context->limit_pattern,
294 M_MATCH_FULL_ADDRESS,
295 Context, Context->hdrs[j]))
297 Context->hdrs[j]->virtual = Context->vcount;
298 Context->v2r[Context->vcount] = j;
299 Context->hdrs[j]->limited = 1;
301 Context->vsize += THIS_BODY->length + THIS_BODY->offset - THIS_BODY->hdr_offset;
308 /* save the list of new messages */
309 if (oldcount && check != M_REOPENED
310 && ((Sort & SORT_MASK) == SORT_THREADS))
312 save_new = (HEADER **) safe_malloc (sizeof (HEADER *) * (Context->msgcount - oldcount));
313 for (j = oldcount; j < Context->msgcount; j++)
314 save_new[j-oldcount] = Context->hdrs[j];
317 /* if the mailbox was reopened, need to rethread from scratch */
318 mutt_sort_headers (Context, (check == M_REOPENED));
320 /* uncollapse threads with new mail */
321 if ((Sort & SORT_MASK) == SORT_THREADS)
323 if (check == M_REOPENED)
327 Context->collapsed = 0;
329 for (h = Context->tree; h; h = h->next)
331 for (j = h; !j->message; j = j->child)
333 mutt_uncollapse_thread (Context, j->message);
335 mutt_set_virtual (Context);
339 for (j = 0; j < Context->msgcount - oldcount; j++)
343 for (k = 0; k < Context->msgcount; k++)
345 HEADER *h = Context->hdrs[k];
346 if (h == save_new[j] && (!Context->pattern || h->limited))
347 mutt_uncollapse_thread (Context, h);
351 mutt_set_virtual (Context);
358 /* restore the current message to the message it was pointing to */
359 for (j = 0; j < Context->vcount; j++)
361 if (Context->hdrs[Context->v2r[j]]->index == menu->oldcurrent)
369 if (menu->current < 0)
370 menu->current = ci_first_message ();
374 static void resort_index (MUTTMENU *menu)
377 HEADER *current = CURHDR;
380 mutt_sort_headers (Context, 0);
381 /* Restore the current message */
383 for (i = 0; i < Context->vcount; i++)
385 if (Context->hdrs[Context->v2r[i]] == current)
392 if ((Sort & SORT_MASK) == SORT_THREADS && menu->current < 0)
393 menu->current = mutt_parent_message (Context, current);
395 if (menu->current < 0)
396 menu->current = ci_first_message ();
398 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
401 struct mapping_t IndexHelp[] = {
402 { N_("Quit"), OP_QUIT },
403 { N_("Del"), OP_DELETE },
404 { N_("Undel"), OP_UNDELETE },
405 { N_("Save"), OP_SAVE },
406 { N_("Mail"), OP_MAIL },
407 { N_("Reply"), OP_REPLY },
408 { N_("Group"), OP_GROUP_REPLY },
409 { N_("Help"), OP_HELP },
414 struct mapping_t IndexNewsHelp[] = {
415 { N_("Quit"), OP_QUIT },
416 { N_("Del"), OP_DELETE },
417 { N_("Undel"), OP_UNDELETE },
418 { N_("Save"), OP_SAVE },
419 { N_("Post"), OP_POST },
420 { N_("Followup"), OP_FOLLOWUP },
421 { N_("Catchup"), OP_CATCHUP },
422 { N_("Help"), OP_HELP },
427 /* This function handles the message index window as well as commands returned
428 * from the pager (MENU_PAGER).
430 int mutt_index_menu (void)
432 char buf[LONG_STRING], helpstr[SHORT_STRING];
435 int done = 0; /* controls when to exit the "event" loop */
437 int tag = 0; /* has the tag-prefix command been pressed? */
442 char *cp; /* temporary variable. */
443 int index_hint; /* used to restore cursor position */
444 int do_buffy_notify = 1;
445 int close = 0; /* did we OP_QUIT or OP_EXIT out of this menu? */
446 int attach_msg = option(OPTATTACHMSG);
448 menu = mutt_new_menu ();
449 menu->menu = MENU_MAIN;
451 menu->pagelen = LINES - 3;
452 menu->make_entry = index_make_entry;
453 menu->color = index_color;
454 menu->current = ci_first_message ();
455 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
457 (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp :
462 mutt_buffy_check(1); /* force the buffy check after we enter the folder */
466 tag = 0; /* clear the tag-prefix */
468 menu->max = Context ? Context->vcount : 0;
469 oldcount = Context ? Context->msgcount : 0;
471 /* check if we need to resort the index because just about
472 * any 'op' below could do mutt_enter_command(), either here or
473 * from any new menu launched, and change $sort/$sort_aux
475 if (option (OPTNEEDRESORT) && Context && Context->msgcount)
478 if (option (OPTREDRAWTREE) && Context && Context->msgcount && (Sort & SORT_MASK) == SORT_THREADS)
480 mutt_draw_tree (Context);
481 menu->redraw |= REDRAW_STATUS;
482 unset_option (OPTREDRAWTREE);
485 if (Context && !attach_msg)
488 /* check for new mail in the mailbox. If nonzero, then something has
489 * changed about the file (either we got new mail or the file was
490 * modified underneath us.)
494 imap_allow_reopen (Context);
497 index_hint = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ? CURHDR->index : 0;
499 if ((check = mx_check_mailbox (Context, &index_hint, 0)) < 0)
503 /* fatal error occurred */
505 menu->redraw = REDRAW_FULL;
508 set_option (OPTSEARCHINVALID);
510 else if (check == M_NEW_MAIL || check == M_REOPENED || check == M_FLAGS)
512 update_index (menu, Context, check, oldcount, index_hint);
514 /* notify the user of new mail */
515 if (check == M_REOPENED)
516 mutt_error _("Mailbox was externally modified. Flags may be wrong.");
517 else if (check == M_NEW_MAIL)
519 mutt_message _("New mail in this mailbox.");
520 if (option (OPTBEEPNEW))
522 } else if (check == M_FLAGS)
523 mutt_message _("Mailbox was externally modified.");
525 /* avoid the message being overwritten by buffy */
528 menu->redraw = REDRAW_FULL;
529 menu->max = Context->vcount;
531 set_option (OPTSEARCHINVALID);
537 imap_disallow_reopen (Context);
542 /* check for new mail in the incoming folders */
544 if ((newcount = mutt_buffy_check (0)) != oldcount)
545 menu->redraw |= REDRAW_STATUS;
548 if (mutt_buffy_notify () && option (OPTBEEPNEW))
558 if (menu->redraw & REDRAW_FULL)
560 menu_redraw_full (menu);
564 if (menu->menu == MENU_MAIN)
566 if (Context && Context->hdrs && !(menu->current >= Context->vcount))
568 menu_check_recenter (menu);
570 if (menu->redraw & REDRAW_INDEX)
572 menu_redraw_index (menu);
573 menu->redraw |= REDRAW_STATUS;
575 else if (menu->redraw & (REDRAW_MOTION_RESYNCH | REDRAW_MOTION))
576 menu_redraw_motion (menu);
577 else if (menu->redraw & REDRAW_CURRENT)
578 menu_redraw_current (menu);
581 if (menu->redraw & REDRAW_STATUS)
583 menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
584 CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
585 SETCOLOR (MT_COLOR_STATUS);
586 mutt_paddstr (COLS, buf);
587 SETCOLOR (MT_COLOR_NORMAL);
588 menu->redraw &= ~REDRAW_STATUS;
592 if (menu->current < menu->max)
593 menu->oldcurrent = menu->current;
595 menu->oldcurrent = -1;
597 if (option (OPTARROWCURSOR))
598 move (menu->current - menu->top + menu->offset, 2);
600 move (menu->current - menu->top + menu->offset, COLS - 1);
603 op = km_dokey (MENU_MAIN);
605 dprint(4, (debugfile, "mutt_index_menu[%d]: Got op %d\n", __LINE__, op));
607 #if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
611 mutt_resize_screen ();
612 menu->redraw = REDRAW_FULL;
613 menu->menu = MENU_MAIN;
615 menu->top = 0; /* so we scroll the right amount */
617 * force a real complete redraw. clrtobot() doesn't seem to be able
618 * to handle every case without this.
620 clearok(stdscr,TRUE);
626 continue; /* either user abort or timeout */
630 /* special handling for the tag-prefix function */
631 if (op == OP_TAG_PREFIX)
635 mutt_error _("No mailbox is open.");
639 if (!Context->tagged)
641 mutt_error _("No tagged messages.");
646 /* give visual indication that the next command is a tag- command */
647 mvaddstr (LINES - 1, 0, "tag-");
650 /* get the real command */
651 if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX)
653 /* abort tag sequence */
658 else if (option (OPTAUTOTAG) && Context && Context->tagged)
661 if (op == OP_TAG_PREFIX_COND)
665 mutt_error _("No mailbox is open.");
669 if (!Context->tagged)
675 if(tmp.op==OP_END_COND)break;
677 mutt_message _("Nothing to do.");
682 /* give visual indication that the next command is a tag- command */
683 mvaddstr (LINES - 1, 0, "tag-");
686 /* get the real command */
687 if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX)
689 /* abort tag sequence */
699 if (menu->current < menu->max)
700 menu->oldcurrent = menu->current;
702 menu->oldcurrent = -1;
704 mutt_curs_set (1); /* fallback from the pager */
708 unset_option (OPTNEWS); /* for any case */
713 /* ----------------------------------------------------------------------
718 menu_bottom_page (menu);
721 menu_first_entry (menu);
724 menu_middle_page (menu);
730 menu_half_down (menu);
733 menu_next_line (menu);
736 menu_prev_line (menu);
739 menu_next_page (menu);
742 menu_prev_page (menu);
745 menu_last_entry (menu);
748 menu_top_page (menu);
751 menu_current_top (menu);
753 case OP_CURRENT_MIDDLE:
754 menu_current_middle (menu);
756 case OP_CURRENT_BOTTOM:
757 menu_current_bottom (menu);
764 if (Context->magic == M_NNTP)
768 if (op == OP_GET_MESSAGE)
771 if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0
777 LIST *ref = CURHDR->env->references;
780 mutt_error _("Article has no parent reference!");
783 strfcpy (buf, ref->data, sizeof (buf));
785 if (!Context->id_hash)
786 Context->id_hash = mutt_make_id_hash (Context);
787 if ((h = hash_find (Context->id_hash, buf)))
789 if (h->virtual != -1)
791 menu->current = h->virtual;
792 menu->redraw = REDRAW_MOTION_RESYNCH;
794 else if (h->collapsed)
796 mutt_uncollapse_thread (Context, h);
797 mutt_set_virtual (Context);
798 menu->current = h->virtual;
799 menu->redraw = REDRAW_MOTION_RESYNCH;
802 mutt_error _("Message not visible in limited view.");
806 if (nntp_check_msgid (Context, buf) == 0)
808 h = Context->hdrs[Context->msgcount-1];
809 mutt_sort_headers (Context, 0);
810 menu->current = h->virtual;
811 menu->redraw = REDRAW_FULL;
814 mutt_error (_("Article %s not found on server"), buf);
819 case OP_GET_CHILDREN:
820 case OP_RECONSTRUCT_THREAD:
822 if (Context->magic == M_NNTP)
825 int old = CURHDR->index, i;
827 if (!CURHDR->env->message_id)
829 mutt_error _("No Message-Id. Unable to perform operation");
833 if (!Context->id_hash)
834 Context->id_hash = mutt_make_id_hash (Context);
835 strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
837 if (op == OP_RECONSTRUCT_THREAD)
839 LIST *ref = CURHDR->env->references;
842 nntp_check_msgid (Context, ref->data);
843 /* the last msgid in References is the root message */
845 strfcpy (buf, ref->data, sizeof (buf));
849 mutt_message _("Check for children of message...");
850 if (nntp_check_children (Context, buf) == 0)
852 mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
853 h = hash_find (Context->id_hash, buf);
854 /* if the root message was retrieved, move to it */
856 menu->current = h->virtual;
857 else /* try to restore old position */
858 for (i = 0; i < Context->msgcount; i++)
859 if (Context->hdrs[i]->index == old)
861 menu->current = Context->hdrs[i]->virtual;
862 /* As an added courtesy, recenter the menu
863 * with the current entry at the middle of the screen */
864 menu_check_recenter (menu);
865 menu_current_middle (menu);
868 menu->redraw = REDRAW_FULL;
878 if (isdigit (LastKey)) mutt_ungetch (LastKey, 0);
880 if (mutt_get_field (_("Jump to message: "), buf, sizeof (buf), 0) != 0
884 if (! isdigit ((unsigned char) buf[0]))
886 mutt_error _("Argument must be a message number.");
891 if (i > 0 && i <= Context->msgcount)
893 for (j = i-1; j < Context->msgcount; j++)
895 if (Context->hdrs[j]->virtual != -1)
898 if (j >= Context->msgcount)
900 for (j = i-2; j >= 0; j--)
902 if (Context->hdrs[j]->virtual != -1)
909 menu->current = Context->hdrs[j]->virtual;
910 if (menu->menu == MENU_PAGER)
912 op = OP_DISPLAY_MESSAGE;
916 menu->redraw = REDRAW_MOTION;
919 mutt_error _("That message is not visible.");
922 mutt_error _("Invalid message number.");
926 /* --------------------------------------------------------------------
927 * `index' specific commands
930 case OP_MAIN_DELETE_PATTERN:
937 CHECK_IMAP_ACL(IMAP_ACL_DELETE);
941 mutt_pattern_func (M_DELETE, _("Delete messages matching: "));
942 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
946 case OP_MAIN_FETCH_MAIL:
950 menu->redraw = REDRAW_FULL;
956 mutt_help (MENU_MAIN);
957 menu->redraw = REDRAW_FULL;
960 case OP_MAIN_SHOW_LIMIT:
962 if (!Context->pattern)
963 mutt_message _("No limit pattern is in effect.");
967 /* i18n: ask for a limit to apply */
968 snprintf (buf, sizeof(buf), _("Limit: %s"),Context->pattern);
969 mutt_message ("%s", buf);
977 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
979 if (op == OP_TOGGLE_READ)
981 char buf[LONG_STRING];
983 if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
985 snprintf (buf, sizeof (buf), "!~R!~D~s%s",
986 Context->pattern ? Context->pattern : ".*");
987 set_option (OPTHIDEREAD);
991 strfcpy (buf, Context->pattern + 8, sizeof(buf));
992 if (!*buf || strncmp (buf, ".*", 2) == 0)
993 snprintf (buf, sizeof(buf), "~A");
994 unset_option (OPTHIDEREAD);
996 FREE (&Context->pattern);
997 Context->pattern = safe_strdup (buf);
999 if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
1000 mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1002 if (menu->oldcurrent >= 0)
1004 /* try to find what used to be the current message */
1006 for (i = 0; i < Context->vcount; i++)
1007 if (Context->hdrs[Context->v2r[i]]->index == menu->oldcurrent)
1012 if (menu->current < 0) menu->current = 0;
1016 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1017 if ((Sort & SORT_MASK) == SORT_THREADS)
1018 mutt_draw_tree (Context);
1019 menu->redraw = REDRAW_FULL;
1032 if (query_quadoption (OPT_QUIT, _("Quit Mutt?")) == M_YES)
1036 oldcount = Context ? Context->msgcount : 0;
1038 if (!Context || (check = mx_close_mailbox (Context, &index_hint)) == 0)
1042 if (check == M_NEW_MAIL || check == M_REOPENED)
1043 update_index (menu, Context, check, oldcount, index_hint);
1045 menu->redraw = REDRAW_FULL; /* new mail arrived? */
1046 set_option (OPTSEARCHINVALID);
1053 clearok (stdscr, TRUE);
1054 menu->redraw = REDRAW_FULL;
1058 case OP_SEARCH_REVERSE:
1059 case OP_SEARCH_NEXT:
1060 case OP_SEARCH_OPPOSITE:
1064 if ((menu->current = mutt_search_command (menu->current, op)) == -1)
1065 menu->current = menu->oldcurrent;
1067 menu->redraw = REDRAW_MOTION;
1071 case OP_SORT_REVERSE:
1073 if (mutt_select_sort ((op == OP_SORT_REVERSE)) == 0)
1075 if (Context && Context->msgcount)
1077 resort_index (menu);
1078 set_option (OPTSEARCHINVALID);
1087 if (tag && !option (OPTAUTOTAG))
1089 for (j = 0; j < Context->vcount; j++)
1090 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_TAG, 0);
1091 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
1095 mutt_set_flag (Context, CURHDR, M_TAG, !CURHDR->tagged);
1096 menu->redraw = REDRAW_STATUS;
1097 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
1100 menu->redraw |= REDRAW_MOTION_RESYNCH;
1103 menu->redraw |= REDRAW_CURRENT;
1107 case OP_MAIN_TAG_PATTERN:
1111 mutt_pattern_func (M_TAG, _("Tag messages matching: "));
1112 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1115 case OP_MAIN_UNDELETE_PATTERN:
1122 CHECK_IMAP_ACL(IMAP_ACL_DELETE);
1125 if (mutt_pattern_func (M_UNDELETE, _("Undelete messages matching: ")) == 0)
1126 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1129 case OP_MAIN_UNTAG_PATTERN:
1133 if (mutt_pattern_func (M_UNTAG, _("Untag messages matching: ")) == 0)
1134 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1137 /* --------------------------------------------------------------------
1138 * The following operations can be performed inside of the pager.
1142 case OP_MAIN_IMAP_FETCH:
1143 if (Context->magic == M_IMAP)
1144 imap_check_mailbox (Context, &index_hint, 1);
1148 case OP_MAIN_SYNC_FOLDER:
1154 int oldvcount = Context->vcount;
1155 int oldcount = Context->msgcount;
1159 /* calculate the number of messages _above_ the cursor,
1160 * so we can keep the cursor on the current message
1162 for (j = 0; j <= menu->current; j++)
1164 if (Context->hdrs[Context->v2r[j]]->deleted)
1168 if ((check = mx_sync_mailbox (Context, &index_hint)) == 0)
1170 if (Context->vcount != oldvcount)
1171 menu->current -= dcount;
1172 set_option (OPTSEARCHINVALID);
1174 else if (check == M_NEW_MAIL || check == M_REOPENED)
1175 update_index (menu, Context, check, oldcount, index_hint);
1178 * do a sanity check even if mx_sync_mailbox failed.
1181 if (menu->current < 0 || menu->current >= Context->vcount)
1182 menu->current = ci_first_message ();
1185 /* check for a fatal error, or all messages deleted */
1189 /* if we were in the pager, redisplay the message */
1190 if (menu->menu == MENU_PAGER)
1192 op = OP_DISPLAY_MESSAGE;
1196 menu->redraw = REDRAW_FULL;
1199 case OP_MAIN_CHANGE_FOLDER:
1200 case OP_MAIN_CHANGE_FOLDER_READONLY:
1202 case OP_MAIN_CHANGE_GROUP:
1203 case OP_MAIN_CHANGE_GROUP_READONLY:
1206 if (attach_msg || option (OPTREADONLY) ||
1208 op == OP_MAIN_CHANGE_GROUP_READONLY ||
1210 op == OP_MAIN_CHANGE_FOLDER_READONLY)
1216 cp = _("Open mailbox in read-only mode");
1218 cp = _("Open mailbox");
1222 unset_option (OPTNEWS);
1223 if (op == OP_MAIN_CHANGE_GROUP ||
1224 op == OP_MAIN_CHANGE_GROUP_READONLY)
1226 set_option (OPTNEWS);
1227 if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1230 cp = _("Open newsgroup in read-only mode");
1232 cp = _("Open newsgroup");
1237 mutt_buffy (buf, sizeof (buf));
1239 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
1243 CLEARLINE (LINES-1);
1248 if (option (OPTNEWS))
1250 unset_option (OPTNEWS);
1251 nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
1255 mutt_expand_path (buf, sizeof (buf));
1256 if (mx_get_magic (buf) <= 0)
1258 mutt_error (_("%s is not a mailbox."), buf);
1266 mutt_str_replace (&LastFolder, Context->path);
1267 oldcount = Context ? Context->msgcount : 0;
1269 if ((check = mx_close_mailbox (Context, &index_hint)) != 0)
1271 if (check == M_NEW_MAIL || check == M_REOPENED)
1272 update_index (menu, Context, check, oldcount, index_hint);
1274 set_option (OPTSEARCHINVALID);
1275 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1283 /* Set CurrentMenu to MENU_MAIN before executing any folder
1284 * hooks so that all the index menu functions are available to
1288 CurrentMenu = MENU_MAIN;
1289 mutt_folder_hook (buf);
1291 if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
1293 menu->current = ci_first_message ();
1299 /* mutt_buffy_check() must be done with mail-reader mode! */
1300 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1301 (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp);
1303 mutt_clear_error ();
1304 mutt_buffy_check(1); /* force the buffy check after we have changed
1306 menu->redraw = REDRAW_FULL;
1307 set_option (OPTSEARCHINVALID);
1310 case OP_DISPLAY_MESSAGE:
1311 case OP_DISPLAY_HEADERS: /* don't weed the headers */
1316 * toggle the weeding of headers so that a user can press the key
1317 * again while reading the message.
1319 if (op == OP_DISPLAY_HEADERS)
1320 toggle_option (OPTWEED);
1322 unset_option (OPTNEEDRESORT);
1324 if ((Sort & SORT_MASK) == SORT_THREADS && CURHDR->collapsed)
1326 mutt_uncollapse_thread (Context, CURHDR);
1327 mutt_set_virtual (Context);
1328 if (option (OPTUNCOLLAPSEJUMP))
1329 menu->current = mutt_thread_next_unread (Context, CURHDR);
1332 if ((op = mutt_display_message (CURHDR)) == -1)
1334 unset_option (OPTNEEDRESORT);
1338 menu->menu = MENU_PAGER;
1339 menu->oldcurrent = menu->current;
1345 if (menu->menu == MENU_MAIN && attach_msg)
1351 if ((menu->menu == MENU_MAIN)
1352 && (query_quadoption (OPT_QUIT,
1353 _("Exit Mutt without saving?")) == M_YES))
1357 mx_fastclose_mailbox (Context);
1369 mutt_edit_content_type (CURHDR, CURHDR->content, NULL);
1370 /* if we were in the pager, redisplay the message */
1371 if (menu->menu == MENU_PAGER)
1373 op = OP_DISPLAY_MESSAGE;
1377 menu->redraw = REDRAW_CURRENT;
1380 case OP_MAIN_NEXT_UNDELETED:
1384 if (menu->current >= Context->vcount - 1)
1386 if (menu->menu == MENU_MAIN)
1387 mutt_error _("You are on the last message.");
1390 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1392 menu->current = menu->oldcurrent;
1393 if (menu->menu == MENU_MAIN)
1394 mutt_error _("No undeleted messages.");
1396 else if (menu->menu == MENU_PAGER)
1398 op = OP_DISPLAY_MESSAGE;
1402 menu->redraw = REDRAW_MOTION;
1409 if (menu->current >= Context->vcount - 1)
1411 if (menu->menu == MENU_MAIN)
1412 mutt_error _("You are on the last message.");
1416 if (menu->menu == MENU_PAGER)
1418 op = OP_DISPLAY_MESSAGE;
1422 menu->redraw = REDRAW_MOTION;
1425 case OP_MAIN_PREV_UNDELETED:
1429 if (menu->current < 1)
1431 mutt_error _("You are on the first message.");
1434 if ((menu->current = ci_previous_undeleted (menu->current)) == -1)
1436 menu->current = menu->oldcurrent;
1437 if (menu->menu == MENU_MAIN)
1438 mutt_error _("No undeleted messages.");
1440 else if (menu->menu == MENU_PAGER)
1442 op = OP_DISPLAY_MESSAGE;
1446 menu->redraw = REDRAW_MOTION;
1453 if (menu->current < 1)
1455 if (menu->menu == MENU_MAIN) mutt_error _("You are on the first message.");
1459 if (menu->menu == MENU_PAGER)
1461 op = OP_DISPLAY_MESSAGE;
1465 menu->redraw = REDRAW_MOTION;
1468 case OP_DECRYPT_COPY:
1469 case OP_DECRYPT_SAVE:
1473 case OP_COPY_MESSAGE:
1475 case OP_DECODE_COPY:
1476 case OP_DECODE_SAVE:
1479 if (mutt_save_message (tag ? NULL : CURHDR,
1480 (op == OP_DECRYPT_SAVE) ||
1481 (op == OP_SAVE) || (op == OP_DECODE_SAVE),
1482 (op == OP_DECODE_SAVE) || (op == OP_DECODE_COPY),
1483 (op == OP_DECRYPT_SAVE) || (op == OP_DECRYPT_COPY) ||
1485 &menu->redraw) == 0 &&
1486 (op == OP_SAVE || op == OP_DECODE_SAVE || op == OP_DECRYPT_SAVE)
1490 menu->redraw |= REDRAW_INDEX;
1491 else if (option (OPTRESOLVE))
1493 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1495 menu->current = menu->oldcurrent;
1496 menu->redraw |= REDRAW_CURRENT;
1499 menu->redraw |= REDRAW_MOTION_RESYNCH;
1502 menu->redraw |= REDRAW_CURRENT;
1506 case OP_MAIN_NEXT_NEW:
1507 case OP_MAIN_NEXT_UNREAD:
1508 case OP_MAIN_PREV_NEW:
1509 case OP_MAIN_PREV_UNREAD:
1510 case OP_MAIN_NEXT_NEW_THEN_UNREAD:
1511 case OP_MAIN_PREV_NEW_THEN_UNREAD:
1514 int first_unread = -1;
1522 for (j = 0; j != Context->vcount; j++)
1524 #define CURHDRi Context->hdrs[Context->v2r[i]]
1525 if (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_NEXT_NEW_THEN_UNREAD)
1528 if (i > Context->vcount - 1)
1530 mutt_message _("Search wrapped to top.");
1539 mutt_message _("Search wrapped to bottom.");
1540 i = Context->vcount - 1;
1544 if (CURHDRi->collapsed && (Sort & SORT_MASK) == SORT_THREADS)
1546 if (UNREAD (CURHDRi) && first_unread == -1)
1548 if (UNREAD (CURHDRi) == 1 && first_new == -1)
1551 else if ((!CURHDRi->deleted && !CURHDRi->read))
1553 if (first_unread == -1)
1555 if ((!CURHDRi->old) && first_new == -1)
1559 if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD) &&
1562 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1563 op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1568 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1569 op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1571 menu->current = first_new;
1572 else if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD ||
1573 op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1574 && first_unread != -1)
1575 menu->current = first_unread;
1577 if (menu->current == -1)
1579 menu->current = menu->oldcurrent;
1580 mutt_error ("%s%s.", (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW) ? _("No new messages") : _("No unread messages"),
1581 Context->pattern ? _(" in this limited view") : "");
1583 else if (menu->menu == MENU_PAGER)
1585 op = OP_DISPLAY_MESSAGE;
1589 menu->redraw = REDRAW_MOTION;
1592 case OP_FLAG_MESSAGE:
1599 if (Context->magic == M_POP)
1602 mutt_error _("Can't change 'important' flag on POP server.");
1608 CHECK_IMAP_ACL(IMAP_ACL_WRITE);
1612 if (Context->magic == M_NNTP)
1615 mutt_error _("Can't change 'important' flag on NNTP server.");
1622 for (j = 0; j < Context->vcount; j++)
1624 if (Context->hdrs[Context->v2r[j]]->tagged)
1625 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]],
1626 M_FLAG, !Context->hdrs[Context->v2r[j]]->flagged);
1629 menu->redraw |= REDRAW_INDEX;
1633 mutt_set_flag (Context, CURHDR, M_FLAG, !CURHDR->flagged);
1634 if (option (OPTRESOLVE))
1636 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1638 menu->current = menu->oldcurrent;
1639 menu->redraw = REDRAW_CURRENT;
1642 menu->redraw = REDRAW_MOTION_RESYNCH;
1645 menu->redraw = REDRAW_CURRENT;
1647 menu->redraw |= REDRAW_STATUS;
1657 CHECK_IMAP_ACL(IMAP_ACL_SEEN);
1662 for (j = 0; j < Context->vcount; j++)
1664 if (Context->hdrs[Context->v2r[j]]->tagged)
1666 if (Context->hdrs[Context->v2r[j]]->read ||
1667 Context->hdrs[Context->v2r[j]]->old)
1668 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_NEW, 1);
1670 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_READ, 1);
1673 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
1677 if (CURHDR->read || CURHDR->old)
1678 mutt_set_flag (Context, CURHDR, M_NEW, 1);
1680 mutt_set_flag (Context, CURHDR, M_READ, 1);
1682 if (option (OPTRESOLVE))
1684 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1686 menu->current = menu->oldcurrent;
1687 menu->redraw = REDRAW_CURRENT;
1690 menu->redraw = REDRAW_MOTION_RESYNCH;
1693 menu->redraw = REDRAW_CURRENT;
1694 menu->redraw |= REDRAW_STATUS;
1698 case OP_TOGGLE_WRITE:
1701 if (mx_toggle_write (Context) == 0)
1702 menu->redraw |= REDRAW_STATUS;
1705 case OP_MAIN_NEXT_THREAD:
1706 case OP_MAIN_NEXT_SUBTHREAD:
1707 case OP_MAIN_PREV_THREAD:
1708 case OP_MAIN_PREV_SUBTHREAD:
1714 case OP_MAIN_NEXT_THREAD:
1715 menu->current = mutt_next_thread (CURHDR);
1718 case OP_MAIN_NEXT_SUBTHREAD:
1719 menu->current = mutt_next_subthread (CURHDR);
1722 case OP_MAIN_PREV_THREAD:
1723 menu->current = mutt_previous_thread (CURHDR);
1726 case OP_MAIN_PREV_SUBTHREAD:
1727 menu->current = mutt_previous_subthread (CURHDR);
1731 if (menu->current < 0)
1733 menu->current = menu->oldcurrent;
1734 if (op == OP_MAIN_NEXT_THREAD || op == OP_MAIN_NEXT_SUBTHREAD)
1735 mutt_error _("No more threads.");
1737 mutt_error _("You are on the first thread.");
1739 else if (menu->menu == MENU_PAGER)
1741 op = OP_DISPLAY_MESSAGE;
1745 menu->redraw = REDRAW_MOTION;
1748 case OP_MAIN_PARENT_MESSAGE:
1753 if ((menu->current = mutt_parent_message (Context, CURHDR)) < 0)
1755 menu->current = menu->oldcurrent;
1757 else if (menu->menu == MENU_PAGER)
1759 op = OP_DISPLAY_MESSAGE;
1763 menu->redraw = REDRAW_MOTION;
1766 case OP_MAIN_SET_FLAG:
1767 case OP_MAIN_CLEAR_FLAG:
1774 CHECK_IMAP_ACL(IMAP_ACL_WRITE);
1777 if (mutt_change_flag (tag ? NULL : CURHDR, (op == OP_MAIN_SET_FLAG)) == 0)
1779 menu->redraw = REDRAW_STATUS;
1781 menu->redraw |= REDRAW_INDEX;
1782 else if (option (OPTRESOLVE))
1784 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1786 menu->current = menu->oldcurrent;
1787 menu->redraw |= REDRAW_CURRENT;
1790 menu->redraw |= REDRAW_MOTION_RESYNCH;
1793 menu->redraw |= REDRAW_CURRENT;
1797 case OP_MAIN_COLLAPSE_THREAD:
1801 if ((Sort & SORT_MASK) != SORT_THREADS)
1803 mutt_error _("Threading is not enabled.");
1807 if (CURHDR->collapsed)
1809 menu->current = mutt_uncollapse_thread (Context, CURHDR);
1810 mutt_set_virtual (Context);
1811 if (option (OPTUNCOLLAPSEJUMP))
1812 menu->current = mutt_thread_next_unread (Context, CURHDR);
1814 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR))
1816 menu->current = mutt_collapse_thread (Context, CURHDR);
1817 mutt_set_virtual (Context);
1821 mutt_error _("Thread contains unread messages.");
1825 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1829 case OP_MAIN_COLLAPSE_ALL:
1833 if ((Sort & SORT_MASK) != SORT_THREADS)
1835 mutt_error _("Threading is not enabled.");
1841 THREAD *thread, *top;
1844 if (CURHDR->collapsed)
1845 final = mutt_uncollapse_thread (Context, CURHDR);
1846 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR))
1847 final = mutt_collapse_thread (Context, CURHDR);
1849 final = CURHDR->virtual;
1851 base = Context->hdrs[Context->v2r[final]];
1853 top = Context->tree;
1854 Context->collapsed = !Context->collapsed;
1855 while ((thread = top) != NULL)
1857 while (!thread->message)
1858 thread = thread->child;
1859 h = thread->message;
1861 if (h->collapsed != Context->collapsed)
1864 mutt_uncollapse_thread (Context, h);
1865 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (h))
1866 mutt_collapse_thread (Context, h);
1871 mutt_set_virtual (Context);
1872 for (j = 0; j < Context->vcount; j++)
1874 if (Context->hdrs[Context->v2r[j]]->index == base->index)
1881 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1885 /* --------------------------------------------------------------------
1886 * These functions are invoked directly from the internal-pager
1889 case OP_BOUNCE_MESSAGE:
1894 ci_bounce_message (tag ? NULL : CURHDR, &menu->redraw);
1897 case OP_CREATE_ALIAS:
1899 mutt_create_alias (Context && Context->vcount ? CURHDR->env : NULL, NULL);
1900 MAYBE_REDRAW (menu->redraw);
1901 menu->redraw |= REDRAW_CURRENT;
1906 mutt_query_menu (NULL, 0);
1907 MAYBE_REDRAW (menu->redraw);
1910 case OP_PURGE_MESSAGE:
1918 CHECK_IMAP_ACL(IMAP_ACL_DELETE);
1923 mutt_tag_set_flag (M_DELETE, 1);
1924 mutt_tag_set_flag (M_PURGED, (op != OP_PURGE_MESSAGE) ? 0 : 1);
1925 if (option (OPTDELETEUNTAG))
1926 mutt_tag_set_flag (M_TAG, 0);
1927 menu->redraw = REDRAW_INDEX;
1931 mutt_set_flag (Context, CURHDR, M_DELETE, 1);
1932 mutt_set_flag (Context, CURHDR, M_PURGED,
1933 (op != OP_PURGE_MESSAGE) ? 0 : 1);
1934 if (option (OPTDELETEUNTAG))
1935 mutt_set_flag (Context, CURHDR, M_TAG, 0);
1936 if (option (OPTRESOLVE))
1938 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1940 menu->current = menu->oldcurrent;
1941 menu->redraw = REDRAW_CURRENT;
1943 else if (menu->menu == MENU_PAGER)
1945 op = OP_DISPLAY_MESSAGE;
1949 menu->redraw |= REDRAW_MOTION_RESYNCH;
1952 menu->redraw = REDRAW_CURRENT;
1954 menu->redraw |= REDRAW_STATUS;
1957 case OP_DELETE_THREAD:
1958 case OP_DELETE_SUBTHREAD:
1965 CHECK_IMAP_ACL(IMAP_ACL_DELETE);
1968 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 1,
1969 op == OP_DELETE_THREAD ? 0 : 1);
1973 if (option (OPTDELETEUNTAG))
1974 mutt_thread_set_flag (CURHDR, M_TAG, 0,
1975 op == OP_DELETE_THREAD ? 0 : 1);
1976 if (option (OPTRESOLVE))
1977 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1978 menu->current = menu->oldcurrent;
1979 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1985 if (Context && Context->magic == M_NNTP)
1987 if (mutt_newsgroup_catchup (CurrentNewsSrv,
1988 ((NNTP_DATA *)Context->data)->group))
1989 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1994 case OP_DISPLAY_ADDRESS:
1998 mutt_display_address (CURHDR->env);
2001 case OP_ENTER_COMMAND:
2003 CurrentMenu = MENU_MAIN;
2004 mutt_enter_command ();
2005 mutt_check_rescore (Context);
2006 if (option (OPTFORCEREDRAWINDEX))
2007 menu->redraw = REDRAW_FULL;
2008 unset_option (OPTFORCEREDRAWINDEX);
2009 unset_option (OPTFORCEREDRAWPAGER);
2012 case OP_EDIT_MESSAGE:
2020 if (Context->magic == M_POP)
2023 mutt_error _("Can't edit message on POP server.");
2029 CHECK_IMAP_ACL(IMAP_ACL_INSERT);
2033 if (Context->magic == M_NNTP)
2036 mutt_error _("Can't edit message on newsserver.");
2041 mutt_edit_message (Context, tag ? NULL : CURHDR);
2042 menu->redraw = REDRAW_FULL;
2046 case OP_FORWARD_MESSAGE:
2051 ci_send_message (SENDFORWARD, NULL, NULL, Context, tag ? NULL : CURHDR);
2052 menu->redraw = REDRAW_FULL;
2056 case OP_FORGET_PASSPHRASE:
2057 crypt_forget_passphrase ();
2060 case OP_GROUP_REPLY:
2065 ci_send_message (SENDREPLY|SENDGROUPREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
2066 menu->redraw = REDRAW_FULL;
2074 ci_send_message (SENDREPLY|SENDLISTREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
2075 menu->redraw = REDRAW_FULL;
2081 ci_send_message (0, NULL, NULL, Context, NULL);
2082 menu->redraw = REDRAW_FULL;
2086 if (!(WithCrypto & APPLICATION_PGP))
2089 ci_send_message (SENDKEY, NULL, NULL, NULL, NULL);
2090 menu->redraw = REDRAW_FULL;
2094 case OP_EXTRACT_KEYS:
2099 crypt_extract_keys_from_messages(tag ? NULL : CURHDR);
2100 menu->redraw = REDRAW_FULL;
2104 case OP_CHECK_TRADITIONAL:
2105 if (!(WithCrypto & APPLICATION_PGP))
2109 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
2110 if (menu->menu == MENU_PAGER)
2112 op = OP_DISPLAY_MESSAGE;
2121 mutt_pipe_message (tag ? NULL : CURHDR);
2122 MAYBE_REDRAW (menu->redraw);
2129 mutt_print_message (tag ? NULL : CURHDR);
2132 case OP_MAIN_READ_THREAD:
2133 case OP_MAIN_READ_SUBTHREAD:
2140 CHECK_IMAP_ACL(IMAP_ACL_SEEN);
2143 rc = mutt_thread_set_flag (CURHDR, M_READ, 1,
2144 op == OP_MAIN_READ_THREAD ? 0 : 1);
2148 if (option (OPTRESOLVE))
2150 if ((menu->current = (op == OP_MAIN_READ_THREAD ?
2151 mutt_next_thread (CURHDR) : mutt_next_subthread (CURHDR))) == -1)
2152 menu->current = menu->oldcurrent;
2154 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2158 case OP_RECALL_MESSAGE:
2161 ci_send_message (SENDPOSTPONED, NULL, NULL, Context, NULL);
2162 menu->redraw = REDRAW_FULL;
2173 for (j = 0; j < Context->vcount; j++)
2175 if (Context->hdrs[Context->v2r[j]]->tagged)
2176 mutt_resend_message (NULL, Context, Context->hdrs[Context->v2r[j]]);
2180 mutt_resend_message (NULL, Context, CURHDR);
2182 menu->redraw = REDRAW_FULL;
2188 case OP_FORWARD_TO_GROUP:
2191 if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2192 mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
2193 query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
2195 if (Context && Context->magic == M_NNTP &&
2196 !((NNTP_DATA *)Context->data)->allowed &&
2197 query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
2200 ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2204 if (op == OP_FOLLOWUP)
2205 ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context,
2206 tag ? NULL : CURHDR);
2208 ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context,
2209 tag ? NULL : CURHDR);
2211 menu->redraw = REDRAW_FULL;
2221 ci_send_message (SENDREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
2222 menu->redraw = REDRAW_FULL;
2225 case OP_SHELL_ESCAPE:
2227 mutt_shell_escape ();
2228 MAYBE_REDRAW (menu->redraw);
2232 case OP_TAG_SUBTHREAD:
2236 rc = mutt_thread_set_flag (CURHDR, M_TAG, !CURHDR->tagged,
2237 op == OP_TAG_THREAD ? 0 : 1);
2241 if (option (OPTRESOLVE))
2243 menu->current = mutt_next_thread (CURHDR);
2245 if (menu->current == -1)
2246 menu->current = menu->oldcurrent;
2248 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2259 CHECK_IMAP_ACL(IMAP_ACL_DELETE);
2264 mutt_tag_set_flag (M_DELETE, 0);
2265 mutt_tag_set_flag (M_PURGED, 0);
2266 menu->redraw = REDRAW_INDEX;
2270 mutt_set_flag (Context, CURHDR, M_DELETE, 0);
2271 mutt_set_flag (Context, CURHDR, M_PURGED, 0);
2272 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
2275 menu->redraw = REDRAW_MOTION_RESYNCH;
2278 menu->redraw = REDRAW_CURRENT;
2280 menu->redraw |= REDRAW_STATUS;
2283 case OP_UNDELETE_THREAD:
2284 case OP_UNDELETE_SUBTHREAD:
2291 CHECK_IMAP_ACL(IMAP_ACL_DELETE);
2294 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2295 op == OP_UNDELETE_THREAD ? 0 : 1)
2296 + mutt_thread_set_flag (CURHDR, M_PURGED, 0,
2297 op == OP_UNDELETE_THREAD ? 0 : 1);
2301 if (option (OPTRESOLVE))
2303 if (op == OP_UNDELETE_THREAD)
2304 menu->current = mutt_next_thread (CURHDR);
2306 menu->current = mutt_next_subthread (CURHDR);
2308 if (menu->current == -1)
2309 menu->current = menu->oldcurrent;
2311 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2323 case OP_VIEW_ATTACHMENTS:
2326 mutt_view_attachments (CURHDR);
2327 if (CURHDR->attach_del)
2328 Context->changed = 1;
2329 menu->redraw = REDRAW_FULL;
2340 if (menu->menu == MENU_MAIN)
2341 km_error_key (MENU_MAIN);
2344 if (menu->menu == MENU_PAGER)
2346 menu->menu = MENU_MAIN;
2347 menu->redraw = REDRAW_FULL;
2349 set_option (OPTWEED); /* turn header weeding back on. */
2357 /* Close all open IMAP connections */
2362 /* Close all open NNTP connections */
2367 mutt_menuDestroy (&menu);
2371 void mutt_set_header_color (CONTEXT *ctx, HEADER *curhdr)
2378 for (color = ColorIndexList; color; color = color->next)
2379 if (mutt_pattern_exec (color->color_pattern, M_MATCH_FULL_ADDRESS, ctx, curhdr))
2381 curhdr->pair = color->pair;
2384 curhdr->pair = ColorDefs[MT_COLOR_NORMAL];