# include <ioctl.h>
#endif
-static struct {
- int rows, cols;
- WINDOW *sidebar;
- WINDOW *main;
-} layout;
+WINDOW *sidebar_w, *main_w;
void mutt_need_hard_redraw(void)
{
/* 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)
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);
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);
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;
}