]> granicus.if.org Git - neomutt/commitdiff
split out sidebar wipe
authorRichard Russon <rich@flatcap.org>
Mon, 8 Feb 2016 16:30:36 +0000 (16:30 +0000)
committerRichard Russon <rich@flatcap.org>
Mon, 4 Apr 2016 02:37:43 +0000 (03:37 +0100)
sidebar.c

index f427dd86103e824f54527020c62d26b1100f9a7d..5a9cfcbf99e6c4e4ca1f7563d5d848ef32a1f032 100644 (file)
--- a/sidebar.c
+++ b/sidebar.c
@@ -642,6 +642,29 @@ draw_divider (int first_row, int num_rows)
        return delim_len;
 }
 
+/**
+ * fill_empty_space - Wipe the remaining sidebar space
+ * @first_row:  Screen line to start (0-based)
+ * @num_rows:   Number of rows to fill
+ * @width:      Width of the sidebar (minus the divider)
+ *
+ * Write spaces over the area the sidebar isn't using.
+ */
+static void
+fill_empty_space (int first_row, int num_rows, int width)
+{
+       /* Fill the remaining rows with blank space */
+       SETCOLOR(MT_COLOR_NORMAL);
+
+       int r;
+       for (r = 0; r < num_rows; r++) {
+               int i = 0;
+               move (first_row + r, 0);
+               for (; i < width; i++)
+                       addch (' ');
+       }
+}
+
 /**
  * draw_sidebar - Write out a list of mailboxes, on the left
  * @first_row:  Screen line to start (0-based)
@@ -670,6 +693,7 @@ draw_sidebar (int first_row, int num_rows, int div_width)
        if (!b)
                return;
 
+       int w = MIN(COLS, (SidebarWidth - div_width));
        int row = 0;
        for (b = TopBuffy; b && (row < num_rows); b = b->next) {
                if (b->is_hidden) {
@@ -755,7 +779,6 @@ draw_sidebar (int first_row, int num_rows, int div_width)
                        }
                }
                char str[SHORT_STRING];
-               int w = MIN(COLS, (SidebarWidth - div_width));
                make_sidebar_entry (str, sizeof (str), w, sidebar_folder_name, b);
                printw ("%s", str);
                if (sidebar_folder_depth > 0)
@@ -763,14 +786,7 @@ draw_sidebar (int first_row, int num_rows, int div_width)
                row++;
        }
 
-       /* Fill the remaining rows with blank space */
-       SETCOLOR(MT_COLOR_NORMAL);
-       for (; row < num_rows; row++) {
-               int i = 0;
-               move (first_row + row, 0);
-               for (; i < (SidebarWidth - div_width); i++)
-                       addch (' ');
-       }
+       fill_empty_space (first_row + row, num_rows - row, w);
 }
 
 
@@ -820,8 +836,11 @@ sb_draw (void)
        if (div_width < 0)
                return;
 
-       if (!Incoming)
+       if (!Incoming) {
+               int w = MIN(COLS, (SidebarWidth - div_width));
+               fill_empty_space (first_row, num_rows, w);
                return;
+       }
 
        if (!prepare_sidebar (num_rows))
                return;