enter.o envelope.o filter.o flags.o from.o group.o handler.o \
hdrline.o header.o help.o history.o hook.o init.o keymap.o \
main.o mbox.o menu.o mh.o muttlib.o mutt_account.o \
- mutt_logging.o mutt_signal.o mutt_socket.o mx.o newsrc.o \
+ mutt_logging.o mutt_signal.o mutt_socket.o mutt_window.o mx.o newsrc.o \
nntp.o pager.o parse.o pattern.o pop.o pop_auth.o pop_lib.o \
postpone.o query.o recvattach.o recvcmd.o resize.o rfc1524.o \
rfc2047.o rfc2231.o rfc3676.o safe_asprintf.o score.o send.o \
#include "keymap.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "opcodes.h"
#include "options.h"
#include "protos.h"
#include "mutt_account.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "mx.h"
#include "opcodes.h"
#include "options.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "mx.h"
#include "options.h"
#include "protos.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "mx.h"
#include "ncrypt/ncrypt.h"
#include "options.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "mx.h"
#include "ncrypt/ncrypt.h"
#include "opcodes.h"
#include "header.h"
#include "mailbox.h"
#include "mutt_curses.h"
+#include "mutt_window.h"
#include "mx.h"
#include "ncrypt/ncrypt.h"
#include "options.h"
#include "header.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "opcodes.h"
#include "options.h"
#include "pager.h"
static size_t UngetLen = 0;
static struct Event *UngetKeyEvents;
-struct MuttWindow *MuttHelpWindow = NULL;
-struct MuttWindow *MuttIndexWindow = NULL;
-struct MuttWindow *MuttStatusWindow = NULL;
-struct MuttWindow *MuttMessageWindow = NULL;
-#ifdef USE_SIDEBAR
-struct MuttWindow *MuttSidebarWindow = NULL;
-#endif
-
-static void reflow_message_window_rows(int mw_rows);
-
void mutt_refresh(void)
{
/* don't refresh when we are waiting for a child. */
addstr((char *) field); /* cast to get around bad prototypes */
NORMAL_COLOR;
mutt_refresh();
- mutt_window_getyx(MuttMessageWindow, NULL, &x);
+ mutt_window_getxy(MuttMessageWindow, &x, NULL);
ret = mutt_enter_string_full(buf, buflen, x, complete, multiple, files, numfiles, es);
} while (ret == 1);
mutt_window_clearline(MuttMessageWindow, 0);
}
if (prompt_lines != MuttMessageWindow->rows)
{
- reflow_message_window_rows(prompt_lines);
+ mutt_window_reflow_message_rows(prompt_lines);
mutt_menu_current_redraw();
}
if (MuttMessageWindow->rows != 1)
{
- reflow_message_window_rows(1);
+ mutt_window_reflow_message_rows(1);
mutt_menu_current_redraw();
}
else
mutt_clear_error();
}
-void mutt_init_windows(void)
-{
- MuttHelpWindow = mutt_mem_calloc(1, sizeof(struct MuttWindow));
- MuttIndexWindow = mutt_mem_calloc(1, sizeof(struct MuttWindow));
- MuttStatusWindow = mutt_mem_calloc(1, sizeof(struct MuttWindow));
- MuttMessageWindow = mutt_mem_calloc(1, sizeof(struct MuttWindow));
-#ifdef USE_SIDEBAR
- MuttSidebarWindow = mutt_mem_calloc(1, sizeof(struct MuttWindow));
-#endif
-}
-
-void mutt_free_windows(void)
-{
- FREE(&MuttHelpWindow);
- FREE(&MuttIndexWindow);
- FREE(&MuttStatusWindow);
- FREE(&MuttMessageWindow);
-#ifdef USE_SIDEBAR
- FREE(&MuttSidebarWindow);
-#endif
-}
-
-void mutt_reflow_windows(void)
-{
- if (OPT_NO_CURSES)
- return;
-
- mutt_debug(2, "entering\n");
-
- MuttStatusWindow->rows = 1;
- MuttStatusWindow->cols = COLS;
- MuttStatusWindow->row_offset = StatusOnTop ? 0 : LINES - 2;
- MuttStatusWindow->col_offset = 0;
-
- memcpy(MuttHelpWindow, MuttStatusWindow, sizeof(struct MuttWindow));
- if (!Help)
- MuttHelpWindow->rows = 0;
- else
- MuttHelpWindow->row_offset = StatusOnTop ? LINES - 2 : 0;
-
- memcpy(MuttMessageWindow, MuttStatusWindow, sizeof(struct MuttWindow));
- MuttMessageWindow->row_offset = LINES - 1;
-
- memcpy(MuttIndexWindow, MuttStatusWindow, sizeof(struct MuttWindow));
- MuttIndexWindow->rows = MAX(
- LINES - MuttStatusWindow->rows - MuttHelpWindow->rows - MuttMessageWindow->rows, 0);
- MuttIndexWindow->row_offset =
- StatusOnTop ? MuttStatusWindow->rows : MuttHelpWindow->rows;
-
-#ifdef USE_SIDEBAR
- if (SidebarVisible)
- {
- memcpy(MuttSidebarWindow, MuttIndexWindow, sizeof(struct MuttWindow));
- MuttSidebarWindow->cols = SidebarWidth;
- MuttIndexWindow->cols -= SidebarWidth;
-
- if (SidebarOnRight)
- {
- MuttSidebarWindow->col_offset = COLS - SidebarWidth;
- }
- else
- {
- MuttIndexWindow->col_offset += SidebarWidth;
- }
- }
-#endif
-
- mutt_menu_set_current_redraw_full();
- /* the pager menu needs this flag set to recalc line_info */
- mutt_menu_set_current_redraw(REDRAW_FLOW);
-}
-
-static void reflow_message_window_rows(int mw_rows)
-{
- MuttMessageWindow->rows = mw_rows;
- MuttMessageWindow->row_offset = LINES - mw_rows;
-
- MuttStatusWindow->row_offset = StatusOnTop ? 0 : LINES - mw_rows - 1;
-
- if (Help)
- MuttHelpWindow->row_offset = StatusOnTop ? LINES - mw_rows - 1 : 0;
-
- MuttIndexWindow->rows = MAX(
- LINES - MuttStatusWindow->rows - MuttHelpWindow->rows - MuttMessageWindow->rows, 0);
-
-#ifdef USE_SIDEBAR
- if (SidebarVisible)
- MuttSidebarWindow->rows = MuttIndexWindow->rows;
-#endif
-
- /* We don't also set REDRAW_FLOW because this function only
- * changes rows and is a temporary adjustment. */
- mutt_menu_set_current_redraw_full();
-}
-
-int mutt_window_move(struct MuttWindow *win, int row, int col)
-{
- return move(win->row_offset + row, win->col_offset + col);
-}
-
-int mutt_window_mvaddch(struct MuttWindow *win, int row, int col, const chtype ch)
-{
- return mvaddch(win->row_offset + row, win->col_offset + col, ch);
-}
-
-int mutt_window_mvaddstr(struct MuttWindow *win, int row, int col, const char *str)
-{
- return mvaddstr(win->row_offset + row, win->col_offset + col, str);
-}
-
-#ifdef USE_SLANG_CURSES
-static int vw_printw(SLcurses_Window_Type *win, const char *fmt, va_list ap)
-{
- char buf[LONG_STRING];
-
- (void) SLvsnprintf(buf, sizeof(buf), (char *) fmt, ap);
- SLcurses_waddnstr(win, buf, -1);
- return 0;
-}
-#endif
-
-int mutt_window_mvprintw(struct MuttWindow *win, int row, int col, const char *fmt, ...)
-{
- int rc = mutt_window_move(win, row, col);
- if (rc != ERR)
- {
- va_list ap;
- va_start(ap, fmt);
- rc = vw_printw(stdscr, fmt, ap);
- va_end(ap);
- }
-
- return rc;
-}
-
-/**
- * mutt_window_clrtoeol - Clear to the end of the line
- *
- * Assumes the cursor has already been positioned within the window.
- */
-void mutt_window_clrtoeol(struct MuttWindow *win)
-{
- if (!win || !stdscr)
- return;
-
- if (win->col_offset + win->cols == COLS)
- clrtoeol();
- else
- {
- int row, col;
- getyx(stdscr, row, col);
- int curcol = col;
- while (curcol < win->col_offset + win->cols)
- {
- addch(' ');
- curcol++;
- }
- move(row, col);
- }
-}
-
-void mutt_window_clearline(struct MuttWindow *win, int row)
-{
- mutt_window_move(win, row, 0);
- mutt_window_clrtoeol(win);
-}
-
-/**
- * mutt_window_getyx - Get the cursor position in the window
- *
- * Assumes the current position is inside the window. Otherwise it will
- * happily return negative or values outside the window boundaries
- */
-void mutt_window_getyx(struct MuttWindow *win, int *y, int *x)
-{
- int row, col;
-
- getyx(stdscr, row, col);
- if (y)
- *y = row - win->row_offset;
- if (x)
- *x = col - win->col_offset;
-}
-
void mutt_show_error(void)
{
if (OPT_KEEP_QUIET || !ErrorBufMessage)
}
if (prompt_lines != MuttMessageWindow->rows)
{
- reflow_message_window_rows(prompt_lines);
+ mutt_window_reflow_message_rows(prompt_lines);
mutt_menu_current_redraw();
}
}
if (MuttMessageWindow->rows != 1)
{
- reflow_message_window_rows(1);
+ mutt_window_reflow_message_rows(1);
mutt_menu_current_redraw();
}
else
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "mx.h"
#include "ncrypt/ncrypt.h"
#include "opcodes.h"
case OP_SIDEBAR_TOGGLE_VISIBLE:
SidebarVisible = !SidebarVisible;
- mutt_reflow_windows();
+ mutt_window_reflow();
break;
case OP_SIDEBAR_TOGGLE_VIRTUAL:
#include "globals.h"
#include "header.h"
#include "mutt_curses.h"
+#include "mutt_window.h"
#include "options.h"
#include "protos.h"
#include "history.h"
#include "keymap.h"
#include "mutt_curses.h"
+#include "mutt_window.h"
#include "opcodes.h"
#include "protos.h"
#include "mutt.h"
#include "filter.h"
#include "mutt_curses.h"
+#include "mutt_window.h"
#include "protos.h"
/**
#include "header.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "mx.h"
#include "options.h"
#include "protos.h"
#include "globals.h"
#include "keymap.h"
#include "mutt_curses.h"
+#include "mutt_window.h"
#include "ncrypt/ncrypt.h"
#include "opcodes.h"
#include "options.h"
#include "header.h"
#include "mbtable.h"
#include "mutt_curses.h"
+#include "mutt_window.h"
#include "ncrypt/ncrypt.h"
#include "options.h"
#include "protos.h"
#include "globals.h"
#include "keymap.h"
#include "mutt_curses.h"
+#include "mutt_window.h"
#include "opcodes.h"
#include "options.h"
#include "pager.h"
#include "keymap.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "opcodes.h"
#include "options.h"
#include "protos.h"
#include "mbtable.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "mx.h"
#include "myvar.h"
#include "ncrypt/ncrypt.h"
if (p->flags & R_TREE)
OPT_REDRAW_TREE = true;
if (p->flags & R_REFLOW)
- mutt_reflow_windows();
+ mutt_window_reflow();
#ifdef USE_SIDEBAR
if (p->flags & R_SIDEBAR)
mutt_menu_set_current_redraw(REDRAW_SIDEBAR);
if (MuttVars[idx].flags & R_TREE)
OPT_REDRAW_TREE = true;
if (MuttVars[idx].flags & R_REFLOW)
- mutt_reflow_windows();
+ mutt_window_reflow();
#ifdef USE_SIDEBAR
if (MuttVars[idx].flags & R_SIDEBAR)
mutt_menu_set_current_redraw(REDRAW_SIDEBAR);
#include "functions.h"
#include "globals.h"
#include "mutt_curses.h"
+#include "mutt_window.h"
#include "ncrypt/ncrypt.h"
#include "opcodes.h"
#include "options.h"
#include "mutt_curses.h"
#include "mutt_logging.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "myvar.h"
#include "ncrypt/ncrypt.h"
#include "options.h"
meta(stdscr, true);
#endif
init_extended_keys();
- mutt_reflow_windows();
+ mutt_window_reflow();
return 0;
}
/* Always create the mutt_windows because batch mode has some shared code
* paths that end up referencing them. */
- mutt_init_windows();
+ mutt_window_init();
/* This must come before mutt_init() because curses needs to be started
* before calling the init_pair() function to set the color scheme. */
FREE(&tempfile);
}
- mutt_free_windows();
+ mutt_window_free();
if (rv != 0)
goto main_curses; // TEST36: neomutt -H existing -s test john@example.com -E (cancel sending)
log_queue_empty();
mutt_log_stop();
mutt_free_opts();
- mutt_free_windows();
+ mutt_window_free();
// TEST43: neomutt (no change to mailbox)
// TEST44: neomutt (change mailbox)
}
#include "keymap.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "opcodes.h"
#include "options.h"
#include "pattern.h"
void menu_redraw_full(struct Menu *menu)
{
- mutt_reflow_windows();
+ mutt_window_reflow();
NORMAL_COLOR;
/* clear() doesn't optimize screen redraws */
move(0, 0);
* was initialized with positive size, otherwise no percentage is shown */
void mutt_progress_update(struct Progress *progress, long pos, int percent);
-/**
- * struct MuttWindow - A division of the screen
- *
- * Windows for different parts of the screen
- */
-struct MuttWindow
-{
- int rows;
- int cols;
- int row_offset;
- int col_offset;
-};
-
-extern struct MuttWindow *MuttHelpWindow;
-extern struct MuttWindow *MuttIndexWindow;
-extern struct MuttWindow *MuttStatusWindow;
-extern struct MuttWindow *MuttMessageWindow;
-#ifdef USE_SIDEBAR
-extern struct MuttWindow *MuttSidebarWindow;
-#endif
-
-void mutt_init_windows(void);
-void mutt_free_windows(void);
-void mutt_reflow_windows(void);
-int mutt_window_move(struct MuttWindow *win, int row, int col);
-int mutt_window_mvaddch(struct MuttWindow *win, int row, int col, const chtype ch);
-int mutt_window_mvaddstr(struct MuttWindow *win, int row, int col, const char *str);
-int mutt_window_mvprintw(struct MuttWindow *win, int row, int col, const char *fmt, ...);
-void mutt_window_clrtoeol(struct MuttWindow *win);
-void mutt_window_clearline(struct MuttWindow *win, int row);
-void mutt_window_getyx(struct MuttWindow *win, int *y, int *x);
-
-static inline int mutt_window_wrap_cols(struct MuttWindow *win, short wrap)
-{
- if (wrap < 0)
- return win->cols > -wrap ? win->cols + wrap : win->cols;
- else if (wrap)
- return wrap < win->cols ? wrap : win->cols;
- else
- return win->cols;
-}
-
extern int *ColorQuote;
extern int ColorQuoteUsed;
extern int ColorDefs[];
#include "mutt/mutt.h"
#include "globals.h"
#include "mutt_curses.h"
+#include "mutt_window.h"
#include "protos.h"
struct timeval LastError = { 0 };
--- /dev/null
+/**
+ * @file
+ * Window management
+ *
+ * @authors
+ * Copyright (C) 2018 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "globals.h"
+#include "mutt/logging.h"
+#include "mutt/mutt.h"
+#include "mutt_menu.h"
+#include "mutt_window.h"
+#include "options.h"
+#include <stdarg.h>
+#include <string.h>
+
+struct MuttWindow *MuttHelpWindow = NULL;
+struct MuttWindow *MuttIndexWindow = NULL;
+struct MuttWindow *MuttStatusWindow = NULL;
+struct MuttWindow *MuttMessageWindow = NULL;
+#ifdef USE_SIDEBAR
+struct MuttWindow *MuttSidebarWindow = NULL;
+#endif
+
+#ifdef USE_SLANG_CURSES
+/**
+ * vw_printw - Write a formatted string to a Window (function missing from Slang)
+ * @param win Window
+ * @param fmt printf format string
+ * @param ap printf arguments
+ * @retval 0 Always
+ */
+static int vw_printw(SLcurses_Window_Type *win, const char *fmt, va_list ap)
+{
+ char buf[LONG_STRING];
+
+ (void) SLvsnprintf(buf, sizeof(buf), (char *) fmt, ap);
+ SLcurses_waddnstr(win, buf, -1);
+ return 0;
+}
+#endif
+
+/**
+ * mutt_window_clearline - Clear a row of a Window
+ * @param win Window
+ * @param row Row to clear
+ */
+void mutt_window_clearline(struct MuttWindow *win, int row)
+{
+ mutt_window_move(win, row, 0);
+ mutt_window_clrtoeol(win);
+}
+
+/**
+ * mutt_window_clrtoeol - Clear to the end of the line
+ * @param win Window
+ *
+ * @note Assumes the cursor has already been positioned within the window.
+ */
+void mutt_window_clrtoeol(struct MuttWindow *win)
+{
+ if (!win || !stdscr)
+ return;
+
+ if (win->col_offset + win->cols == COLS)
+ clrtoeol();
+ else
+ {
+ int row = 0;
+ int col = 0;
+ getyx(stdscr, row, col);
+ int curcol = col;
+ while (curcol < (win->col_offset + win->cols))
+ {
+ addch(' ');
+ curcol++;
+ }
+ move(row, col);
+ }
+}
+
+/**
+ * mutt_window_free - Free the default Windows
+ */
+void mutt_window_free(void)
+{
+ FREE(&MuttHelpWindow);
+ FREE(&MuttIndexWindow);
+ FREE(&MuttStatusWindow);
+ FREE(&MuttMessageWindow);
+#ifdef USE_SIDEBAR
+ FREE(&MuttSidebarWindow);
+#endif
+}
+
+/**
+ * mutt_window_getxy - Get the cursor position in the Window
+ * @param[in] win Window
+ * @param[out] x X-Coordinate
+ * @param[out] y Y-Coordinate
+ *
+ * Assumes the current position is inside the window. Otherwise it will
+ * happily return negative or values outside the window boundaries
+ */
+void mutt_window_getxy(struct MuttWindow *win, int *x, int *y)
+{
+ int row = 0;
+ int col = 0;
+
+ getyx(stdscr, row, col);
+ if (x)
+ *x = col - win->col_offset;
+ if (y)
+ *y = row - win->row_offset;
+}
+
+/**
+ * mutt_window_init - Create the default Windows
+ *
+ * Create the Help, Index, Status, Message and Sidebar Windows.
+ */
+void mutt_window_init(void)
+{
+ MuttHelpWindow = mutt_mem_calloc(1, sizeof(struct MuttWindow));
+ MuttIndexWindow = mutt_mem_calloc(1, sizeof(struct MuttWindow));
+ MuttStatusWindow = mutt_mem_calloc(1, sizeof(struct MuttWindow));
+ MuttMessageWindow = mutt_mem_calloc(1, sizeof(struct MuttWindow));
+#ifdef USE_SIDEBAR
+ MuttSidebarWindow = mutt_mem_calloc(1, sizeof(struct MuttWindow));
+#endif
+}
+
+/**
+ * mutt_window_move - Move the cursor in a Window
+ * @param win Window
+ * @param row Row to move to
+ * @param col Column to move to
+ * @retval OK Success
+ * @retval ERR Error
+ */
+int mutt_window_move(struct MuttWindow *win, int row, int col)
+{
+ return move(win->row_offset + row, win->col_offset + col);
+}
+
+/**
+ * mutt_window_mvaddch - Move the cursor and write a character to a Window
+ * @param win Window to write to
+ * @param row Row to move to
+ * @param col Column to move to
+ * @param ch Character to write
+ * @retval OK Success
+ * @retval ERR Error
+ */
+int mutt_window_mvaddch(struct MuttWindow *win, int row, int col, const chtype ch)
+{
+ return mvaddch(win->row_offset + row, win->col_offset + col, ch);
+}
+
+/**
+ * mutt_window_mvaddstr - Move the cursor and write a fixed string to a Window
+ * @param win Window to write to
+ * @param row Row to move to
+ * @param col Column to move to
+ * @param str String to write
+ * @retval OK Success
+ * @retval ERR Error
+ */
+int mutt_window_mvaddstr(struct MuttWindow *win, int row, int col, const char *str)
+{
+ return mvaddstr(win->row_offset + row, win->col_offset + col, str);
+}
+
+/**
+ * mutt_window_mvprintw - Move the cursor and write a formatted string to a Window
+ * @param win Window to write to
+ * @param row Row to move to
+ * @param col Column to move to
+ * @param fmt printf format string
+ * @param ... printf arguments
+ * @retval num Success, number of characters written
+ * @retval ERR Error, move failed
+ */
+int mutt_window_mvprintw(struct MuttWindow *win, int row, int col, const char *fmt, ...)
+{
+ int rc = mutt_window_move(win, row, col);
+ if (rc == ERR)
+ return rc;
+
+ va_list ap;
+ va_start(ap, fmt);
+ rc = vw_printw(stdscr, fmt, ap);
+ va_end(ap);
+
+ return rc;
+}
+
+/**
+ * mutt_window_reflow - Resize the Windows to fit the screen
+ */
+void mutt_window_reflow(void)
+{
+ if (OPT_NO_CURSES)
+ return;
+
+ mutt_debug(2, "entering\n");
+
+ MuttStatusWindow->rows = 1;
+ MuttStatusWindow->cols = COLS;
+ MuttStatusWindow->row_offset = StatusOnTop ? 0 : LINES - 2;
+ MuttStatusWindow->col_offset = 0;
+
+ memcpy(MuttHelpWindow, MuttStatusWindow, sizeof(struct MuttWindow));
+ if (!Help)
+ MuttHelpWindow->rows = 0;
+ else
+ MuttHelpWindow->row_offset = StatusOnTop ? LINES - 2 : 0;
+
+ memcpy(MuttMessageWindow, MuttStatusWindow, sizeof(struct MuttWindow));
+ MuttMessageWindow->row_offset = LINES - 1;
+
+ memcpy(MuttIndexWindow, MuttStatusWindow, sizeof(struct MuttWindow));
+ MuttIndexWindow->rows = MAX(
+ LINES - MuttStatusWindow->rows - MuttHelpWindow->rows - MuttMessageWindow->rows, 0);
+ MuttIndexWindow->row_offset =
+ StatusOnTop ? MuttStatusWindow->rows : MuttHelpWindow->rows;
+
+#ifdef USE_SIDEBAR
+ if (SidebarVisible)
+ {
+ memcpy(MuttSidebarWindow, MuttIndexWindow, sizeof(struct MuttWindow));
+ MuttSidebarWindow->cols = SidebarWidth;
+ MuttIndexWindow->cols -= SidebarWidth;
+
+ if (SidebarOnRight)
+ {
+ MuttSidebarWindow->col_offset = COLS - SidebarWidth;
+ }
+ else
+ {
+ MuttIndexWindow->col_offset += SidebarWidth;
+ }
+ }
+#endif
+
+ mutt_menu_set_current_redraw_full();
+ /* the pager menu needs this flag set to recalc line_info */
+ mutt_menu_set_current_redraw(REDRAW_FLOW);
+}
+
+/**
+ * mutt_window_reflow_message_rows - Resize the Message Window
+ * @param mw_rows Number of rows required
+ *
+ * Resize the other Windows to allow a multi-line message to be displayed.
+ */
+void mutt_window_reflow_message_rows(int mw_rows)
+{
+ MuttMessageWindow->rows = mw_rows;
+ MuttMessageWindow->row_offset = LINES - mw_rows;
+
+ MuttStatusWindow->row_offset = StatusOnTop ? 0 : LINES - mw_rows - 1;
+
+ if (Help)
+ MuttHelpWindow->row_offset = StatusOnTop ? LINES - mw_rows - 1 : 0;
+
+ MuttIndexWindow->rows = MAX(
+ LINES - MuttStatusWindow->rows - MuttHelpWindow->rows - MuttMessageWindow->rows, 0);
+
+#ifdef USE_SIDEBAR
+ if (SidebarVisible)
+ MuttSidebarWindow->rows = MuttIndexWindow->rows;
+#endif
+
+ /* We don't also set REDRAW_FLOW because this function only
+ * changes rows and is a temporary adjustment. */
+ mutt_menu_set_current_redraw_full();
+}
+
+/**
+ * mutt_window_wrap_cols - Calculate the wrap column for a Window
+ *
+ * The wrap variable can be negative, meaning there should be a right margin.
+ */
+int mutt_window_wrap_cols(struct MuttWindow *win, short wrap)
+{
+ if (wrap < 0)
+ return (win->cols > -wrap) ? (win->cols + wrap) : win->cols;
+ else if (wrap)
+ return (wrap < win->cols) ? wrap : win->cols;
+ else
+ return win->cols;
+}
--- /dev/null
+/**
+ * @file
+ * Window management
+ *
+ * @authors
+ * Copyright (C) 2018 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _MUTT_WINDOW_H
+#define _MUTT_WINDOW_H
+
+#include "mutt_curses.h"
+
+/**
+ * struct MuttWindow - A division of the screen
+ *
+ * Windows for different parts of the screen
+ */
+struct MuttWindow
+{
+ int rows;
+ int cols;
+ int row_offset;
+ int col_offset;
+};
+
+extern struct MuttWindow *MuttHelpWindow;
+extern struct MuttWindow *MuttIndexWindow;
+extern struct MuttWindow *MuttMessageWindow;
+#ifdef USE_SIDEBAR
+extern struct MuttWindow *MuttSidebarWindow;
+#endif
+extern struct MuttWindow *MuttStatusWindow;
+
+void mutt_window_clearline(struct MuttWindow *win, int row);
+void mutt_window_clrtoeol(struct MuttWindow *win);
+void mutt_window_free(void);
+void mutt_window_getxy(struct MuttWindow *win, int *x, int *y);
+void mutt_window_init(void);
+int mutt_window_move(struct MuttWindow *win, int row, int col);
+int mutt_window_mvaddch(struct MuttWindow *win, int row, int col, const chtype ch);
+int mutt_window_mvaddstr(struct MuttWindow *win, int row, int col, const char *str);
+int mutt_window_mvprintw(struct MuttWindow *win, int row, int col, const char *fmt, ...);
+void mutt_window_reflow_message_rows(int mw_rows);
+void mutt_window_reflow(void);
+int mutt_window_wrap_cols(struct MuttWindow *win, short wrap);
+
+#endif /* _MUTT_WINDOW_H */
#include "header.h"
#include "mailbox.h"
#include "mutt_curses.h"
+#include "mutt_window.h"
#include "mx.h"
#include "ncrypt/ncrypt.h"
#include "options.h"
#include "keymap.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "ncrypt.h"
#include "opcodes.h"
#include "options.h"
#include "format_flags.h"
#include "globals.h"
#include "mutt_curses.h"
+#include "mutt_window.h"
#include "ncrypt.h"
#include "pgp.h"
#include "pgpkey.h"
#include "keymap.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "ncrypt.h"
#include "opcodes.h"
#include "options.h"
#include "keymap.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "ncrypt.h"
#include "opcodes.h"
#include "options.h"
#include "mutt_account.h"
#include "mutt_curses.h"
#include "mutt_socket.h"
+#include "mutt_window.h"
#include "mx.h"
#include "nntp.h"
#include "options.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "mx.h"
#include "ncrypt/ncrypt.h"
#include "opcodes.h"
if (pager_menu->redraw & REDRAW_FULL)
{
- mutt_reflow_windows();
+ mutt_window_reflow();
NORMAL_COLOR;
/* clear() doesn't optimize screen redraws */
move(0, 0);
}
else
{
- /* note: mutt_resize_screen() -> mutt_reflow_windows() sets
+ /* note: mutt_resize_screen() -> mutt_window_reflow() sets
* REDRAW_FULL and REDRAW_FLOW */
ch = 0;
}
case OP_SIDEBAR_TOGGLE_VISIBLE:
SidebarVisible = !SidebarVisible;
- mutt_reflow_windows();
+ mutt_window_reflow();
break;
#endif
#include "keymap.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "opcodes.h"
#include "protos.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "mx.h"
#include "ncrypt/ncrypt.h"
#include "opcodes.h"
#include "globals.h"
#include "header.h"
#include "mutt_curses.h"
+#include "mutt_window.h"
#include "options.h"
#include "protos.h"
#include "state.h"
#include "keymap.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "opcodes.h"
#include "options.h"
#include "protos.h"
#include <unistd.h>
#include "mutt/mutt.h"
#include "mutt_curses.h"
+#include "mutt_window.h"
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#else
#else
resizeterm(SLtt_Screen_Rows, SLtt_Screen_Cols);
#endif
- mutt_reflow_windows();
+ mutt_window_reflow();
}
#include "globals.h"
#include "header.h"
#include "mutt_curses.h"
+#include "mutt_window.h"
#include "options.h"
#include "protos.h"
#include "state.h"
#include "header.h"
#include "mailbox.h"
#include "mutt_curses.h"
+#include "mutt_window.h"
#include "mx.h"
#include "ncrypt/ncrypt.h"
#include "options.h"
#include "globals.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "mx.h"
#include "opcodes.h"
#include "options.h"
#include "mbtable.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
+#include "mutt_window.h"
#include "mx.h"
#include "options.h"
#include "protos.h"