static size_t UngetLen = 0;
static event_t *UngetKeyEvents;
+mutt_window_t *MuttHelpWindow = NULL;
+mutt_window_t *MuttIndexWindow = NULL;
+mutt_window_t *MuttStatusWindow = NULL;
+mutt_window_t *MuttMessageWindow = NULL;
+#ifdef USE_SIDEBAR
+mutt_window_t *MuttSidebarWindow = NULL;
+#endif
+
void mutt_refresh (void)
{
/* don't refresh when we are waiting for a child. */
mutt_clear_error ();
}
+void mutt_init_windows ()
+{
+ MuttHelpWindow = safe_calloc (sizeof (mutt_window_t), 1);
+ MuttIndexWindow = safe_calloc (sizeof (mutt_window_t), 1);
+ MuttStatusWindow = safe_calloc (sizeof (mutt_window_t), 1);
+ MuttMessageWindow = safe_calloc (sizeof (mutt_window_t), 1);
+#ifdef USE_SIDEBAR
+ MuttSidebarWindow = safe_calloc (sizeof (mutt_window_t), 1);
+#endif
+
+ mutt_reflow_windows ();
+}
+
+void mutt_free_windows ()
+{
+ FREE (&MuttHelpWindow);
+ FREE (&MuttIndexWindow);
+ FREE (&MuttStatusWindow);
+ FREE (&MuttMessageWindow);
+#ifdef USE_SIDEBAR
+ FREE (&MuttSidebarWindow);
+#endif
+}
+
+void mutt_reflow_windows (void)
+{
+ if (option (OPTNOCURSES))
+ return;
+
+ dprint (2, (debugfile, "In mutt_reflow_windows\n"));
+
+ MuttStatusWindow->rows = 1;
+ MuttStatusWindow->cols = COLS;
+ MuttStatusWindow->row_offset = option (OPTSTATUSONTOP) ? 0 : LINES - 2;
+ MuttStatusWindow->col_offset = 0;
+
+ memcpy (MuttHelpWindow, MuttStatusWindow, sizeof (mutt_window_t));
+ if (! option (OPTHELP))
+ MuttHelpWindow->rows = 0;
+ else
+ MuttHelpWindow->row_offset = option (OPTSTATUSONTOP) ? LINES - 2 : 0;
+
+ memcpy (MuttMessageWindow, MuttStatusWindow, sizeof (mutt_window_t));
+ MuttMessageWindow->row_offset = LINES - 1;
+
+ memcpy (MuttIndexWindow, MuttStatusWindow, sizeof (mutt_window_t));
+ MuttIndexWindow->rows = LINES - MuttStatusWindow->rows - MuttHelpWindow->rows -
+ MuttMessageWindow->rows;
+ MuttIndexWindow->row_offset = option (OPTSTATUSONTOP) ? MuttStatusWindow->rows :
+ MuttHelpWindow->rows;
+
+#ifdef USE_SIDEBAR
+ if (option (OPTSIDEBAR))
+ {
+ memcpy (MuttSidebarWindow, MuttIndexWindow, sizeof (mutt_window_t));
+ MuttSidebarWindow->cols = SidebarWidth;
+
+ MuttIndexWindow->cols -= SidebarWidth;
+ MuttIndexWindow->col_offset += SidebarWidth;
+ }
+#endif
+}
+
+int mutt_window_move (mutt_window_t *win, int row, int col)
+{
+ return move (win->row_offset + row, win->col_offset + col);
+}
+
+int mutt_window_mvaddch (mutt_window_t *win, int row, int col, const chtype ch)
+{
+ return mvaddch (win->row_offset + row, win->col_offset + col, ch);
+}
+
+int mutt_window_mvaddstr (mutt_window_t *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 (mutt_window_t *win, int row, int col, const char *fmt, ...)
+{
+ va_list ap;
+ int rv;
+
+ if ((rv = mutt_window_move (win, row, col) != ERR))
+ {
+ va_start (ap, fmt);
+ rv = vw_printw (stdscr, fmt, ap);
+ va_end (ap);
+ }
+
+ return rv;
+}
+
+/* Assumes the cursor has already been positioned within the
+ * window.
+ */
+void mutt_window_clrtoeol (mutt_window_t *win)
+{
+ int row, col, curcol;
+
+ if (win->col_offset + win->cols == COLS)
+ clrtoeol ();
+ else
+ {
+ getyx (stdscr, row, col);
+ curcol = col;
+ while (curcol < win->col_offset + win->cols)
+ {
+ addch (' ');
+ curcol++;
+ }
+ move (row, col);
+ }
+}
+
+void mutt_window_clearline (mutt_window_t *win, int row)
+{
+ mutt_window_move (win, row, 0);
+ mutt_window_clrtoeol (win);
+}
+
+/* Assumes the current position is inside the window.
+ * Otherwise it will happily return negative or values outside
+ * the window boundaries
+ */
+void mutt_window_getyx (mutt_window_t *win, int *y, int *x)
+{
+ int row, col;
+
+ getyx (stdscr, row, col);
+ *y = row - win->row_offset;
+ *x = col - win->col_offset;
+}
+
+
void mutt_show_error (void)
{
if (option (OPTKEEPQUIET))
#define R_RESORT_SUB (1<<3) /* resort subthreads */
#define R_RESORT_INIT (1<<4) /* resort from scratch */
#define R_TREE (1<<5) /* redraw the thread tree */
+#define R_REFLOW (1<<6) /* reflow window layout */
#define R_BOTH (R_INDEX | R_PAGER)
#define R_RESORT_BOTH (R_RESORT | R_RESORT_SUB)
*/
#endif /* HAVE_GDBM || HAVE_DB4 */
#endif /* USE_HCACHE */
- { "help", DT_BOOL, R_BOTH, OPTHELP, 1 },
+ { "help", DT_BOOL, R_BOTH|R_REFLOW, OPTHELP, 1 },
/*
** .pp
** When \fIset\fP, help lines describing the bindings for the major functions
** will replace any dots in the expansion by underscores. This might be helpful
** with IMAP folders that don't like dots in folder names.
*/
- { "status_on_top", DT_BOOL, R_BOTH, OPTSTATUSONTOP, 0 },
+ { "status_on_top", DT_BOOL, R_BOTH|R_REFLOW, OPTSTATUSONTOP, 0 },
/*
** .pp
** Setting this variable causes the ``status bar'' to be displayed on
* was initialized with positive size, otherwise no percentage is shown */
void mutt_progress_update (progress_t* progress, long pos, int percent);
+/* Windows for different parts of the screen */
+typedef struct
+{
+ int rows;
+ int cols;
+ int row_offset;
+ int col_offset;
+} mutt_window_t;
+
+extern mutt_window_t *MuttHelpWindow;
+extern mutt_window_t *MuttIndexWindow;
+extern mutt_window_t *MuttStatusWindow;
+extern mutt_window_t *MuttMessageWindow;
+#ifdef USE_SIDEBAR
+extern mutt_window_t *MuttSidebarWindow;
+#endif
+
+void mutt_init_windows (void);
+void mutt_free_windows (void);
+void mutt_reflow_windows (void);
+int mutt_window_move (mutt_window_t *, int row, int col);
+int mutt_window_mvaddch (mutt_window_t *, int row, int col, const chtype ch);
+int mutt_window_mvaddstr (mutt_window_t *, int row, int col, const char *str);
+int mutt_window_mvprintw (mutt_window_t *, int row, int col, const char *fmt, ...);
+void mutt_window_clrtoeol (mutt_window_t *);
+void mutt_window_clearline (mutt_window_t *, int row);
+void mutt_window_getyx (mutt_window_t *, int *y, int *x);
+
+
static inline int mutt_term_width(short wrap)
{
if (wrap < 0)