LINES - 1 is the status bar, living on stdscr.
[apps/madmutt.git] / lib-ui / layout.c
index 50fd0b6..5dfdb62 100644 (file)
@@ -30,8 +30,8 @@ WINDOW *sidebar_w, *main_w;
 
 void mutt_need_hard_redraw(void)
 {
-    keypad(stdscr, true);
-    clearok(stdscr, true);
+    keypad(main_w, true);
+    clearok(main_w, true);
     set_option(OPTNEEDREDRAW);
 }
 
@@ -49,28 +49,29 @@ void mutt_refresh(void)
         return;
 
     /* else */
-    wrefresh(stdscr);
     if (sidebar_w)
-        wrefresh(sidebar_w);
-    wrefresh(main_w);
-    main_w = NULL;
+        wnoutrefresh(sidebar_w);
+    if (main_w)
+        wnoutrefresh(main_w);
+    wrefresh(stdscr);
 }
 
 void mutt_endwin(const char *msg)
 {
     if (!option(OPTNOCURSES)) {
-        CLEARLINE(LINES - 1);
+        CLEARLINE(stdscr, LINES - 1);
 
         if (sidebar_w) {
             delwin(sidebar_w);
             sidebar_w = NULL;
         }
+#if 0
         if (main_w) {
             delwin(main_w);
             main_w = NULL;
         }
+#endif
 
-        wattrset(stdscr, A_NORMAL);
         mutt_refresh();
         endwin();
     }
@@ -83,12 +84,11 @@ void mutt_endwin(const char *msg)
 
 void ui_layout_init(void)
 {
-    SETCOLOR(MT_COLOR_NORMAL);
-    wclear(stdscr);
+    clear();
+    main_w = newwin(LINES - 1, COLS, 0, 0);
+    SETCOLOR(main_w, MT_COLOR_NORMAL);
     mutt_error   = mutt_curses_error;
     mutt_message = mutt_curses_message;
-
-    main_w = newwin(LINES - 1, COLS, 0, 0);
 }
 
 void ui_layout_resize(void)
@@ -113,7 +113,7 @@ void ui_layout_resize(void)
         resizeterm(rows, cols);
         SigWinch = 0;
         /* force a real complete redraw. */
-        clearok(stdscr, true);
+        clearok(main_w, true);
     }
 }
 
@@ -126,6 +126,7 @@ WINDOW *ui_layout_sidebar_w(void)
         if (!sidebar_w) {
             sidebar_w = newwin(LINES - 1, SidebarWidth, 0, 0);
             wresize(main_w, LINES - 1, COLS - SidebarWidth);
+            mvwin(main_w, 0, SidebarWidth);
         }
 
         getmaxyx(sidebar_w, sh, sw);
@@ -133,12 +134,14 @@ WINDOW *ui_layout_sidebar_w(void)
         if (sh != LINES - 1 || sw != SidebarWidth) {
             wresize(sidebar_w, LINES - 1, SidebarWidth);
             wresize(main_w, LINES - 1, COLS - SidebarWidth);
+            mvwin(main_w, 0, SidebarWidth);
         }
     } else {
         if (sidebar_w) {
             delwin(sidebar_w);
             sidebar_w = NULL;
             wresize(main_w, LINES - 1, COLS);
+            mvwin(main_w, 0, 0);
         }
     }
     return sidebar_w;