more useless and cluttered things.
[apps/madmutt.git] / lib-ui / curs_main.c
index 6e20d66..300dc8a 100644 (file)
 
 #include <lib-ui/sidebar.h>
 #include <lib-mx/mx.h>
-
-#include <pop/pop.h>
+#include "pop.h"
 
 #include "curses.h"
 #include "menu.h"
 
 #include "mutt.h"
+#include "crypt.h"
+#include "pattern.h"
 #include "alias.h"
 #include "sort.h"
 #include "recvattach.h"
 #include "buffy.h"
 #include "thread.h"
-#include "xterm.h"
+#include "score.h"
 
 #include <imap/imap_private.h>
 
-#include <lib-crypt/crypt.h>
-
 #ifdef USE_NNTP
-#include "nntp/nntp.h"
-#endif
-
-#ifdef USE_SASL
-#include "mutt_sasl.h"
+#include <nntp/nntp.h>
 #endif
 
 static const char *No_mailbox_is_open = N_("No mailbox is open.");
@@ -98,8 +93,7 @@ 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;
@@ -387,7 +381,7 @@ struct mapping_t IndexNewsHelp[] = {
  */
 int mutt_index_menu (void)
 {
-  char buf[LONG_STRING], helpstr[SHORT_STRING];
+  char buf[LONG_STRING], helpstr[STRING];
   int flags;
   int op = OP_NULL;
   int done = 0;                 /* controls when to exit the "event" loop */
@@ -397,10 +391,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 ();
@@ -478,7 +472,7 @@ int mutt_index_menu (void)
           sidebar_draw ();
           mutt_message (_("New mail in this mailbox."));
 
-          if (option (OPTBEEPNEW))
+          if (mod_core.beep_new)
             beep ();
         }
         else if (check == M_FLAGS)
@@ -505,7 +499,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
@@ -549,10 +543,11 @@ int mutt_index_menu (void)
         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);
         }
       }
 
@@ -562,9 +557,7 @@ int mutt_index_menu (void)
       else
         menu->oldcurrent = -1;
 
-      if (option (OPTARROWCURSOR))
-        move (menu->current - menu->top + menu->offset, 2);
-       else if (option (OPTBRAILLEFRIENDLY))
+      if (option (OPTBRAILLEFRIENDLY))
          move (menu->current - menu->top + menu->offset, 0);
       else
         move (menu->current - menu->top + menu->offset, COLS - 1);
@@ -925,15 +918,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);
         }
@@ -973,7 +965,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;
@@ -1301,7 +1293,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) {
@@ -1746,8 +1738,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;
@@ -1993,11 +1984,6 @@ int mutt_index_menu (void)
       menu->redraw = REDRAW_FULL;
       break;
 
-
-    case OP_FORGET_PASSPHRASE:
-      crypt_forget_passphrase ();
-      break;
-
     case OP_GROUP_REPLY:
 
       CHECK_MSGCOUNT;
@@ -2035,13 +2021,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;
@@ -2063,35 +2042,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;
@@ -2297,10 +2261,6 @@ 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:
@@ -2317,9 +2277,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)
@@ -2332,9 +2289,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
   }