Signed-off-by: Pierre Habouzit <madcoder@debian.org>
# include <ioctl.h>
#endif
# 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)
{
void mutt_need_hard_redraw(void)
{
/* else */
wrefresh(stdscr);
/* 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)
}
void mutt_endwin(const char *msg)
if (!option(OPTNOCURSES)) {
CLEARLINE(LINES - 1);
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);
}
wattrset(stdscr, A_NORMAL);
mutt_error = mutt_curses_error;
mutt_message = mutt_curses_message;
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) {
}
void ui_layout_resize(void)
{
if (SigWinch) {
+ int fd, rows = -1, cols = -1;
- layout.rows = layout.cols = -1;
-
if ((fd = open("/dev/tty", O_RDONLY)) != -1) {
if (ioctl(fd, TIOCGWINSZ, &w) != -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;
- 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);
SigWinch = 0;
/* force a real complete redraw. */
clearok(stdscr, true);
WINDOW *ui_layout_sidebar_w(void)
{
WINDOW *ui_layout_sidebar_w(void)
{
- if (option(OPTMBOXPANE) && SidebarWidth > 1 && SidebarWidth < layout.cols)
+ if (option(OPTMBOXPANE) && SidebarWidth > 1 && SidebarWidth < COLS)
- 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);
- if (layout.sidebar) {
- delwin(layout.sidebar);
- layout.sidebar = NULL;
+ if (sidebar_w) {
+ delwin(sidebar_w);
+ sidebar_w = NULL;
+ wresize(main_w, LINES - 1, COLS);
#ifndef MUTT_LIB_UI_LAYOUT_H
#define MUTT_LIB_UI_LAYOUT_H
#ifndef MUTT_LIB_UI_LAYOUT_H
#define MUTT_LIB_UI_LAYOUT_H
+extern WINDOW *sidebar_w, *main_w;
+
void ui_layout_init(void);
void ui_layout_resize(void);
void ui_layout_init(void);
void ui_layout_resize(void);
void mutt_refresh(void);
void mutt_endwin(const char *);
void mutt_refresh(void);
void mutt_endwin(const char *);
+static inline int ui_get_width(WINDOW *w) {
+ int x, y;
+ getmaxyx(w, y, x);
+ return y;
+}
+
+static inline int ui_get_height(WINDOW *w) {
+ int x, y;
+ getmaxyx(w, y, x);
+ return x;
+}
+
int sidebar_need_count(void)
{
int sidebar_need_count(void)
{
- return ui_layout_sidebar_w() && !m_strisempty(SidebarNumberFormat);
+ return sidebar_w && !m_strisempty(SidebarNumberFormat);