2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or (at
5 * your option) any later version.
7 * This program is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * Copyright © 2006 Pierre Habouzit
20 #include <lib-ui/lib-ui.h>
23 #ifdef HAVE_SYS_IOCTL_H
24 # include <sys/ioctl.h>
25 #elif defined(HAVE_IOCTL_H)
29 WINDOW *sidebar_w, *main_w;
31 void mutt_need_hard_redraw(void)
34 clearok(main_w, true);
35 set_option(OPTNEEDREDRAW);
38 void mutt_refresh(void)
41 extern ssize_t UngetCount;
43 /* don't refresh when we are waiting for a child. */
44 if (option(OPTKEEPQUIET))
47 /* don't refresh in the middle of macros unless necessary */
48 if (UngetCount && !option(OPTFORCEREFRESH))
53 wnoutrefresh(sidebar_w);
59 void mutt_endwin(const char *msg)
61 if (!option(OPTNOCURSES)) {
62 CLEARLINE(main_w, LINES - 1);
79 if (!m_strisempty(msg)) {
85 void ui_layout_init(void)
88 main_w = newwin(LINES - 1, COLS, 0, 0);
89 SETCOLOR(main_w, MT_COLOR_NORMAL);
90 mutt_error = mutt_curses_error;
91 mutt_message = mutt_curses_message;
94 void ui_layout_resize(void)
97 int fd, rows = -1, cols = -1;
100 if ((fd = open("/dev/tty", O_RDONLY)) != -1) {
101 if (ioctl(fd, TIOCGWINSZ, &w) != -1) {
108 rows = atoi(getenv("LINES") ?: "24");
111 cols = atoi(getenv("COLUMNS") ?: "80");
113 resizeterm(rows, cols);
115 /* force a real complete redraw. */
116 clearok(main_w, true);
120 WINDOW *ui_layout_sidebar_w(void)
122 if (option(OPTMBOXPANE) && SidebarWidth > 1 && SidebarWidth < COLS)
127 sidebar_w = newwin(LINES - 1, SidebarWidth, 0, 0);
128 wresize(main_w, LINES - 1, COLS - SidebarWidth);
129 mvwin(main_w, 0, SidebarWidth);
132 getmaxyx(sidebar_w, sh, sw);
134 if (sh != LINES - 1 || sw != SidebarWidth) {
135 wresize(sidebar_w, LINES - 1, SidebarWidth);
136 wresize(main_w, LINES - 1, COLS - SidebarWidth);
137 mvwin(main_w, 0, SidebarWidth);
143 wresize(main_w, LINES - 1, COLS);