X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-ui%2Fcurs_main.c;h=257cd96591e6211956b1a815042e4972a03c993e;hp=0fd125a3fd22e02aa365bbebc04c371afce88145;hb=7dcd7ee09b8760133ac8ec00562e4d60b2f0aebd;hpb=05a3bbbe420e4afc76e0eea24ce32f859405dc4a diff --git a/lib-ui/curs_main.c b/lib-ui/curs_main.c index 0fd125a..257cd96 100644 --- a/lib-ui/curs_main.c +++ b/lib-ui/curs_main.c @@ -10,49 +10,28 @@ * please see the file GPL in the top level source directory. */ -#if HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include -#include +#include +#include +#include "pop.h" -#include "curses.h" #include "menu.h" #include "mutt.h" -#include "mx.h" +#include "crypt.h" +#include "pattern.h" +#include "alias.h" #include "sort.h" #include "recvattach.h" #include "buffy.h" -#include "mx.h" -#include "sidebar.h" #include "thread.h" -#include "xterm.h" +#include "score.h" #include -#include - #ifdef USE_NNTP -#include "nntp/nntp.h" -#endif - -#ifdef USE_SASL -#include "mutt_sasl.h" +#include "nntp.h" #endif static const char *No_mailbox_is_open = N_("No mailbox is open."); @@ -107,14 +86,12 @@ static const char *No_visible = N_("No visible messages."); #define CURHDR Context->hdrs[Context->v2r[menu->current]] #define OLDHDR Context->hdrs[Context->v2r[menu->oldcurrent]] #define UNREAD(h) mutt_thread_contains_unread (Context, h) -#define SW (option(OPTMBOXPANE)?SidebarWidth:0) extern size_t UngetCount; void index_make_entry (char *s, ssize_t l, struct menu_t * menu, int num) { - format_flag flag = - M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR | M_FORMAT_INDEX; + format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_INDEX; int edgemsgno, reverse = Sort & SORT_REVERSE; HEADER *h = Context->hdrs[Context->v2r[num]]; THREAD *tmp; @@ -371,38 +348,12 @@ static void resort_index (MUTTMENU * menu) menu->redraw = REDRAW_INDEX | REDRAW_STATUS; } -struct mapping_t IndexHelp[] = { - {N_("Quit"), OP_QUIT}, - {N_("Del"), OP_DELETE}, - {N_("Undel"), OP_UNDELETE}, - {N_("Save"), OP_SAVE}, - {N_("Mail"), OP_MAIL}, - {N_("Reply"), OP_REPLY}, - {N_("Group"), OP_GROUP_REPLY}, - {N_("Help"), OP_HELP}, - {NULL, OP_NULL} -}; - -#ifdef USE_NNTP -struct mapping_t IndexNewsHelp[] = { - {N_("Quit"), OP_QUIT}, - {N_("Del"), OP_DELETE}, - {N_("Undel"), OP_UNDELETE}, - {N_("Save"), OP_SAVE}, - {N_("Post"), OP_POST}, - {N_("Followup"), OP_FOLLOWUP}, - {N_("Catchup"), OP_CATCHUP}, - {N_("Help"), OP_HELP}, - {NULL, OP_NULL} -}; -#endif - /* This function handles the message index window as well as commands returned * from the pager (MENU_PAGER). */ int mutt_index_menu (void) { - char buf[LONG_STRING], helpstr[SHORT_STRING]; + char buf[LONG_STRING]; int flags; int op = OP_NULL; int done = 0; /* controls when to exit the "event" loop */ @@ -412,10 +363,10 @@ int mutt_index_menu (void) int oldcount = -1; int rc = -1; MUTTMENU *menu; - char *cp; /* temporary variable. */ + const char *cp; /* temporary variable. */ int index_hint; /* used to restore cursor position */ int do_buffy_notify = 1; - int closed = 0; /* did we OP_QUIT or OP_EXIT out of this menu? */ + int closed = 0; /* did we OP_QUIT or OP_EXIT out of this menu? */ int attach_msg = option (OPTATTACHMSG); menu = mutt_new_menu (); @@ -425,13 +376,6 @@ int mutt_index_menu (void) menu->make_entry = (void *) index_make_entry; menu->color = index_color; menu->current = ci_first_message (); - menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, -#ifdef USE_NNTP - (Context - && (Context->magic == - M_NNTP)) ? IndexNewsHelp : -#endif - IndexHelp); if (!attach_msg) { buffy_check (0); /* force the buffy check after we enter the folder */ @@ -490,10 +434,10 @@ int mutt_index_menu (void) ("Mailbox was externally modified. Flags may be wrong.")); else if (check == M_NEW_MAIL) { /* on new mail: redraw sidebar */ - sidebar_draw (CurrentMenu); + sidebar_draw (); mutt_message (_("New mail in this mailbox.")); - if (option (OPTBEEPNEW)) + if (mod_core.beep_new) beep (); } else if (check == M_FLAGS) @@ -520,7 +464,7 @@ int mutt_index_menu (void) menu->redraw |= REDRAW_SIDEBAR; } if (do_buffy_notify) { - if (buffy_notify () && option (OPTBEEPNEW)) + if (buffy_notify () && mod_core.beep_new) beep (); } else @@ -530,10 +474,10 @@ int mutt_index_menu (void) if (op != -1) mutt_curs_set (0); if (menu->redraw & REDRAW_SIDEBAR) - sidebar_draw (menu->menu); + sidebar_draw (); if (menu->redraw & REDRAW_FULL) { menu_redraw_full (menu); - sidebar_draw (menu->menu); + sidebar_draw (); mutt_show_error (); } @@ -553,21 +497,21 @@ int mutt_index_menu (void) if (menu->redraw & REDRAW_STATUS) { menu_status_line (buf, sizeof (buf), menu, NONULL (Status)); - CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES - 2); - sidebar_draw_frames(); - SETCOLOR (MT_COLOR_STATUS); - BKGDSET (MT_COLOR_STATUS); - move(option (OPTSTATUSONTOP) ? 0 : LINES - 2,SW); - mutt_paddstr (COLS-SW, buf); - SETCOLOR (MT_COLOR_NORMAL); - BKGDSET (MT_COLOR_NORMAL); + CLEARLINE(main_w, 0); + SETCOLOR(main_w, MT_COLOR_STATUS); + BKGDSET(main_w, MT_COLOR_STATUS); + wmove(main_w, 0, 0); + mutt_paddstr (main_w, getmaxx(main_w), buf); + SETCOLOR(main_w, MT_COLOR_NORMAL); + BKGDSET(main_w, MT_COLOR_NORMAL); sidebar_set_buffystats (Context); menu->redraw &= ~REDRAW_STATUS; if (option (OPTXTERMSETTITLES)) { - menu_status_line (buf, sizeof (buf), menu, NONULL (XtermTitle)); - mutt_xterm_set_title (buf); - menu_status_line (buf, sizeof (buf), menu, NONULL (XtermIcon)); - mutt_xterm_set_icon (buf); + menu_status_line(buf, sizeof(buf), menu, NONULL(XtermTitle)); + printf("\033]2;%s\007", buf); + menu_status_line(buf, sizeof(buf), menu, NONULL(XtermIcon)); + printf("\033]1;%s\007", buf); + fflush(stdout); } } @@ -576,36 +520,18 @@ int mutt_index_menu (void) menu->oldcurrent = menu->current; else menu->oldcurrent = -1; - - if (option (OPTARROWCURSOR)) - move (menu->current - menu->top + menu->offset, 2); - else if (option (OPTBRAILLEFRIENDLY)) - move (menu->current - menu->top + menu->offset, 0); - else - move (menu->current - menu->top + menu->offset, COLS - 1); mutt_refresh (); -#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM) if (SigWinch) { mutt_flushinp (); - mutt_resize_screen (); + ui_layout_resize(); menu->redraw = REDRAW_FULL; menu->menu = MENU_MAIN; - SigWinch = 0; menu->top = 0; /* so we scroll the right amount */ - /* - * force a real complete redraw. clrtobot() doesn't seem to be able - * to handle every case without this. - */ - clearok (stdscr, TRUE); continue; } -#endif op = km_dokey (MENU_MAIN); - - debug_print (4, ("Got op %d\n", op)); - if (op == -1) continue; /* either user abort or timeout */ @@ -627,13 +553,13 @@ int mutt_index_menu (void) tag = 1; /* give visual indication that the next command is a tag- command */ - mvaddstr (LINES - 1, 0, "tag-"); - clrtoeol (); + mvwaddstr (main_w, LINES - 1, 0, "tag-"); + wclrtoeol (main_w); /* get the real command */ if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX) { /* abort tag sequence */ - CLEARLINE (LINES - 1); + CLEARLINE(main_w, LINES - 1); continue; } } @@ -662,13 +588,13 @@ int mutt_index_menu (void) tag = 1; /* give visual indication that the next command is a tag- command */ - mvaddstr (LINES - 1, 0, "tag-"); - clrtoeol (); + mvwaddstr (main_w, LINES - 1, 0, "tag-"); + wclrtoeol (main_w); /* get the real command */ if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX) { /* abort tag sequence */ - CLEARLINE (LINES - 1); + CLEARLINE(main_w, LINES - 1); continue; } } @@ -751,7 +677,7 @@ int mutt_index_menu (void) break; } else { - LIST *ref = CURHDR->env->references; + string_list_t *ref = CURHDR->env->references; if (!ref) { mutt_error (_("Article has no parent reference!")); @@ -807,7 +733,7 @@ int mutt_index_menu (void) m_strcpy(buf, sizeof(buf), CURHDR->env->message_id); if (op == OP_RECONSTRUCT_THREAD) { - LIST *ref = CURHDR->env->references; + string_list_t *ref = CURHDR->env->references; while (ref) { nntp_check_msgid (Context, ref->data); @@ -942,15 +868,14 @@ int mutt_index_menu (void) if (op == OP_TOGGLE_READ) { char buffer[LONG_STRING]; - if (!Context->pattern - || strncmp (Context->pattern, "!~R!~D~s", 8) != 0) { + if (m_strncmp (Context->pattern, "!~R!~D~s", 8) != 0) { snprintf (buffer, sizeof (buffer), "!~R!~D~s%s", Context->pattern ? Context->pattern : ".*"); set_option (OPTHIDEREAD); } else { m_strcpy(buf, sizeof(buf), Context->pattern + 8); - if (!*buf || strncmp (buf, ".*", 2) == 0) + if (m_strncmp (buf, ".*", 2) == 0) snprintf (buf, sizeof (buf), "~A"); unset_option (OPTHIDEREAD); } @@ -990,7 +915,7 @@ int mutt_index_menu (void) break; } - if (query_quadoption (OPT_QUIT, _("Quit Madmutt?")) == M_YES) { + if (query_quadoption2(mod_core.quit, _("Quit Madmutt?")) == M_YES) { int check; oldcount = Context ? Context->msgcount : 0; @@ -1009,8 +934,7 @@ int mutt_index_menu (void) break; case OP_REDRAW: - - clearok (stdscr, TRUE); + clearok (main_w, TRUE); menu->redraw = REDRAW_FULL; break; @@ -1158,7 +1082,7 @@ int mutt_index_menu (void) case OP_MAIN_CHANGE_GROUP: case OP_MAIN_CHANGE_GROUP_READONLY: #endif - if (attach_msg || option (OPTREADONLY) || + if (attach_msg || #ifdef USE_NNTP op == OP_MAIN_CHANGE_GROUP_READONLY || #endif @@ -1205,7 +1129,7 @@ int mutt_index_menu (void) break; } if (!buf[0]) { - CLEARLINE (LINES - 1); + CLEARLINE(main_w, LINES - 1); break; } @@ -1226,7 +1150,7 @@ int mutt_index_menu (void) if (Context) { int check; - if (Context->compressinfo && Context->realpath) + if (Context->cinfo && Context->realpath) m_strreplace(&LastFolder, Context->realpath); else m_strreplace(&LastFolder, Context->path); @@ -1260,14 +1184,6 @@ int mutt_index_menu (void) menu->current = 0; sidebar_set_current (buf); -#ifdef USE_NNTP - /* buffy_check() must be done with mail-reader mode! */ - menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, - (Context - && (Context->magic == - M_NNTP)) ? IndexNewsHelp : - IndexHelp); -#endif mutt_clear_error (); buffy_check (0); /* force the buffy check after we have changed the folder */ @@ -1296,8 +1212,7 @@ int mutt_index_menu (void) menu->current = mutt_thread_next_unread (Context, CURHDR); } - if (option (OPTPGPAUTODEC) && - (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))) + if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)) mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw); if ((op = mutt_display_message (CURHDR)) == -1) { @@ -1318,7 +1233,7 @@ int mutt_index_menu (void) } if ((menu->menu == MENU_MAIN) - && (query_quadoption (OPT_QUIT, + && (query_quadoption2(mod_core.quit, _("Exit Madmutt without saving?")) == M_YES)) { if (Context) { @@ -1763,8 +1678,7 @@ int mutt_index_menu (void) CHECK_VISIBLE; CHECK_READONLY; - if (mutt_change_flag (tag ? NULL : CURHDR, (op == OP_MAIN_SET_FLAG)) == - 0) { + if (mutt_change_flag (tag ? NULL : CURHDR, (op == OP_MAIN_SET_FLAG)) == 0) { menu->redraw = REDRAW_STATUS; if (tag) menu->redraw |= REDRAW_INDEX; @@ -1956,7 +1870,7 @@ int mutt_index_menu (void) case OP_CATCHUP: if (Context && Context->magic == M_NNTP) { if (mutt_newsgroup_catchup (CurrentNewsSrv, - ((NNTP_DATA *) Context->data)->group)) + ((nntp_data_t *) Context->data)->group)) menu->redraw = REDRAW_INDEX | REDRAW_STATUS; } break; @@ -1989,8 +1903,7 @@ int mutt_index_menu (void) CHECK_MX_ACL (Context, ACL_INSERT, _("Editing")); - if (option (OPTPGPAUTODEC) - && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))) + if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)) mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw); mutt_edit_message (Context, tag ? NULL : CURHDR); menu->redraw = REDRAW_FULL; @@ -2003,26 +1916,19 @@ int mutt_index_menu (void) CHECK_VISIBLE; CHECK_ATTACH; - if (option (OPTPGPAUTODEC) && - (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))) + if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)) mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw); ci_send_message (SENDFORWARD, NULL, NULL, Context, tag ? NULL : CURHDR); menu->redraw = REDRAW_FULL; break; - - case OP_FORGET_PASSPHRASE: - crypt_forget_passphrase (); - break; - case OP_GROUP_REPLY: CHECK_MSGCOUNT; CHECK_VISIBLE; CHECK_ATTACH; - if (option (OPTPGPAUTODEC) && - (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))) + if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)) mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw); ci_send_message (SENDREPLY | SENDGROUPREPLY, NULL, NULL, Context, @@ -2036,8 +1942,7 @@ int mutt_index_menu (void) CHECK_MSGCOUNT; CHECK_VISIBLE; - if (option (OPTPGPAUTODEC) && - (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))) + if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)) mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw); ci_send_message (SENDREPLY | SENDLISTREPLY, NULL, NULL, Context, @@ -2052,13 +1957,6 @@ int mutt_index_menu (void) menu->redraw = REDRAW_FULL; break; - case OP_MAIL_KEY: - CHECK_ATTACH; - ci_send_message (SENDKEY, NULL, NULL, NULL, NULL); - menu->redraw = REDRAW_FULL; - break; - - case OP_EXTRACT_KEYS: CHECK_MSGCOUNT; CHECK_VISIBLE; @@ -2080,35 +1978,20 @@ int mutt_index_menu (void) break; case OP_PIPE: - CHECK_MSGCOUNT; CHECK_VISIBLE; mutt_pipe_message (tag ? NULL : CURHDR); - /* in an IMAP folder index with imap_peek=no, piping could change - * * new or old messages status to read. Redraw what's needed. - */ - if (Context->magic == M_IMAP && !option (OPTIMAPPEEK)) { - menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS; - } MAYBE_REDRAW (menu->redraw); break; case OP_PRINT: - CHECK_MSGCOUNT; CHECK_VISIBLE; mutt_print_message (tag ? NULL : CURHDR); - /* in an IMAP folder index with imap_peek=no, piping could change - * * new or old messages status to read. Redraw what's needed. - */ - if (Context->magic == M_IMAP && !option (OPTIMAPPEEK)) { - menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS; - } break; case OP_MAIN_READ_THREAD: case OP_MAIN_READ_SUBTHREAD: - CHECK_MSGCOUNT; CHECK_VISIBLE; CHECK_READONLY; @@ -2172,7 +2055,7 @@ int mutt_index_menu (void) _("Reply by mail as poster prefers?")) != M_YES) { if (Context && Context->magic == M_NNTP - && !((NNTP_DATA *) Context->data)->allowed + && !((nntp_data_t *) Context->data)->allowed && query_quadoption (OPT_TOMODERATED, _ ("Posting to this group not allowed, may be moderated. Continue?")) @@ -2200,8 +2083,7 @@ int mutt_index_menu (void) CHECK_MSGCOUNT; CHECK_VISIBLE; - if (option (OPTPGPAUTODEC) && - (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))) + if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)) mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw); ci_send_message (SENDREPLY, NULL, NULL, Context, tag ? NULL : CURHDR); @@ -2314,17 +2196,13 @@ int mutt_index_menu (void) mutt_what_key (); break; - case OP_REBUILD_CACHE: - mx_rebuild_cache (); - break; - case OP_SIDEBAR_SCROLL_UP: case OP_SIDEBAR_SCROLL_DOWN: case OP_SIDEBAR_NEXT: case OP_SIDEBAR_PREV: case OP_SIDEBAR_NEXT_NEW: case OP_SIDEBAR_PREV_NEW: - sidebar_scroll (op, menu->menu); + sidebar_scroll (op); break; default: if (menu->menu == MENU_MAIN) @@ -2334,9 +2212,6 @@ int mutt_index_menu (void) if (menu->menu == MENU_PAGER) { menu->menu = MENU_MAIN; menu->redraw = REDRAW_FULL; -#if 0 - set_option (OPTWEED); /* turn header weeding back on. */ -#endif } if (done) @@ -2349,9 +2224,6 @@ int mutt_index_menu (void) #ifdef USE_NNTP /* Close all open NNTP connections */ nntp_logout_all (); -#endif -#ifdef USE_SASL - mutt_sasl_done (); #endif }