X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-ui%2Flayout.c;h=50fd0b61bdbed1152ff7f8a4300082c43d2a35f6;hp=bb7abc338d40e847480777b23797c54eaa29ec16;hb=b2c8662dd3e1d14ed817e9e166f1fd223a5b4754;hpb=5dcac54e5db074dc4572f843666c7f7acaf2d109 diff --git a/lib-ui/layout.c b/lib-ui/layout.c index bb7abc3..50fd0b6 100644 --- a/lib-ui/layout.c +++ b/lib-ui/layout.c @@ -26,11 +26,7 @@ # include #endif -static struct { - int rows, cols; - WINDOW *sidebar; - WINDOW *main; -} layout; +WINDOW *sidebar_w, *main_w; void mutt_need_hard_redraw(void) { @@ -41,20 +37,23 @@ void mutt_need_hard_redraw(void) void mutt_refresh(void) { + /* FIXME: UGGLY */ + extern ssize_t UngetCount; + /* don't refresh when we are waiting for a child. */ if (option(OPTKEEPQUIET)) return; -#if 0 /* MC: WHY ? */ /* don't refresh in the middle of macros unless necessary */ if (UngetCount && !option(OPTFORCEREFRESH)) return; -#endif /* else */ wrefresh(stdscr); - if (layout.sidebar) - wrefresh(layout.sidebar); + if (sidebar_w) + wrefresh(sidebar_w); + wrefresh(main_w); + main_w = NULL; } void mutt_endwin(const char *msg) @@ -62,13 +61,13 @@ void mutt_endwin(const char *msg) if (!option(OPTNOCURSES)) { CLEARLINE(LINES - 1); - if (layout.sidebar) { - delwin(layout.sidebar); - layout.sidebar = NULL; + if (sidebar_w) { + delwin(sidebar_w); + sidebar_w = NULL; } - if (layout.main) { - delwin(layout.main); - layout.main = NULL; + if (main_w) { + delwin(main_w); + main_w = NULL; } wattrset(stdscr, A_NORMAL); @@ -89,31 +88,29 @@ void ui_layout_init(void) mutt_error = mutt_curses_error; mutt_message = mutt_curses_message; - getmaxyx(stdscr, layout.rows, layout.cols); + main_w = newwin(LINES - 1, COLS, 0, 0); } void ui_layout_resize(void) { if (SigWinch) { - int fd; + int fd, rows = -1, cols = -1; struct winsize w; - layout.rows = layout.cols = -1; - if ((fd = open("/dev/tty", O_RDONLY)) != -1) { if (ioctl(fd, TIOCGWINSZ, &w) != -1) { - layout.rows = w.ws_row; - layout.cols = w.ws_col; + rows = w.ws_row; + cols = w.ws_col; } close(fd); } - if (layout.rows <= 0) { - layout.rows = atoi(getenv("LINES") ?: "24"); + if (rows <= 0) { + rows = atoi(getenv("LINES") ?: "24"); } - if (layout.cols <= 0) { - layout.cols = atoi(getenv("COLUMNS") ?: "80"); + if (cols <= 0) { + cols = atoi(getenv("COLUMNS") ?: "80"); } - resizeterm(layout.rows, layout.cols); + resizeterm(rows, cols); SigWinch = 0; /* force a real complete redraw. */ clearok(stdscr, true); @@ -122,24 +119,27 @@ void ui_layout_resize(void) WINDOW *ui_layout_sidebar_w(void) { - if (option(OPTMBOXPANE) && SidebarWidth > 1 && SidebarWidth < layout.cols) + if (option(OPTMBOXPANE) && SidebarWidth > 1 && SidebarWidth < COLS) { int sw, sh; - if (!layout.sidebar) { - layout.sidebar = newwin(layout.rows - 1, SidebarWidth, 0, 0); + if (!sidebar_w) { + sidebar_w = newwin(LINES - 1, SidebarWidth, 0, 0); + wresize(main_w, LINES - 1, COLS - SidebarWidth); } - getmaxyx(layout.sidebar, sh, sw); + getmaxyx(sidebar_w, sh, sw); - if (sh != layout.rows - 1 || sw != SidebarWidth) { - wresize(layout.sidebar, layout.rows - 1, SidebarWidth); + if (sh != LINES - 1 || sw != SidebarWidth) { + wresize(sidebar_w, LINES - 1, SidebarWidth); + wresize(main_w, LINES - 1, COLS - SidebarWidth); } } else { - if (layout.sidebar) { - delwin(layout.sidebar); - layout.sidebar = NULL; + if (sidebar_w) { + delwin(sidebar_w); + sidebar_w = NULL; + wresize(main_w, LINES - 1, COLS); } } - return layout.sidebar; + return sidebar_w; }