]> granicus.if.org Git - neomutt/commitdiff
Separate out the index menu redrawing. (see #3877)
authorKevin McCarthy <kevin@8t8.us>
Wed, 5 Apr 2017 23:09:35 +0000 (16:09 -0700)
committerKevin McCarthy <kevin@8t8.us>
Wed, 5 Apr 2017 23:09:35 +0000 (16:09 -0700)
curs_main.c

index a1b69e8de579c328dc0e76ae0ce35c4b5805cdb9..dde3cadc2d1adc32605fdea6edebf63d4a568557 100644 (file)
@@ -494,6 +494,59 @@ static const struct mapping_t IndexHelp[] = {
   { NULL,       0 }
 };
 
+static void index_menu_redraw (MUTTMENU *menu)
+{
+  char buf[LONG_STRING];
+
+  if (menu->redraw & REDRAW_FULL)
+  {
+    menu_redraw_full (menu);
+    mutt_show_error ();
+  }
+
+#ifdef USE_SIDEBAR
+  if (menu->redraw & REDRAW_SIDEBAR)
+  {
+    mutt_sb_set_buffystats (Context);
+    menu_redraw_sidebar (menu);
+  }
+#endif
+
+  if (Context && Context->hdrs && !(menu->current >= Context->vcount))
+  {
+    menu_check_recenter (menu);
+
+    if (menu->redraw & REDRAW_INDEX)
+    {
+      menu_redraw_index (menu);
+      menu->redraw |= REDRAW_STATUS;
+    }
+    else if (menu->redraw & (REDRAW_MOTION_RESYNCH | REDRAW_MOTION))
+      menu_redraw_motion (menu);
+    else if (menu->redraw & REDRAW_CURRENT)
+      menu_redraw_current (menu);
+  }
+
+  if (menu->redraw & REDRAW_STATUS)
+  {
+    menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
+    mutt_window_move (MuttStatusWindow, 0, 0);
+    SETCOLOR (MT_COLOR_STATUS);
+    mutt_paddstr (MuttStatusWindow->cols, buf);
+    NORMAL_COLOR;
+    menu->redraw &= ~REDRAW_STATUS;
+    if (option(OPTTSENABLED) && TSSupported)
+    {
+      menu_status_line (buf, sizeof (buf), menu, NONULL (TSStatusFormat));
+      mutt_ts_status(buf);
+      menu_status_line (buf, sizeof (buf), menu, NONULL (TSIconFormat));
+      mutt_ts_icon(buf);
+    }
+  }
+
+  menu->redraw = 0;
+}
+
 /* This function handles the message index window as well as commands returned
  * from the pager (MENU_PAGER).
  */
@@ -519,6 +572,7 @@ int mutt_index_menu (void)
   menu->color = index_color;
   menu->current = ci_first_message ();
   menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
+  menu->custom_menu_redraw = index_menu_redraw;
   mutt_push_current_menu (menu);
 
   if (!attach_msg)
@@ -615,63 +669,19 @@ int mutt_index_menu (void)
 
     if (menu->menu == MENU_MAIN)
     {
-      if (menu->redraw & REDRAW_FULL)
-      {
-        menu_redraw_full (menu);
-        mutt_show_error ();
-      }
-
-#ifdef USE_SIDEBAR
-      if (menu->redraw & REDRAW_SIDEBAR)
-      {
-        mutt_sb_set_buffystats (Context);
-        menu_redraw_sidebar (menu);
-      }
-#endif
-      if (Context && Context->hdrs && !(menu->current >= Context->vcount))
-      {
-       menu_check_recenter (menu);
-
-       if (menu->redraw & REDRAW_INDEX)
-       {
-         menu_redraw_index (menu);
-         menu->redraw |= REDRAW_STATUS;
-       }
-       else if (menu->redraw & (REDRAW_MOTION_RESYNCH | REDRAW_MOTION))
-         menu_redraw_motion (menu);
-       else if (menu->redraw & REDRAW_CURRENT)
-         menu_redraw_current (menu);
-      }
+      index_menu_redraw (menu);
 
-      if (menu->redraw & REDRAW_STATUS)
-      {
-       menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
-        mutt_window_move (MuttStatusWindow, 0, 0);
-       SETCOLOR (MT_COLOR_STATUS);
-       mutt_paddstr (MuttStatusWindow->cols, buf);
-       NORMAL_COLOR;
-       menu->redraw &= ~REDRAW_STATUS;
-       if (option(OPTTSENABLED) && TSSupported)
-       {
-         menu_status_line (buf, sizeof (buf), menu, NONULL (TSStatusFormat));
-         mutt_ts_status(buf);
-         menu_status_line (buf, sizeof (buf), menu, NONULL (TSIconFormat));
-         mutt_ts_icon(buf);
-       }
-      }
-
-      menu->redraw = 0;
       if (menu->current < menu->max)
-       menu->oldcurrent = menu->current;
+        menu->oldcurrent = menu->current;
       else
-       menu->oldcurrent = -1;
+        menu->oldcurrent = -1;
 
       if (option (OPTARROWCURSOR))
-       mutt_window_move (MuttIndexWindow, menu->current - menu->top + menu->offset, 2);
+        mutt_window_move (MuttIndexWindow, menu->current - menu->top + menu->offset, 2);
       else if (option (OPTBRAILLEFRIENDLY))
-       mutt_window_move (MuttIndexWindow, menu->current - menu->top + menu->offset, 0);
+        mutt_window_move (MuttIndexWindow, menu->current - menu->top + menu->offset, 0);
       else
-       mutt_window_move (MuttIndexWindow, menu->current - menu->top + menu->offset,
+        mutt_window_move (MuttIndexWindow, menu->current - menu->top + menu->offset,
                           MuttIndexWindow->cols - 1);
       mutt_refresh ();
 
@@ -680,8 +690,6 @@ int mutt_index_menu (void)
       {
        mutt_flushinp ();
        mutt_resize_screen ();
-       menu->redraw = REDRAW_FULL;
-       menu->menu = MENU_MAIN;
        SigWinch = 0;
        menu->top = 0; /* so we scroll the right amount */
        /*