2 * Copyright notice from original mutt:
3 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
5 * Parts were written/modified by:
6 * Nico Golde <nico@ngolde.de>
8 * This file is part of mutt-ng, see http://www.muttng.org/.
9 * It's licensed under the GNU General Public License,
10 * please see the file GPL in the top level source directory.
13 #include <lib-ui/lib-ui.h>
15 #include <lib-ui/sidebar.h>
16 #include <lib-mx/mx.h>
26 #include "recvattach.h"
31 #include <imap/imap_private.h>
37 static const char *No_mailbox_is_open = N_("No mailbox is open.");
38 static const char *There_are_no_messages = N_("There are no messages.");
39 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
40 static const char *Function_not_permitted_in_attach_message_mode =
41 N_("Function not permitted in attach-message mode.");
42 static const char *No_visible = N_("No visible messages.");
44 #define CHECK_IN_MAILBOX if (!Context) \
47 mutt_error (_(No_mailbox_is_open)); \
51 #define CHECK_MSGCOUNT if (!Context) \
54 mutt_error(_(No_mailbox_is_open)); \
57 else if (!Context->msgcount) \
60 mutt_error(_(There_are_no_messages)); \
64 #define CHECK_VISIBLE if (Context && menu->current >= Context->vcount) \
67 mutt_error(_(No_visible)); \
72 #define CHECK_READONLY if (Context->readonly) \
75 mutt_error(_(Mailbox_is_read_only)); \
79 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
82 mutt_error(_(Function_not_permitted_in_attach_message_mode)); \
86 #define CURHDR Context->hdrs[Context->v2r[menu->current]]
87 #define OLDHDR Context->hdrs[Context->v2r[menu->oldcurrent]]
88 #define UNREAD(h) mutt_thread_contains_unread (Context, h)
89 #define SW (option(OPTMBOXPANE)?SidebarWidth:0)
91 extern size_t UngetCount;
93 void index_make_entry (char *s, ssize_t l, struct menu_t * menu, int num)
95 format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_INDEX;
96 int edgemsgno, reverse = Sort & SORT_REVERSE;
97 HEADER *h = Context->hdrs[Context->v2r[num]];
100 if ((Sort & SORT_MASK) == SORT_THREADS && h->tree) {
101 flag |= M_FORMAT_TREE; /* display the thread tree */
102 if (h->display_subject)
103 flag |= M_FORMAT_FORCESUBJ;
106 if (menu->top + menu->pagelen > menu->max)
107 edgemsgno = Context->v2r[menu->max - 1];
109 edgemsgno = Context->v2r[menu->top + menu->pagelen - 1];
112 edgemsgno = Context->v2r[menu->top];
114 for (tmp = h->thread->parent; tmp; tmp = tmp->parent) {
118 /* if no ancestor is visible on current screen, provisionally force
120 if (reverse ? tmp->message->msgno > edgemsgno : tmp->message->msgno <
122 flag |= M_FORMAT_FORCESUBJ;
125 else if (tmp->message->virtual >= 0)
128 if (flag & M_FORMAT_FORCESUBJ) {
129 for (tmp = h->thread->prev; tmp; tmp = tmp->prev) {
133 /* ...but if a previous sibling is available, don't force it */
134 if (reverse ? tmp->message->msgno >
135 edgemsgno : tmp->message->msgno < edgemsgno)
137 else if (tmp->message->virtual >= 0) {
138 flag &= ~M_FORMAT_FORCESUBJ;
146 _mutt_make_string (s, l, NONULL (HdrFmt), Context, h, flag);
149 int index_color (int index_no)
151 HEADER *h = Context->hdrs[Context->v2r[index_no]];
156 mutt_set_header_color (Context, h);
160 static int ci_next_undeleted (int msgno)
164 for (i = msgno + 1; i < Context->vcount; i++)
165 if (!Context->hdrs[Context->v2r[i]]->deleted)
170 static int ci_previous_undeleted (int msgno)
174 for (i = msgno - 1; i >= 0; i--)
175 if (!Context->hdrs[Context->v2r[i]]->deleted)
180 /* Return the index of the first new message, or failing that, the first
183 static int ci_first_message (void)
187 if (Context && Context->msgcount) {
188 for (i = 0; i < Context->vcount; i++) {
189 if (!Context->hdrs[Context->v2r[i]]->read &&
190 !Context->hdrs[Context->v2r[i]]->deleted) {
191 if (!Context->hdrs[Context->v2r[i]]->old)
200 /* If Sort is reverse and not threaded, the latest message is first.
201 * If Sort is threaded, the latest message is first iff exactly one
202 * of Sort and SortAux are reverse.
204 if (((Sort & SORT_REVERSE) && (Sort & SORT_MASK) != SORT_THREADS) ||
205 ((Sort & SORT_MASK) == SORT_THREADS &&
206 ((Sort ^ SortAux) & SORT_REVERSE)))
209 return (Context->vcount ? Context->vcount - 1 : 0);
214 /* This should be in mx.c, but it only gets used here. */
215 static int mx_toggle_write (CONTEXT * ctx)
221 mutt_error (_("Cannot toggle write on a readonly mailbox!"));
226 if (ctx->dontwrite) {
228 mutt_message (_("Changes to folder will be written on folder exit."));
232 mutt_message (_("Changes to folder will not be written."));
238 static void update_index (MUTTMENU * menu, CONTEXT * ctx __attribute__ ((unused)), int check,
239 int oldcount, int index_hint)
241 /* store pointers to the newly added messages */
242 HEADER **save_new = NULL;
245 /* take note of the current message */
247 if (menu->current < Context->vcount)
248 menu->oldcurrent = index_hint;
250 oldcount = 0; /* invalid message number! */
253 /* We are in a limited view. Check if the new message(s) satisfy
254 * the limit criteria. If they do, set their virtual msgno so that
255 * they will be visible in the limited view */
256 if (Context->pattern) {
257 #define THIS_BODY Context->hdrs[j]->content
258 for (j = (check == M_REOPENED) ? 0 : oldcount; j < Context->msgcount; j++) {
259 if (mutt_pattern_exec
260 (Context->limit_pattern, M_MATCH_FULL_ADDRESS, Context,
262 Context->hdrs[j]->virtual = Context->vcount;
263 Context->v2r[Context->vcount] = j;
264 Context->hdrs[j]->limited = 1;
267 THIS_BODY->length + THIS_BODY->offset - THIS_BODY->hdr_offset;
273 /* save the list of new messages */
274 if (oldcount && check != M_REOPENED && ((Sort & SORT_MASK) == SORT_THREADS)) {
275 save_new = p_new(HEADER*, Context->msgcount - oldcount);
276 for (j = oldcount; j < Context->msgcount; j++)
277 save_new[j - oldcount] = Context->hdrs[j];
280 /* if the mailbox was reopened, need to rethread from scratch */
281 mutt_sort_headers (Context, (check == M_REOPENED));
283 /* uncollapse threads with new mail */
284 if ((Sort & SORT_MASK) == SORT_THREADS) {
285 if (check == M_REOPENED) {
288 Context->collapsed = 0;
290 for (h = Context->tree; h; h = h->next) {
291 for (c = h; !c->message; c = c->child);
292 mutt_uncollapse_thread (Context, c->message);
294 mutt_set_virtual (Context);
297 for (j = 0; j < Context->msgcount - oldcount; j++) {
300 for (k = 0; k < Context->msgcount; k++) {
301 HEADER *h = Context->hdrs[k];
303 if (h == save_new[j] && (!Context->pattern || h->limited))
304 mutt_uncollapse_thread (Context, h);
308 mutt_set_virtual (Context);
314 /* restore the current message to the message it was pointing to */
315 for (j = 0; j < Context->vcount; j++) {
316 if (Context->hdrs[Context->v2r[j]]->index == menu->oldcurrent) {
323 if (menu->current < 0)
324 menu->current = ci_first_message ();
327 static void resort_index (MUTTMENU * menu)
330 HEADER *current = CURHDR;
333 mutt_sort_headers (Context, 0);
334 /* Restore the current message */
336 for (i = 0; i < Context->vcount; i++) {
337 if (Context->hdrs[Context->v2r[i]] == current) {
343 if ((Sort & SORT_MASK) == SORT_THREADS && menu->current < 0)
344 menu->current = mutt_parent_message (Context, current);
346 if (menu->current < 0)
347 menu->current = ci_first_message ();
349 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
352 /* This function handles the message index window as well as commands returned
353 * from the pager (MENU_PAGER).
355 int mutt_index_menu (void)
357 char buf[LONG_STRING];
360 int done = 0; /* controls when to exit the "event" loop */
362 int tag = 0; /* has the tag-prefix command been pressed? */
367 const char *cp; /* temporary variable. */
368 int index_hint; /* used to restore cursor position */
369 int do_buffy_notify = 1;
370 int closed = 0; /* did we OP_QUIT or OP_EXIT out of this menu? */
371 int attach_msg = option (OPTATTACHMSG);
373 menu = mutt_new_menu ();
374 menu->menu = MENU_MAIN;
376 menu->pagelen = LINES - 3;
377 menu->make_entry = (void *) index_make_entry;
378 menu->color = index_color;
379 menu->current = ci_first_message ();
382 buffy_check (0); /* force the buffy check after we enter the folder */
383 /* record folder we open to place sidebar indicator properly */
384 if (Context && Context->path)
385 sidebar_set_current (Context->path);
389 tag = 0; /* clear the tag-prefix */
391 menu->max = Context ? Context->vcount : 0;
392 oldcount = Context ? Context->msgcount : 0;
394 /* check if we need to resort the index because just about
395 * any 'op' below could do mutt_enter_command(), either here or
396 * from any new menu launched, and change $sort/$sort_aux
398 if (option (OPTNEEDRESORT) && Context && Context->msgcount)
401 if (option (OPTREDRAWTREE) && Context && Context->msgcount
402 && (Sort & SORT_MASK) == SORT_THREADS) {
403 mutt_draw_tree (Context);
404 menu->redraw |= REDRAW_STATUS;
405 unset_option (OPTREDRAWTREE);
408 if (Context && !attach_msg) {
411 /* check for new mail in the mailbox. If nonzero, then something has
412 * changed about the file (either we got new mail or the file was
413 * modified underneath us.)
416 imap_allow_reopen (Context);
418 index_hint = (Context->vcount && menu->current >= 0
419 && menu->current < Context->vcount) ? CURHDR->index : 0;
421 if ((check = mx_check_mailbox (Context, &index_hint, 0)) < 0) {
422 if (!Context->path) {
423 /* fatal error occurred */
425 menu->redraw = REDRAW_FULL;
427 set_option (OPTSEARCHINVALID);
429 else if (check == M_NEW_MAIL || check == M_REOPENED || check == M_FLAGS) {
430 update_index (menu, Context, check, oldcount, index_hint);
432 /* notify the user of new mail */
433 if (check == M_REOPENED)
435 ("Mailbox was externally modified. Flags may be wrong."));
436 else if (check == M_NEW_MAIL) {
437 /* on new mail: redraw sidebar */
439 mutt_message (_("New mail in this mailbox."));
441 if (mod_core.beep_new)
444 else if (check == M_FLAGS)
445 mutt_message (_("Mailbox was externally modified."));
447 /* avoid the message being overwritten by buffy */
450 menu->redraw = REDRAW_FULL;
451 menu->max = Context->vcount;
453 set_option (OPTSEARCHINVALID);
458 imap_disallow_reopen (Context);
461 /* check for new mail in the incoming folders */
463 if ((newcount = buffy_check (0)) != oldcount) {
464 menu->redraw |= REDRAW_STATUS;
465 menu->redraw |= REDRAW_SIDEBAR;
467 if (do_buffy_notify) {
468 if (buffy_notify () && mod_core.beep_new)
477 if (menu->redraw & REDRAW_SIDEBAR)
479 if (menu->redraw & REDRAW_FULL) {
480 menu_redraw_full (menu);
485 if (menu->menu == MENU_MAIN) {
486 if (Context && Context->hdrs && !(menu->current >= Context->vcount)) {
487 menu_check_recenter (menu);
489 if (menu->redraw & REDRAW_INDEX) {
490 menu_redraw_index (menu);
491 menu->redraw |= REDRAW_STATUS;
493 else if (menu->redraw & (REDRAW_MOTION_RESYNCH | REDRAW_MOTION))
494 menu_redraw_motion (menu);
495 else if (menu->redraw & REDRAW_CURRENT)
496 menu_redraw_current (menu);
499 if (menu->redraw & REDRAW_STATUS) {
500 menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
501 CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES - 2);
502 SETCOLOR (MT_COLOR_STATUS);
503 BKGDSET (MT_COLOR_STATUS);
504 wmove(stdscr, option (OPTSTATUSONTOP) ? 0 : LINES - 2,SW);
505 mutt_paddstr (COLS-SW, buf);
506 SETCOLOR (MT_COLOR_NORMAL);
507 BKGDSET (MT_COLOR_NORMAL);
508 sidebar_set_buffystats (Context);
509 menu->redraw &= ~REDRAW_STATUS;
510 if (option (OPTXTERMSETTITLES)) {
511 menu_status_line(buf, sizeof(buf), menu, NONULL(XtermTitle));
512 printf("\033]2;%s\007", buf);
513 menu_status_line(buf, sizeof(buf), menu, NONULL(XtermIcon));
514 printf("\033]1;%s\007", buf);
520 if (menu->current < menu->max)
521 menu->oldcurrent = menu->current;
523 menu->oldcurrent = -1;
525 if (option (OPTBRAILLEFRIENDLY))
526 wmove (stdscr, menu->current - menu->top + menu->offset, 0);
528 wmove (stdscr, menu->current - menu->top + menu->offset, COLS - 1);
534 menu->redraw = REDRAW_FULL;
535 menu->menu = MENU_MAIN;
536 menu->top = 0; /* so we scroll the right amount */
540 op = km_dokey (MENU_MAIN);
542 continue; /* either user abort or timeout */
546 /* special handling for the tag-prefix function */
547 if (op == OP_TAG_PREFIX) {
549 mutt_error (_("No mailbox is open."));
554 if (!Context->tagged) {
555 mutt_error (_("No tagged messages."));
561 /* give visual indication that the next command is a tag- command */
562 mvwaddstr (stdscr, LINES - 1, 0, "tag-");
565 /* get the real command */
566 if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX) {
567 /* abort tag sequence */
568 CLEARLINE (LINES - 1);
572 else if (option (OPTAUTOTAG) && Context && Context->tagged)
575 if (op == OP_TAG_PREFIX_COND) {
577 mutt_error (_("No mailbox is open."));
582 if (!Context->tagged) {
585 while (UngetCount > 0) {
587 if (tmp.op == OP_END_COND)
590 mutt_message (_("Nothing to do."));
596 /* give visual indication that the next command is a tag- command */
597 mvwaddstr (stdscr, LINES - 1, 0, "tag-");
600 /* get the real command */
601 if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX) {
602 /* abort tag sequence */
603 CLEARLINE (LINES - 1);
611 if (menu->current < menu->max)
612 menu->oldcurrent = menu->current;
614 menu->oldcurrent = -1;
616 mutt_curs_set (1); /* fallback from the pager */
620 unset_option (OPTNEWS); /* for any case */
625 /* ----------------------------------------------------------------------
630 menu_bottom_page (menu);
633 menu_first_entry (menu);
636 menu_middle_page (menu);
642 menu_half_down (menu);
645 menu_next_line (menu);
648 menu_prev_line (menu);
651 menu_next_page (menu);
654 menu_prev_page (menu);
657 menu_last_entry (menu);
660 menu_top_page (menu);
663 menu_current_top (menu);
665 case OP_CURRENT_MIDDLE:
666 menu_current_middle (menu);
668 case OP_CURRENT_BOTTOM:
669 menu_current_bottom (menu);
676 if (Context->magic == M_NNTP) {
679 if (op == OP_GET_MESSAGE) {
681 if (mutt_get_field (_("Enter Message-ID: "), buf, sizeof (buf), 0)
686 string_list_t *ref = CURHDR->env->references;
689 mutt_error (_("Article has no parent reference!"));
693 m_strcpy(buf, sizeof(buf), ref->data);
695 if (!Context->id_hash)
696 Context->id_hash = mutt_make_id_hash (Context);
697 if ((h = hash_find (Context->id_hash, buf))) {
698 if (h->virtual != -1) {
699 menu->current = h->virtual;
700 menu->redraw = REDRAW_MOTION_RESYNCH;
702 else if (h->collapsed) {
703 mutt_uncollapse_thread (Context, h);
704 mutt_set_virtual (Context);
705 menu->current = h->virtual;
706 menu->redraw = REDRAW_MOTION_RESYNCH;
709 mutt_error (_("Message not visible in limited view."));
712 if (nntp_check_msgid (Context, buf) == 0) {
713 h = Context->hdrs[Context->msgcount - 1];
714 mutt_sort_headers (Context, 0);
715 menu->current = h->virtual;
716 menu->redraw = REDRAW_FULL;
719 mutt_error (_("Article %s not found on server"), buf);
724 case OP_GET_CHILDREN:
725 case OP_RECONSTRUCT_THREAD:
727 if (Context->magic == M_NNTP) {
729 int old = CURHDR->index;
731 if (!CURHDR->env->message_id) {
732 mutt_error (_("No Message-ID. Unable to perform operation"));
737 if (!Context->id_hash)
738 Context->id_hash = mutt_make_id_hash (Context);
739 m_strcpy(buf, sizeof(buf), CURHDR->env->message_id);
741 if (op == OP_RECONSTRUCT_THREAD) {
742 string_list_t *ref = CURHDR->env->references;
745 nntp_check_msgid (Context, ref->data);
746 /* the last msgid in References is the root message */
748 m_strcpy(buf, sizeof(buf), ref->data);
752 mutt_message (_("Check for children of message..."));
754 if (nntp_check_children (Context, buf) == 0) {
755 mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
756 h = hash_find (Context->id_hash, buf);
757 /* if the root message was retrieved, move to it */
759 menu->current = h->virtual;
760 else /* try to restore old position */
761 for (i = 0; i < Context->msgcount; i++)
762 if (Context->hdrs[i]->index == old) {
763 menu->current = Context->hdrs[i]->virtual;
764 /* As an added courtesy, recenter the menu
765 * with the current entry at the middle of the screen */
766 menu_check_recenter (menu);
767 menu_current_middle (menu);
770 menu->redraw = REDRAW_FULL;
780 if (isdigit (LastKey))
781 mutt_ungetch (LastKey, 0);
783 if (mutt_get_field (_("Jump to message: "), buf, sizeof (buf), 0) != 0
787 if (!isdigit ((unsigned char) buf[0])) {
788 mutt_error (_("Argument must be a message number."));
794 if (i > 0 && i <= Context->msgcount) {
795 for (j = i - 1; j < Context->msgcount; j++) {
796 if (Context->hdrs[j]->virtual != -1)
799 if (j >= Context->msgcount) {
800 for (j = i - 2; j >= 0; j--) {
801 if (Context->hdrs[j]->virtual != -1)
807 menu->current = Context->hdrs[j]->virtual;
808 if (menu->menu == MENU_PAGER) {
809 op = OP_DISPLAY_MESSAGE;
813 menu->redraw = REDRAW_MOTION;
816 mutt_error (_("That message is not visible."));
819 mutt_error (_("Invalid message number."));
823 /* --------------------------------------------------------------------
824 * `index' specific commands
827 case OP_MAIN_DELETE_PATTERN:
833 CHECK_MX_ACL (Context, ACL_DELETE, _("Deletion"));
836 mutt_pattern_func (M_DELETE, _("Delete messages matching: "));
837 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
840 case OP_MAIN_FETCH_MAIL:
844 menu->redraw = REDRAW_FULL;
849 mutt_help (MENU_MAIN);
850 menu->redraw = REDRAW_FULL;
853 case OP_MAIN_SHOW_LIMIT:
855 if (!Context->pattern)
856 mutt_message (_("No limit pattern is in effect."));
861 /* i18n: ask for a limit to apply */
862 snprintf (buffer, sizeof (buffer), _("Limit: %s"), Context->pattern);
863 mutt_message ("%s", buffer);
871 menu->oldcurrent = (Context->vcount && menu->current >= 0
873 Context->vcount) ? CURHDR->index : -1;
874 if (op == OP_TOGGLE_READ) {
875 char buffer[LONG_STRING];
877 if (m_strncmp (Context->pattern, "!~R!~D~s", 8) != 0) {
878 snprintf (buffer, sizeof (buffer), "!~R!~D~s%s",
879 Context->pattern ? Context->pattern : ".*");
880 set_option (OPTHIDEREAD);
883 m_strcpy(buf, sizeof(buf), Context->pattern + 8);
884 if (m_strncmp (buf, ".*", 2) == 0)
885 snprintf (buf, sizeof (buf), "~A");
886 unset_option (OPTHIDEREAD);
888 p_delete(&Context->pattern);
889 Context->pattern = m_strdup(buf);
891 if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
892 mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
894 if (menu->oldcurrent >= 0) {
895 /* try to find what used to be the current message */
897 for (i = 0; i < Context->vcount; i++)
898 if (Context->hdrs[Context->v2r[i]]->index == menu->oldcurrent) {
902 if (menu->current < 0)
907 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
908 if (Context->msgcount && (Sort & SORT_MASK) == SORT_THREADS)
909 mutt_draw_tree (Context);
910 menu->redraw = REDRAW_FULL;
912 if (Context->pattern)
913 mutt_message _("To view all messages, limit to \"all\".");
924 if (query_quadoption2(mod_core.quit, _("Quit Madmutt?")) == M_YES) {
927 oldcount = Context ? Context->msgcount : 0;
930 || (check = mx_close_mailbox (Context, &index_hint)) == 0)
933 if (check == M_NEW_MAIL || check == M_REOPENED)
934 update_index (menu, Context, check, oldcount, index_hint);
936 menu->redraw = REDRAW_FULL; /* new mail arrived? */
937 set_option (OPTSEARCHINVALID);
944 clearok (stdscr, TRUE);
945 menu->redraw = REDRAW_FULL;
949 case OP_SEARCH_REVERSE:
951 case OP_SEARCH_OPPOSITE:
955 if ((menu->current = mutt_search_command (menu->current, op)) == -1)
956 menu->current = menu->oldcurrent;
958 menu->redraw = REDRAW_MOTION;
962 case OP_SORT_REVERSE:
964 if (mutt_select_sort ((op == OP_SORT_REVERSE)) == 0) {
965 if (Context && Context->msgcount) {
967 set_option (OPTSEARCHINVALID);
976 if (tag && !option (OPTAUTOTAG)) {
977 for (j = 0; j < Context->vcount; j++)
978 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_TAG, 0);
979 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
982 mutt_set_flag (Context, CURHDR, M_TAG, !CURHDR->tagged);
983 Context->last_tag = CURHDR->tagged ? CURHDR :
984 ((Context->last_tag == CURHDR && !CURHDR->tagged)
985 ? NULL : Context->last_tag);
986 menu->redraw = REDRAW_STATUS;
987 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1) {
989 menu->redraw |= REDRAW_MOTION_RESYNCH;
992 menu->redraw |= REDRAW_CURRENT;
996 case OP_MAIN_TAG_PATTERN:
1000 mutt_pattern_func (M_TAG, _("Tag messages matching: "));
1001 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1004 case OP_MAIN_UNDELETE_PATTERN:
1010 CHECK_MX_ACL (Context, ACL_DELETE, _("Undeletion"));
1012 if (mutt_pattern_func (M_UNDELETE, _("Undelete messages matching: ")) ==
1014 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1017 case OP_MAIN_UNTAG_PATTERN:
1021 if (mutt_pattern_func (M_UNTAG, _("Untag messages matching: ")) == 0)
1022 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1025 /* --------------------------------------------------------------------
1026 * The following operations can be performed inside of the pager.
1029 case OP_MAIN_IMAP_FETCH:
1030 if (Context->magic == M_IMAP)
1031 imap_check_mailbox (Context, &index_hint, 1);
1034 case OP_MAIN_SYNC_FOLDER:
1036 if (Context && !Context->msgcount)
1043 int oldvcount = Context->vcount;
1044 oldcount = Context->msgcount;
1048 /* calculate the number of messages _above_ the cursor,
1049 * so we can keep the cursor on the current message
1051 for (j = 0; j <= menu->current; j++) {
1052 if (Context->hdrs[Context->v2r[j]]->deleted)
1056 if ((check = mx_sync_mailbox (Context, &index_hint)) == 0) {
1057 if (Context->vcount != oldvcount)
1058 menu->current -= dcount;
1059 set_option (OPTSEARCHINVALID);
1061 else if (check == M_NEW_MAIL || check == M_REOPENED)
1062 update_index (menu, Context, check, oldcount, index_hint);
1065 * do a sanity check even if mx_sync_mailbox failed.
1068 if (menu->current < 0 || menu->current >= Context->vcount)
1069 menu->current = ci_first_message ();
1072 /* check for a fatal error, or all messages deleted */
1076 /* if we were in the pager, redisplay the message */
1077 if (menu->menu == MENU_PAGER) {
1078 op = OP_DISPLAY_MESSAGE;
1082 menu->redraw = REDRAW_FULL;
1085 case OP_SIDEBAR_OPEN:
1086 case OP_MAIN_CHANGE_FOLDER:
1087 case OP_MAIN_CHANGE_FOLDER_READONLY:
1089 case OP_MAIN_CHANGE_GROUP:
1090 case OP_MAIN_CHANGE_GROUP_READONLY:
1092 if (attach_msg || option (OPTREADONLY) ||
1094 op == OP_MAIN_CHANGE_GROUP_READONLY ||
1096 op == OP_MAIN_CHANGE_FOLDER_READONLY)
1102 cp = _("Open mailbox in read-only mode");
1104 cp = _("Open mailbox");
1108 unset_option (OPTNEWS);
1109 if (op == OP_MAIN_CHANGE_GROUP || op == OP_MAIN_CHANGE_GROUP_READONLY) {
1110 set_option (OPTNEWS);
1111 if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1114 cp = _("Open newsgroup in read-only mode");
1116 cp = _("Open newsgroup");
1117 nntp_buffy (buf, sizeof (buf));
1122 if (Context && Context->path)
1123 m_strcpy(buf, sizeof(buf), Context->path);
1124 if (op != OP_SIDEBAR_OPEN)
1125 buffy_next (buf, sizeof (buf));
1128 if (op == OP_SIDEBAR_OPEN) {
1129 m_strcpy(buf, sizeof(buf), sidebar_get_current());
1131 else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) {
1132 if (menu->menu == MENU_PAGER) {
1133 op = OP_DISPLAY_MESSAGE;
1139 CLEARLINE (LINES - 1);
1144 if (option (OPTNEWS)) {
1145 unset_option (OPTNEWS);
1146 nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
1150 mutt_expand_path (buf, sizeof (buf));
1151 if (mx_get_magic (buf) <= 0) {
1152 mutt_error (_("%s is not a mailbox."), buf);
1155 m_strreplace(&CurrentFolder, buf);
1160 if (Context->cinfo && Context->realpath)
1161 m_strreplace(&LastFolder, Context->realpath);
1163 m_strreplace(&LastFolder, Context->path);
1164 oldcount = Context ? Context->msgcount : 0;
1166 if ((check = mx_close_mailbox (Context, &index_hint)) != 0) {
1167 if (check == M_NEW_MAIL || check == M_REOPENED)
1168 update_index (menu, Context, check, oldcount, index_hint);
1170 set_option (OPTSEARCHINVALID);
1171 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1179 /* Set CurrentMenu to MENU_MAIN before executing any folder
1180 * hooks so that all the index menu functions are available to
1184 CurrentMenu = MENU_MAIN;
1185 mutt_folder_hook (buf);
1187 if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL) {
1188 menu->current = ci_first_message ();
1192 sidebar_set_current (buf);
1194 mutt_clear_error ();
1195 buffy_check (0); /* force the buffy check after we have changed
1197 menu->redraw = REDRAW_FULL;
1198 set_option (OPTSEARCHINVALID);
1201 case OP_DISPLAY_MESSAGE:
1202 case OP_DISPLAY_HEADERS: /* don't weed the headers */
1207 * toggle the weeding of headers so that a user can press the key
1208 * again while reading the message.
1210 if (op == OP_DISPLAY_HEADERS)
1211 toggle_option (OPTWEED);
1213 unset_option (OPTNEEDRESORT);
1215 if ((Sort & SORT_MASK) == SORT_THREADS && CURHDR->collapsed) {
1216 mutt_uncollapse_thread (Context, CURHDR);
1217 mutt_set_virtual (Context);
1218 if (option (OPTUNCOLLAPSEJUMP))
1219 menu->current = mutt_thread_next_unread (Context, CURHDR);
1222 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1223 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1225 if ((op = mutt_display_message (CURHDR)) == -1) {
1226 unset_option (OPTNEEDRESORT);
1230 menu->menu = MENU_PAGER;
1231 menu->oldcurrent = menu->current;
1237 if (menu->menu == MENU_MAIN && attach_msg) {
1242 if ((menu->menu == MENU_MAIN)
1243 && (query_quadoption2(mod_core.quit,
1244 _("Exit Madmutt without saving?")) == M_YES))
1247 mx_fastclose_mailbox (Context);
1259 mutt_edit_content_type (CURHDR, CURHDR->content, NULL);
1260 /* if we were in the pager, redisplay the message */
1261 if (menu->menu == MENU_PAGER) {
1262 op = OP_DISPLAY_MESSAGE;
1266 menu->redraw = REDRAW_CURRENT;
1269 case OP_MAIN_BREAK_THREAD:
1275 if ((Sort & SORT_MASK) != SORT_THREADS)
1276 mutt_error (_("Threading is not enabled."));
1280 HEADER *oldcur = CURHDR;
1282 mutt_break_thread (CURHDR);
1283 mutt_sort_headers (Context, 1);
1284 menu->current = oldcur->virtual;
1287 Context->changed = 1;
1288 mutt_message _("Thread broken");
1290 if (menu->menu == MENU_PAGER) {
1291 op = OP_DISPLAY_MESSAGE;
1295 menu->redraw |= REDRAW_INDEX;
1299 case OP_MAIN_LINK_THREADS:
1305 if ((Sort & SORT_MASK) != SORT_THREADS)
1306 mutt_error (_("Threading is not enabled."));
1308 else if (!CURHDR->env->message_id)
1309 mutt_error (_("No Message-ID: header available to link thread"));
1311 else if (!tag && (!Context->last_tag || !Context->last_tag->tagged))
1312 mutt_error (_("First, please tag a message to be linked here"));
1315 HEADER *oldcur = CURHDR;
1317 if (mutt_link_threads (CURHDR, tag ? NULL : Context->last_tag,
1319 mutt_sort_headers (Context, 1);
1320 menu->current = oldcur->virtual;
1322 Context->changed = 1;
1323 mutt_message _("Threads linked");
1326 mutt_error (_("No thread linked"));
1329 if (menu->menu == MENU_PAGER) {
1330 op = OP_DISPLAY_MESSAGE;
1334 menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
1337 case OP_MAIN_NEXT_UNDELETED:
1341 if (menu->current >= Context->vcount - 1) {
1342 if (menu->menu == MENU_MAIN)
1343 mutt_error (_("You are on the last message."));
1347 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1348 menu->current = menu->oldcurrent;
1349 if (menu->menu == MENU_MAIN)
1350 mutt_error (_("No undeleted messages."));
1352 else if (menu->menu == MENU_PAGER) {
1353 op = OP_DISPLAY_MESSAGE;
1357 menu->redraw = REDRAW_MOTION;
1364 if (menu->current >= Context->vcount - 1) {
1365 if (menu->menu == MENU_MAIN)
1366 mutt_error (_("You are on the last message."));
1371 if (menu->menu == MENU_PAGER) {
1372 op = OP_DISPLAY_MESSAGE;
1376 menu->redraw = REDRAW_MOTION;
1379 case OP_MAIN_PREV_UNDELETED:
1383 if (menu->current < 1) {
1384 mutt_error (_("You are on the first message."));
1388 if ((menu->current = ci_previous_undeleted (menu->current)) == -1) {
1389 menu->current = menu->oldcurrent;
1390 if (menu->menu == MENU_MAIN)
1391 mutt_error (_("No undeleted messages."));
1393 else if (menu->menu == MENU_PAGER) {
1394 op = OP_DISPLAY_MESSAGE;
1398 menu->redraw = REDRAW_MOTION;
1405 if (menu->current < 1) {
1406 if (menu->menu == MENU_MAIN)
1407 mutt_error (_("You are on the first message."));
1412 if (menu->menu == MENU_PAGER) {
1413 op = OP_DISPLAY_MESSAGE;
1417 menu->redraw = REDRAW_MOTION;
1420 case OP_DECRYPT_COPY:
1421 case OP_DECRYPT_SAVE:
1422 case OP_COPY_MESSAGE:
1424 case OP_DECODE_COPY:
1425 case OP_DECODE_SAVE:
1428 if (mutt_save_message (tag ? NULL : CURHDR,
1429 (op == OP_DECRYPT_SAVE) ||
1430 (op == OP_SAVE) || (op == OP_DECODE_SAVE),
1431 (op == OP_DECODE_SAVE) || (op == OP_DECODE_COPY),
1432 (op == OP_DECRYPT_SAVE)
1433 || (op == OP_DECRYPT_COPY)
1434 || 0, &menu->redraw) == 0 && (op == OP_SAVE
1441 menu->redraw |= REDRAW_INDEX;
1442 else if (option (OPTRESOLVE)) {
1443 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1444 menu->current = menu->oldcurrent;
1445 menu->redraw |= REDRAW_CURRENT;
1448 menu->redraw |= REDRAW_MOTION_RESYNCH;
1451 menu->redraw |= REDRAW_CURRENT;
1455 case OP_MAIN_NEXT_NEW:
1456 case OP_MAIN_NEXT_UNREAD:
1457 case OP_MAIN_PREV_NEW:
1458 case OP_MAIN_PREV_UNREAD:
1459 case OP_MAIN_NEXT_NEW_THEN_UNREAD:
1460 case OP_MAIN_PREV_NEW_THEN_UNREAD:
1463 int first_unread = -1;
1471 for (j = 0; j != Context->vcount; j++) {
1472 #define CURHDRi Context->hdrs[Context->v2r[i]]
1473 if (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_NEXT_UNREAD
1474 || op == OP_MAIN_NEXT_NEW_THEN_UNREAD) {
1476 if (i > Context->vcount - 1) {
1477 mutt_message _("Search wrapped to top.");
1485 mutt_message _("Search wrapped to bottom.");
1487 i = Context->vcount - 1;
1491 if (CURHDRi->collapsed && (Sort & SORT_MASK) == SORT_THREADS) {
1492 if (UNREAD (CURHDRi) && first_unread == -1)
1494 if (UNREAD (CURHDRi) == 1 && first_new == -1)
1497 else if ((!CURHDRi->deleted && !CURHDRi->read)) {
1498 if (first_unread == -1)
1500 if ((!CURHDRi->old) && first_new == -1)
1504 if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD) &&
1507 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1508 op == OP_MAIN_NEXT_NEW_THEN_UNREAD
1509 || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1514 if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
1515 op == OP_MAIN_NEXT_NEW_THEN_UNREAD
1516 || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1518 menu->current = first_new;
1519 else if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD ||
1520 op == OP_MAIN_NEXT_NEW_THEN_UNREAD
1521 || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
1522 && first_unread != -1)
1523 menu->current = first_unread;
1525 if (menu->current == -1) {
1526 menu->current = menu->oldcurrent;
1527 mutt_error ("%s%s.",
1528 (op == OP_MAIN_NEXT_NEW
1530 OP_MAIN_PREV_NEW) ? _("No new messages") :
1531 _("No unread messages"),
1532 Context->pattern ? _(" in this limited view") : "");
1534 else if (menu->menu == MENU_PAGER) {
1535 op = OP_DISPLAY_MESSAGE;
1539 menu->redraw = REDRAW_MOTION;
1542 case OP_FLAG_MESSAGE:
1548 CHECK_MX_ACL (Context, ACL_WRITE, _("Flagging"));
1551 for (j = 0; j < Context->vcount; j++) {
1552 if (Context->hdrs[Context->v2r[j]]->tagged)
1553 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]],
1554 M_FLAG, !Context->hdrs[Context->v2r[j]]->flagged);
1557 menu->redraw |= REDRAW_INDEX;
1560 mutt_set_flag (Context, CURHDR, M_FLAG, !CURHDR->flagged);
1561 if (option (OPTRESOLVE)) {
1562 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1563 menu->current = menu->oldcurrent;
1564 menu->redraw = REDRAW_CURRENT;
1567 menu->redraw = REDRAW_MOTION_RESYNCH;
1570 menu->redraw = REDRAW_CURRENT;
1572 menu->redraw |= REDRAW_STATUS;
1581 CHECK_MX_ACL (Context, ACL_SEEN, _("Toggling"));
1584 for (j = 0; j < Context->vcount; j++) {
1585 if (Context->hdrs[Context->v2r[j]]->tagged) {
1586 if (Context->hdrs[Context->v2r[j]]->read ||
1587 Context->hdrs[Context->v2r[j]]->old)
1588 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_NEW,
1591 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_READ,
1595 menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
1598 if (CURHDR->read || CURHDR->old)
1599 mutt_set_flag (Context, CURHDR, M_NEW, 1);
1601 mutt_set_flag (Context, CURHDR, M_READ, 1);
1603 if (option (OPTRESOLVE)) {
1604 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:
1632 case OP_MAIN_NEXT_THREAD:
1633 menu->current = mutt_next_thread (CURHDR);
1636 case OP_MAIN_NEXT_SUBTHREAD:
1637 menu->current = mutt_next_subthread (CURHDR);
1640 case OP_MAIN_PREV_THREAD:
1641 menu->current = mutt_previous_thread (CURHDR);
1644 case OP_MAIN_PREV_SUBTHREAD:
1645 menu->current = mutt_previous_subthread (CURHDR);
1649 if (menu->current < 0) {
1650 menu->current = menu->oldcurrent;
1651 if (op == OP_MAIN_NEXT_THREAD || op == OP_MAIN_NEXT_SUBTHREAD)
1652 mutt_error (_("No more threads."));
1655 mutt_error (_("You are on the first thread."));
1657 else if (menu->menu == MENU_PAGER) {
1658 op = OP_DISPLAY_MESSAGE;
1662 menu->redraw = REDRAW_MOTION;
1665 case OP_MAIN_PARENT_MESSAGE:
1670 if ((menu->current = mutt_parent_message (Context, CURHDR)) < 0) {
1671 menu->current = menu->oldcurrent;
1673 else if (menu->menu == MENU_PAGER) {
1674 op = OP_DISPLAY_MESSAGE;
1678 menu->redraw = REDRAW_MOTION;
1681 case OP_MAIN_SET_FLAG:
1682 case OP_MAIN_CLEAR_FLAG:
1688 if (mutt_change_flag (tag ? NULL : CURHDR, (op == OP_MAIN_SET_FLAG)) == 0) {
1689 menu->redraw = REDRAW_STATUS;
1691 menu->redraw |= REDRAW_INDEX;
1692 else if (option (OPTRESOLVE)) {
1693 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1694 menu->current = menu->oldcurrent;
1695 menu->redraw |= REDRAW_CURRENT;
1698 menu->redraw |= REDRAW_MOTION_RESYNCH;
1701 menu->redraw |= REDRAW_CURRENT;
1705 case OP_MAIN_COLLAPSE_THREAD:
1709 if ((Sort & SORT_MASK) != SORT_THREADS) {
1710 mutt_error (_("Threading is not enabled."));
1715 if (CURHDR->collapsed) {
1716 menu->current = mutt_uncollapse_thread (Context, CURHDR);
1717 mutt_set_virtual (Context);
1718 if (option (OPTUNCOLLAPSEJUMP))
1719 menu->current = mutt_thread_next_unread (Context, CURHDR);
1721 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR)) {
1722 menu->current = mutt_collapse_thread (Context, CURHDR);
1723 mutt_set_virtual (Context);
1726 mutt_error (_("Thread contains unread messages."));
1731 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1735 case OP_MAIN_COLLAPSE_ALL:
1739 if ((Sort & SORT_MASK) != SORT_THREADS) {
1740 mutt_error (_("Threading is not enabled."));
1747 THREAD *thread, *top;
1750 if (CURHDR->collapsed)
1751 final = mutt_uncollapse_thread (Context, CURHDR);
1752 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR))
1753 final = mutt_collapse_thread (Context, CURHDR);
1755 final = CURHDR->virtual;
1757 base = Context->hdrs[Context->v2r[final]];
1759 top = Context->tree;
1760 Context->collapsed = !Context->collapsed;
1761 while ((thread = top) != NULL) {
1762 while (!thread->message)
1763 thread = thread->child;
1764 h = thread->message;
1766 if (h->collapsed != Context->collapsed) {
1768 mutt_uncollapse_thread (Context, h);
1769 else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (h))
1770 mutt_collapse_thread (Context, h);
1775 mutt_set_virtual (Context);
1776 for (j = 0; j < Context->vcount; j++) {
1777 if (Context->hdrs[Context->v2r[j]]->index == base->index) {
1783 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1787 /* --------------------------------------------------------------------
1788 * These functions are invoked directly from the internal-pager
1791 case OP_BOUNCE_MESSAGE:
1796 ci_bounce_message (tag ? NULL : CURHDR, &menu->redraw);
1799 case OP_CREATE_ALIAS:
1801 mutt_create_alias (Context
1802 && Context->vcount ? CURHDR->env : NULL, NULL);
1803 MAYBE_REDRAW (menu->redraw);
1804 menu->redraw |= REDRAW_CURRENT;
1809 mutt_query_menu (NULL, 0);
1810 MAYBE_REDRAW (menu->redraw);
1813 case OP_PURGE_MESSAGE:
1820 CHECK_MX_ACL (Context, ACL_DELETE, _("Deletion"));
1823 mutt_tag_set_flag (M_DELETE, 1);
1824 mutt_tag_set_flag (M_PURGED, (op != OP_PURGE_MESSAGE) ? 0 : 1);
1825 if (option (OPTDELETEUNTAG))
1826 mutt_tag_set_flag (M_TAG, 0);
1827 menu->redraw = REDRAW_INDEX;
1830 mutt_set_flag (Context, CURHDR, M_DELETE, 1);
1831 mutt_set_flag (Context, CURHDR, M_PURGED,
1832 (op != OP_PURGE_MESSAGE) ? 0 : 1);
1833 if (option (OPTDELETEUNTAG))
1834 mutt_set_flag (Context, CURHDR, M_TAG, 0);
1835 if (option (OPTRESOLVE)) {
1836 if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
1837 menu->current = menu->oldcurrent;
1838 menu->redraw = REDRAW_CURRENT;
1840 else if (menu->menu == MENU_PAGER) {
1841 op = OP_DISPLAY_MESSAGE;
1845 menu->redraw |= REDRAW_MOTION_RESYNCH;
1848 menu->redraw = REDRAW_CURRENT;
1850 menu->redraw |= REDRAW_STATUS;
1853 case OP_DELETE_THREAD:
1854 case OP_DELETE_SUBTHREAD:
1860 CHECK_MX_ACL (Context, ACL_DELETE, _("Deletion"));
1862 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 1,
1863 op == OP_DELETE_THREAD ? 0 : 1);
1866 if (option (OPTDELETEUNTAG))
1867 mutt_thread_set_flag (CURHDR, M_TAG, 0,
1868 op == OP_DELETE_THREAD ? 0 : 1);
1869 if (option (OPTRESOLVE))
1870 if ((menu->current = ci_next_undeleted (menu->current)) == -1)
1871 menu->current = menu->oldcurrent;
1872 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1878 if (Context && Context->magic == M_NNTP) {
1879 if (mutt_newsgroup_catchup (CurrentNewsSrv,
1880 ((nntp_data_t *) Context->data)->group))
1881 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1886 case OP_DISPLAY_ADDRESS:
1890 mutt_display_address (CURHDR->env);
1893 case OP_ENTER_COMMAND:
1895 CurrentMenu = MENU_MAIN;
1896 mutt_enter_command ();
1897 mutt_check_rescore (Context);
1898 if (option (OPTFORCEREDRAWINDEX))
1899 menu->redraw = REDRAW_FULL;
1900 unset_option (OPTFORCEREDRAWINDEX);
1901 unset_option (OPTFORCEREDRAWPAGER);
1904 case OP_EDIT_MESSAGE:
1911 CHECK_MX_ACL (Context, ACL_INSERT, _("Editing"));
1913 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1914 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1915 mutt_edit_message (Context, tag ? NULL : CURHDR);
1916 menu->redraw = REDRAW_FULL;
1920 case OP_FORWARD_MESSAGE:
1926 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1927 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1928 ci_send_message (SENDFORWARD, NULL, NULL, Context, tag ? NULL : CURHDR);
1929 menu->redraw = REDRAW_FULL;
1932 case OP_GROUP_REPLY:
1938 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1939 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1941 ci_send_message (SENDREPLY | SENDGROUPREPLY, NULL, NULL, Context,
1942 tag ? NULL : CURHDR);
1943 menu->redraw = REDRAW_FULL;
1952 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1953 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1955 ci_send_message (SENDREPLY | SENDLISTREPLY, NULL, NULL, Context,
1956 tag ? NULL : CURHDR);
1957 menu->redraw = REDRAW_FULL;
1963 ci_send_message (0, NULL, NULL, Context, NULL);
1964 menu->redraw = REDRAW_FULL;
1967 case OP_EXTRACT_KEYS:
1970 crypt_extract_keys_from_messages (tag ? NULL : CURHDR);
1971 menu->redraw = REDRAW_FULL;
1975 case OP_CHECK_TRADITIONAL:
1978 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
1979 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
1981 if (menu->menu == MENU_PAGER) {
1982 op = OP_DISPLAY_MESSAGE;
1990 mutt_pipe_message (tag ? NULL : CURHDR);
1991 MAYBE_REDRAW (menu->redraw);
1997 mutt_print_message (tag ? NULL : CURHDR);
2000 case OP_MAIN_READ_THREAD:
2001 case OP_MAIN_READ_SUBTHREAD:
2006 CHECK_MX_ACL (Context, ACL_SEEN, _("Marking as read"));
2008 rc = mutt_thread_set_flag (CURHDR, M_READ, 1,
2009 op == OP_MAIN_READ_THREAD ? 0 : 1);
2012 if (option (OPTRESOLVE)) {
2013 if ((menu->current = (op == OP_MAIN_READ_THREAD ?
2014 mutt_next_thread (CURHDR) :
2015 mutt_next_subthread (CURHDR))) == -1)
2016 menu->current = menu->oldcurrent;
2018 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2022 case OP_RECALL_MESSAGE:
2025 ci_send_message (SENDPOSTPONED, NULL, NULL, Context, NULL);
2026 menu->redraw = REDRAW_FULL;
2036 for (j = 0; j < Context->vcount; j++) {
2037 if (Context->hdrs[Context->v2r[j]]->tagged)
2038 mutt_resend_message (NULL, Context,
2039 Context->hdrs[Context->v2r[j]]);
2043 mutt_resend_message (NULL, Context, CURHDR);
2045 menu->redraw = REDRAW_FULL;
2051 case OP_FORWARD_TO_GROUP:
2054 if ((op == OP_FOLLOWUP || op == OP_FORWARD_TO_GROUP) &&
2055 Context && Context->msgcount == 0) {
2056 mutt_error (_("There are no messages."));
2059 else if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2060 m_strcasecmp(CURHDR->env->followup_to, "poster") ||
2061 query_quadoption (OPT_FOLLOWUPTOPOSTER,
2062 _("Reply by mail as poster prefers?")) !=
2064 if (Context && Context->magic == M_NNTP
2065 && !((nntp_data_t *) Context->data)->allowed
2066 && query_quadoption (OPT_TOMODERATED,
2068 ("Posting to this group not allowed, may be moderated. Continue?"))
2072 ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2075 if (op == OP_FOLLOWUP)
2076 ci_send_message (SENDNEWS | SENDREPLY, NULL, NULL, Context,
2077 tag ? NULL : CURHDR);
2079 ci_send_message (SENDNEWS | SENDFORWARD, NULL, NULL, Context,
2080 tag ? NULL : CURHDR);
2082 menu->redraw = REDRAW_FULL;
2093 if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
2094 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
2096 ci_send_message (SENDREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
2097 menu->redraw = REDRAW_FULL;
2100 case OP_SHELL_ESCAPE:
2102 mutt_shell_escape ();
2103 MAYBE_REDRAW (menu->redraw);
2107 case OP_TAG_SUBTHREAD:
2111 rc = mutt_thread_set_flag (CURHDR, M_TAG, !CURHDR->tagged,
2112 op == OP_TAG_THREAD ? 0 : 1);
2115 if (option (OPTRESOLVE)) {
2116 menu->current = mutt_next_thread (CURHDR);
2118 if (menu->current == -1)
2119 menu->current = menu->oldcurrent;
2121 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2131 CHECK_MX_ACL (Context, ACL_DELETE, _("Undeletion"));
2134 mutt_tag_set_flag (M_DELETE, 0);
2135 mutt_tag_set_flag (M_PURGED, 0);
2136 menu->redraw = REDRAW_INDEX;
2139 mutt_set_flag (Context, CURHDR, M_DELETE, 0);
2140 mutt_set_flag (Context, CURHDR, M_PURGED, 0);
2141 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1) {
2143 menu->redraw = REDRAW_MOTION_RESYNCH;
2146 menu->redraw = REDRAW_CURRENT;
2148 menu->redraw |= REDRAW_STATUS;
2151 case OP_UNDELETE_THREAD:
2152 case OP_UNDELETE_SUBTHREAD:
2158 CHECK_MX_ACL (Context, ACL_DELETE, _("Undeletion"));
2160 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2161 op == OP_UNDELETE_THREAD ? 0 : 1)
2162 + mutt_thread_set_flag (CURHDR, M_PURGED, 0,
2163 op == OP_UNDELETE_THREAD ? 0 : 1);
2166 if (option (OPTRESOLVE)) {
2167 if (op == OP_UNDELETE_THREAD)
2168 menu->current = mutt_next_thread (CURHDR);
2170 menu->current = mutt_next_subthread (CURHDR);
2172 if (menu->current == -1)
2173 menu->current = menu->oldcurrent;
2175 menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2184 if (option (OPTFORCEBUFFYCHECK))
2187 menu->redraw = REDRAW_FULL;
2190 case OP_VIEW_ATTACHMENTS:
2193 mutt_view_attachments (CURHDR);
2194 if (CURHDR->attach_del)
2195 Context->changed = 1;
2196 menu->redraw = REDRAW_FULL;
2206 case OP_SIDEBAR_SCROLL_UP:
2207 case OP_SIDEBAR_SCROLL_DOWN:
2208 case OP_SIDEBAR_NEXT:
2209 case OP_SIDEBAR_PREV:
2210 case OP_SIDEBAR_NEXT_NEW:
2211 case OP_SIDEBAR_PREV_NEW:
2212 sidebar_scroll (op);
2215 if (menu->menu == MENU_MAIN)
2216 km_error_key (MENU_MAIN);
2219 if (menu->menu == MENU_PAGER) {
2220 menu->menu = MENU_MAIN;
2221 menu->redraw = REDRAW_FULL;
2229 /* Close all open IMAP connections */
2232 /* Close all open NNTP connections */
2237 mutt_menuDestroy (&menu);
2241 void mutt_set_header_color (CONTEXT * ctx, HEADER * curhdr)
2248 for (color = ColorIndexList; color; color = color->next)
2249 if (mutt_pattern_exec
2250 (color->color_pattern, M_MATCH_FULL_ADDRESS, ctx, curhdr)) {
2251 curhdr->pair = color->pair;
2254 curhdr->pair = ColorDefs[MT_COLOR_NORMAL];