X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-ui%2Flayout.c;h=eb5c2f0dba7964bea4409ba39417fe9f24c44e2b;hp=7b46036b64c882c01a8e7bef4c0ad301e8b77512;hb=819c071fa7efc8dffb4dd92f36f0111227ff692f;hpb=f68ede9bdd47d8c705245b2a07c0b8ba1e230662 diff --git a/lib-ui/layout.c b/lib-ui/layout.c index 7b46036..eb5c2f0 100644 --- a/lib-ui/layout.c +++ b/lib-ui/layout.c @@ -26,16 +26,12 @@ # include #endif -static struct { - int rows, cols; - WINDOW *sidebar; - WINDOW *main; -} layout; +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); } @@ -53,26 +49,29 @@ void mutt_refresh(void) return; /* else */ + if (sidebar_w) + wnoutrefresh(sidebar_w); + if (main_w) + wnoutrefresh(main_w); wrefresh(stdscr); - if (layout.sidebar) - wrefresh(layout.sidebar); } void mutt_endwin(const char *msg) { if (!option(OPTNOCURSES)) { - CLEARLINE(LINES - 1); + CLEARLINE(stdscr, 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 0 + if (main_w) { + delwin(main_w); + main_w = NULL; } +#endif - wattrset(stdscr, A_NORMAL); mutt_refresh(); endwin(); } @@ -85,62 +84,65 @@ void mutt_endwin(const char *msg) void ui_layout_init(void) { - SETCOLOR(MT_COLOR_NORMAL); - wclear(stdscr); + erase(); + main_w = newwin(LINES - 1, COLS, 0, 0); + SETCOLOR(main_w, MT_COLOR_NORMAL); mutt_error = mutt_curses_error; mutt_message = mutt_curses_message; - - getmaxyx(stdscr, layout.rows, layout.cols); } 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); + clearok(main_w, true); } } 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); + mvwin(main_w, 0, 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); + mvwin(main_w, 0, 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); + mvwin(main_w, 0, 0); } } - return layout.sidebar; + return sidebar_w; }