From 5dcac54e5db074dc4572f843666c7f7acaf2d109 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sun, 12 Aug 2007 00:20:39 +0200 Subject: [PATCH 1/1] Make the sidebar live in a proper independent window. This is the first patch of many to come, cleansing the noodle horror the UI code in mutt is (was ?). Signed-off-by: Pierre Habouzit --- globals.h | 1 - init.h | 18 --- lib-ui/CMakeLists.txt | 1 + lib-ui/curs_lib.c | 86 +------------ lib-ui/curs_main.c | 9 +- lib-ui/curses.h | 5 +- lib-ui/layout.c | 145 +++++++++++++++++++++ lib-ui/layout.h | 32 +++++ lib-ui/lib-ui.h | 1 + lib-ui/menu.c | 26 +--- lib-ui/sidebar.c | 289 ++++++++++++++++++------------------------ lib-ui/sidebar.h | 1 - main.c | 2 +- mutt.h | 1 - pager.c | 25 ++-- 15 files changed, 321 insertions(+), 321 deletions(-) create mode 100644 lib-ui/layout.c create mode 100644 lib-ui/layout.h diff --git a/globals.h b/globals.h index ee1a94a..36bab26 100644 --- a/globals.h +++ b/globals.h @@ -89,7 +89,6 @@ WHERE char *Prefix; WHERE char *PrintCmd; WHERE char *QueryCmd; WHERE char *Realname; -WHERE char *SidebarDelim; WHERE char *SidebarNumberFormat; WHERE char *SidebarBoundary; WHERE char *SignOffString; diff --git a/init.h b/init.h index 70ba04e..64e7db1 100644 --- a/init.h +++ b/init.h @@ -549,18 +549,6 @@ struct option_t MuttVars[] = { ** of the message you are replying to into the edit buffer. ** The ``$$weed'' setting applies. */ - {"help", DT_BOOL, R_BOTH, OPTHELP, "yes" }, - /* - ** .pp - ** When \fIset\fP, help lines describing the bindings for the major functions - ** provided by each menu are displayed on the first line of the screen. - ** .pp - ** \fBNote:\fP The binding will not be displayed correctly if the - ** function is bound to a sequence rather than a single keystroke. Also, - ** the help line may not be updated if a binding is changed while Madmutt is - ** running. Since this variable is primarily aimed at new users, neither - ** of these should present a major problem. - */ {"hidden_host", DT_BOOL, R_NONE, OPTHIDDENHOST, "no" }, /* ** .pp @@ -953,12 +941,6 @@ struct option_t MuttVars[] = { ** variable specifies the characters at which to split a folder name into ** ``hierarchy items.'' */ - {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"}, - /* - ** .pp - ** This specifies the delimiter between the sidebar (if visible) and - ** other screens. - */ {"sidebar_visible", DT_BOOL, R_BOTH, OPTMBOXPANE, "no" }, /* ** .pp diff --git a/lib-ui/CMakeLists.txt b/lib-ui/CMakeLists.txt index 25f259d..4b34247 100644 --- a/lib-ui/CMakeLists.txt +++ b/lib-ui/CMakeLists.txt @@ -6,6 +6,7 @@ ADD_LIBRARY(ui enter.c hdrline.c history.c + layout.c menu.c query.c sidebar.c diff --git a/lib-ui/curs_lib.c b/lib-ui/curs_lib.c index 8e15f53..babbc72 100644 --- a/lib-ui/curs_lib.c +++ b/lib-ui/curs_lib.c @@ -13,13 +13,8 @@ #include -#include -#ifdef HAVE_SYS_IOCTL_H -# include -#elif defined(HAVE_IOCTL_H) -# include -#endif #include +#include #include #include @@ -40,27 +35,6 @@ ssize_t UngetCount = 0; static ssize_t UngetBufLen = 0; static event_t *KeyEvent; -void mutt_refresh (void) -{ - /* don't refresh when we are waiting for a child. */ - if (option (OPTKEEPQUIET)) - return; - - /* don't refresh in the middle of macros unless necessary */ - if (UngetCount && !option (OPTFORCEREFRESH)) - return; - - /* else */ - wrefresh (stdscr); -} - -void mutt_need_hard_redraw (void) -{ - keypad (stdscr, TRUE); - clearok (stdscr, TRUE); - set_option (OPTNEEDREDRAW); -} - event_t mutt_getch (void) { int ch; @@ -326,30 +300,6 @@ void curses_initialize(void) meta(stdscr, TRUE); } -void curses_install(void) -{ - SETCOLOR(MT_COLOR_NORMAL); - wclear(stdscr); - mutt_error = mutt_curses_error; - mutt_message = mutt_curses_message; -} - -void mutt_endwin (const char *msg) -{ - if (!option (OPTNOCURSES)) { - CLEARLINE (LINES - 1); - - wattrset (stdscr, A_NORMAL); - mutt_refresh (); - endwin (); - } - - if (msg && *msg) { - puts (msg); - fflush (stdout); - } -} - void _mutt_perror (const char *s, const char* filename, int line) { char *p = strerror (errno); @@ -693,37 +643,3 @@ void mutt_paddstr (int n, const char *s) while (n-- > 0) waddch (stdscr, ' '); } - -/* this routine should be called after receiving SIGWINCH */ -void mutt_resize_screen (void) -{ - char *cp; - int fd; - struct winsize w; - - int rows, cols; - - rows = -1; - cols = -1; - if ((fd = open ("/dev/tty", O_RDONLY)) != -1) { - if (ioctl (fd, TIOCGWINSZ, &w) != -1) { - rows = w.ws_row; - cols = w.ws_col; - } - close (fd); - } - if (rows <= 0) { - if ((cp = getenv ("LINES")) != NULL) { - rows = atoi (cp); - } - else - rows = 24; - } - if (cols <= 0) { - if ((cp = getenv ("COLUMNS")) != NULL) - cols = atoi (cp); - else - cols = 80; - } - resizeterm (rows, cols); -} diff --git a/lib-ui/curs_main.c b/lib-ui/curs_main.c index fa8327b..3fe1cd3 100644 --- a/lib-ui/curs_main.c +++ b/lib-ui/curs_main.c @@ -499,7 +499,6 @@ int mutt_index_menu (void) if (menu->redraw & REDRAW_STATUS) { menu_status_line (buf, sizeof (buf), menu, NONULL (Status)); CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES - 2); - sidebar_draw_frames(); SETCOLOR (MT_COLOR_STATUS); BKGDSET (MT_COLOR_STATUS); wmove(stdscr, option (OPTSTATUSONTOP) ? 0 : LINES - 2,SW); @@ -531,16 +530,10 @@ int mutt_index_menu (void) if (SigWinch) { mutt_flushinp (); - mutt_resize_screen (); + ui_layout_resize(); menu->redraw = REDRAW_FULL; menu->menu = MENU_MAIN; - SigWinch = 0; menu->top = 0; /* so we scroll the right amount */ - /* - * force a real complete redraw. wclrtobot(stdscr) doesn't seem to be able - * to handle every case without this. - */ - clearok (stdscr, TRUE); continue; } diff --git a/lib-ui/curses.h b/lib-ui/curses.h index e8c6055..9f7f272 100644 --- a/lib-ui/curses.h +++ b/lib-ui/curses.h @@ -42,12 +42,8 @@ event_t mutt_getch (void); void curses_initialize(void); void curses_install(void); -void mutt_endwin (const char *); void mutt_flushinp (void); -void mutt_refresh (void); -void mutt_resize_screen (void); void mutt_ungetch (int, int); -void mutt_need_hard_redraw (void); /* ---------------------------------------------------------------------------- * Support for color @@ -155,6 +151,7 @@ void _mutt_make_string (char *, ssize_t, const char *, CONTEXT *, HEADER *, format_flag); +#define WSETCOLOR(w, X) wattrset(w, ColorDefs[X]) #define SETCOLOR(X) wattrset(stdscr, ColorDefs[X]) #define ADDCOLOR(X) wattron(stdscr, ColorDefs[X]) diff --git a/lib-ui/layout.c b/lib-ui/layout.c new file mode 100644 index 0000000..bb7abc3 --- /dev/null +++ b/lib-ui/layout.c @@ -0,0 +1,145 @@ +/* + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Copyright © 2006 Pierre Habouzit + */ + +#include + +#include +#ifdef HAVE_SYS_IOCTL_H +# include +#elif defined(HAVE_IOCTL_H) +# include +#endif + +static struct { + int rows, cols; + WINDOW *sidebar; + WINDOW *main; +} layout; + +void mutt_need_hard_redraw(void) +{ + keypad(stdscr, true); + clearok(stdscr, true); + set_option(OPTNEEDREDRAW); +} + +void mutt_refresh(void) +{ + /* don't refresh when we are waiting for a child. */ + if (option(OPTKEEPQUIET)) + return; + +#if 0 /* MC: WHY ? */ + /* don't refresh in the middle of macros unless necessary */ + if (UngetCount && !option(OPTFORCEREFRESH)) + return; +#endif + + /* else */ + wrefresh(stdscr); + if (layout.sidebar) + wrefresh(layout.sidebar); +} + +void mutt_endwin(const char *msg) +{ + if (!option(OPTNOCURSES)) { + CLEARLINE(LINES - 1); + + if (layout.sidebar) { + delwin(layout.sidebar); + layout.sidebar = NULL; + } + if (layout.main) { + delwin(layout.main); + layout.main = NULL; + } + + wattrset(stdscr, A_NORMAL); + mutt_refresh(); + endwin(); + } + + if (!m_strisempty(msg)) { + puts(msg); + fflush(stdout); + } +} + +void ui_layout_init(void) +{ + SETCOLOR(MT_COLOR_NORMAL); + wclear(stdscr); + mutt_error = mutt_curses_error; + mutt_message = mutt_curses_message; + + getmaxyx(stdscr, layout.rows, layout.cols); +} + +void ui_layout_resize(void) +{ + if (SigWinch) { + int fd; + 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; + } + close(fd); + } + if (layout.rows <= 0) { + layout.rows = atoi(getenv("LINES") ?: "24"); + } + if (layout.cols <= 0) { + layout.cols = atoi(getenv("COLUMNS") ?: "80"); + } + resizeterm(layout.rows, layout.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) + { + int sw, sh; + + if (!layout.sidebar) { + layout.sidebar = newwin(layout.rows - 1, SidebarWidth, 0, 0); + } + + getmaxyx(layout.sidebar, sh, sw); + + if (sh != layout.rows - 1 || sw != SidebarWidth) { + wresize(layout.sidebar, layout.rows - 1, SidebarWidth); + } + } else { + if (layout.sidebar) { + delwin(layout.sidebar); + layout.sidebar = NULL; + } + } + return layout.sidebar; +} diff --git a/lib-ui/layout.h b/lib-ui/layout.h new file mode 100644 index 0000000..7bc2161 --- /dev/null +++ b/lib-ui/layout.h @@ -0,0 +1,32 @@ +/* + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Copyright © 2006 Pierre Habouzit + */ + +#ifndef MUTT_LIB_UI_LAYOUT_H +#define MUTT_LIB_UI_LAYOUT_H + +void ui_layout_init(void); +void ui_layout_resize(void); + +WINDOW *ui_layout_sidebar_w(void); + +void mutt_need_hard_redraw(void); +void mutt_refresh(void); +void mutt_endwin(const char *); + +#endif diff --git a/lib-ui/lib-ui.h b/lib-ui/lib-ui.h index c08b293..31ad572 100644 --- a/lib-ui/lib-ui.h +++ b/lib-ui/lib-ui.h @@ -33,5 +33,6 @@ #endif #include "curses.h" +#include "layout.h" #endif diff --git a/lib-ui/menu.c b/lib-ui/menu.c index 0371dbc..0a1d716 100644 --- a/lib-ui/menu.c +++ b/lib-ui/menu.c @@ -118,21 +118,12 @@ void menu_redraw_full (MUTTMENU * menu) wmove (stdscr, 0, 0); wclrtobot (stdscr); - if (option (OPTHELP)) { - SETCOLOR (MT_COLOR_STATUS); - wmove (stdscr, option (OPTSTATUSONTOP) ? LINES - 2 : 0, SW); - mutt_paddstr (COLS-SW, ""); - SETCOLOR (MT_COLOR_NORMAL); - menu->offset = 1; - menu->pagelen = LINES - 3; - } - else { - menu->offset = option (OPTSTATUSONTOP) ? 1 : 0; - menu->pagelen = LINES - 2; - } - - sidebar_draw_frames(); - + SETCOLOR (MT_COLOR_STATUS); + wmove (stdscr, option (OPTSTATUSONTOP) ? LINES - 2 : 0, SW); + mutt_paddstr (COLS-SW, ""); + SETCOLOR (MT_COLOR_NORMAL); + menu->offset = 1; + menu->pagelen = LINES - 3; mutt_show_error (); menu->redraw = REDRAW_INDEX | REDRAW_STATUS; @@ -148,7 +139,6 @@ void menu_redraw_status (MUTTMENU * menu) mutt_paddstr (COLS-SW, buf); SETCOLOR (MT_COLOR_NORMAL); menu->redraw &= ~REDRAW_STATUS; - sidebar_draw_frames(); } void menu_redraw_index (MUTTMENU * menu) @@ -747,10 +737,8 @@ int mutt_menuLoop (MUTTMENU * menu) mutt_curs_set (1); if (SigWinch) { - mutt_resize_screen (); + ui_layout_resize(); menu->redraw = REDRAW_FULL; - SigWinch = 0; - clearok (stdscr, TRUE); /*force complete redraw */ } if (i == -1) diff --git a/lib-ui/sidebar.c b/lib-ui/sidebar.c index 238a5dd..6ba8471 100644 --- a/lib-ui/sidebar.c +++ b/lib-ui/sidebar.c @@ -25,31 +25,32 @@ static int TopBuffy = 0; static int CurBuffy = 0; -static int known_lines = 0; static short initialized = 0; static short prev_show_value; /* computes first entry to be shown */ -static void calc_boundaries (void) { - if (!Incoming.len) - return; - if (CurBuffy < 0 || CurBuffy >= Incoming.len) - CurBuffy = 0; - if (TopBuffy < 0 || TopBuffy >= Incoming.len) - TopBuffy = 0; - - if (option (OPTSIDEBARNEWMAILONLY)) { - int i = CurBuffy; - TopBuffy = CurBuffy - 1; - while (i >= 0) { - if (Incoming.arr[i]->new > 0) - TopBuffy = i; - i--; +static void calc_boundaries(void) +{ + if (!Incoming.len) + return; + if (CurBuffy < 0 || CurBuffy >= Incoming.len) + CurBuffy = 0; + if (TopBuffy < 0 || TopBuffy >= Incoming.len) + TopBuffy = 0; + + if (option (OPTSIDEBARNEWMAILONLY)) { + int i = CurBuffy; + TopBuffy = CurBuffy - 1; + while (i >= 0) { + if (Incoming.arr[i]->new > 0) + TopBuffy = i; + i--; + } + } else { + TopBuffy = CurBuffy - (CurBuffy % (LINES - 3)); } - } else if (known_lines>0) - TopBuffy = CurBuffy - (CurBuffy % known_lines); - if (TopBuffy < 0) - TopBuffy = 0; + if (TopBuffy < 0) + TopBuffy = 0; } static char *shortened_hierarchy (char *hbox, int maxlen) @@ -169,11 +170,10 @@ sidebar_number_format(char* dest, ssize_t destlen, return src; } -int sidebar_need_count (void) { - if (!option (OPTMBOXPANE) || SidebarWidth == 0 || - !SidebarNumberFormat || !*SidebarNumberFormat) - return (0); - return (1); +int sidebar_need_count(void) +{ + return ui_layout_sidebar_w() + && !m_strisempty(SidebarNumberFormat); } /* print single item @@ -181,47 +181,46 @@ int sidebar_need_count (void) { * 0 item was not printed ('cause of $sidebar_newmail_only) * 1 item was printed */ -static int make_sidebar_entry (char* sbox, int idx, ssize_t len) +static int make_sidebar_entry(WINDOW *sw, char *sbox, int idx, ssize_t len) { - int shortened = 0, lencnt = 0; - char no[STRING], entry[STRING]; - int l_m = m_strlen(Maildir); - - if (SidebarWidth > COLS) - SidebarWidth = COLS; - - if (option (OPTSIDEBARNEWMAILONLY) && sbox && Context && Context->path && - m_strcmp(Context->path, sbox) && Incoming.arr[idx]->new == 0) - /* if $sidebar_newmail_only is set, don't display the - * box only if it's not the currently opened - * (i.e. always display the currently opened) */ - return 0; - - m_strformat(no, len, SidebarWidth, SidebarNumberFormat, sidebar_number_format, idx, 0); - lencnt = m_strlen(no); - - if (l_m > 0 && m_strncmp(sbox, Maildir, l_m) == 0 && - m_strlen(sbox) > l_m) { - sbox += l_m; - if (Maildir[strlen(Maildir)-1]!='/') { - sbox += 1; + int shortened = 0, lencnt = 0; + char no[STRING], entry[STRING]; + int l_m = m_strlen(Maildir); + + if (option(OPTSIDEBARNEWMAILONLY) && sbox && Context && Context->path && + m_strcmp(Context->path, sbox) && Incoming.arr[idx]->new == 0) + /* if $sidebar_newmail_only is set, don't display the + * box only if it's not the currently opened + * (i.e. always display the currently opened) */ + return 0; + + m_strformat(no, sizeof(no), len, SidebarNumberFormat, + sidebar_number_format, idx, 0); + lencnt = m_strlen(no); + + if (l_m > 0 && m_strncmp(sbox, Maildir, l_m) == 0 && + m_strlen(sbox) > l_m) { + sbox += l_m; + if (Maildir[strlen(Maildir)-1]!='/') { + sbox += 1; + } + } else { + sbox = basename(sbox); } - } else - sbox = basename (sbox); - if (option(OPTSHORTENHIERARCHY) && m_strlen(sbox) > len-lencnt-1) { - sbox = shortened_hierarchy (sbox, len-lencnt-1); - shortened = 1; - } + if (option(OPTSHORTENHIERARCHY) && m_strlen(sbox) > len - lencnt) { + sbox = shortened_hierarchy(sbox, len - lencnt); + shortened = 1; + } - snprintf(entry, sizeof(entry), "%*s", (int)len, no); - memcpy(entry, sbox, MIN(len - 1, m_strlen(sbox))); - waddnstr(stdscr, entry, len); + snprintf(entry, sizeof(entry), "%*s", (int)len, no); + memcpy(entry, sbox, MIN(len, m_strlen(sbox))); + waddnstr(sw, entry, len); - if (shortened) - p_delete(&sbox); + if (shortened) + p_delete(&sbox); - return 1; + return 1; } /* returns folder name of currently @@ -257,124 +256,80 @@ void sidebar_set_buffystats (CONTEXT* curContext) { tmp->msg_flagged = curContext->flagged; } -void sidebar_draw_frames (void) { - ssize_t i,delim_len; - - if (!option(OPTMBOXPANE) || SidebarWidth==0) - return; - - delim_len=m_strlen(NONULL(SidebarDelim)); - - /* draw vertical delimiter */ - SETCOLOR (MT_COLOR_SIDEBAR); - for (i = 0; i < LINES-1; i++) { - wmove (stdscr, i, SidebarWidth - delim_len); - if (!m_strcmp(SidebarDelim, "|")) - waddch (stdscr, ACS_VLINE); - else - waddstr (stdscr, NONULL (SidebarDelim)); - } - - /* fill "gaps" at top+bottom */ - SETCOLOR(MT_COLOR_STATUS); - for (i=0; i 0 && option (OPTMBOXPANE) - && m_strlen(SidebarDelim) >= SidebarWidth) { - mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar.")); - sleep (2); - unset_option (OPTMBOXPANE); - return (0); - } + sw = ui_layout_sidebar_w(); + if (!sw) + return 0; + getmaxyx(sw, y, x); + + memset(&blank, ' ', sizeof(blank)); + + wmove(sw, 0, 0); + WSETCOLOR(sw, MT_COLOR_STATUS); + waddnstr(sw, blank, x); + + for (i = TopBuffy, line = 1; i < Incoming.len && line < y; i++) { + BUFFY *tmp = Incoming.arr[i]; + + if (i == CurBuffy) + WSETCOLOR(sw, MT_COLOR_INDICATOR); + else if (tmp->new > 0) + WSETCOLOR(sw, MT_COLOR_NEW); + else if (tmp->msg_flagged > 0) + WSETCOLOR(sw, MT_COLOR_FLAGGED); + else + WSETCOLOR(sw, MT_COLOR_NORMAL); + + if (make_sidebar_entry(sw, tmp->path, i, x - 1)) { + WSETCOLOR(sw, MT_COLOR_SIDEBAR); + waddch(sw, ACS_VLINE); + line++; + } + } - if (SidebarWidth == 0 || !option (OPTMBOXPANE)) - return 0; + while (line < y - 1) { + WSETCOLOR(sw, MT_COLOR_NORMAL); + waddnstr(sw, blank, x - 1); + WSETCOLOR(sw, MT_COLOR_SIDEBAR); + waddch(sw, ACS_VLINE); + line++; + } - sidebar_draw_frames(); + WSETCOLOR(sw, MT_COLOR_STATUS); + waddnstr(sw, blank, x); + WSETCOLOR(sw, MT_COLOR_NORMAL); - if (!Incoming.len) return 0; - - /* actually print items */ - for (i = TopBuffy, line=first_line; i < Incoming.len && line < last_line; i++) { - tmp = Incoming.arr[i]; - - if (i == CurBuffy) - SETCOLOR (MT_COLOR_INDICATOR); - else if (tmp->new > 0) - SETCOLOR (MT_COLOR_NEW); - else if (tmp->msg_flagged > 0) - SETCOLOR (MT_COLOR_FLAGGED); - else - SETCOLOR (MT_COLOR_NORMAL); - - wmove (stdscr, line, 0); - line += make_sidebar_entry (tmp->path, i, SidebarWidth-delim_len); - } - - SETCOLOR (MT_COLOR_NORMAL); - - /* fill with blanks to bottom */ - memset(&blank, ' ', sizeof(blank)); - for (; line < last_line; line++) { - wmove (stdscr, line, 0); - waddnstr (stdscr, blank, SidebarWidth-delim_len); - } - return 0; } /* returns index of new item with new mail or -1 */ -static int exist_next_new () { +static int exist_next_new (void) { int i = 0; if (!Incoming.len) return (-1); @@ -386,7 +341,7 @@ static int exist_next_new () { } /* returns index of prev item with new mail or -1 */ -static int exist_prev_new () { +static int exist_prev_new (void) { int i = 0; if (!Incoming.len) return (-1); @@ -444,7 +399,7 @@ void sidebar_scroll (int op) { mutt_error (_("You are on the first mailbox.")); return; } - CurBuffy -= known_lines; + CurBuffy -= LINES - 3; if (CurBuffy < 0) CurBuffy = 0; break; @@ -453,7 +408,7 @@ void sidebar_scroll (int op) { mutt_error (_("You are on the last mailbox.")); return; } - CurBuffy += known_lines; + CurBuffy += LINES - 3; if (CurBuffy >= Incoming.len) CurBuffy = Incoming.len - 1; break; diff --git a/lib-ui/sidebar.h b/lib-ui/sidebar.h index ffc53e2..b56f2bc 100644 --- a/lib-ui/sidebar.h +++ b/lib-ui/sidebar.h @@ -14,7 +14,6 @@ #include "mutt.h" /* because of CONTEXT :| */ int sidebar_draw (void); -void sidebar_draw_frames (void); void sidebar_scroll (int); void sidebar_set_buffystats (CONTEXT *); const char* sidebar_get_current (void); diff --git a/main.c b/main.c index 60c51bb..7be391f 100644 --- a/main.c +++ b/main.c @@ -453,7 +453,7 @@ int main (int argc, char **argv) mx_set_magic (newMagic); if (!option(OPTNOCURSES)) { - curses_install(); + ui_layout_init(); } /* Create the Maildir directory if it doesn't exist. */ diff --git a/mutt.h b/mutt.h index f12bf9b..24e174d 100644 --- a/mutt.h +++ b/mutt.h @@ -230,7 +230,6 @@ enum { OPTHCACHECOMPRESS, #endif OPTHEADER, - OPTHELP, OPTHIDDENHOST, OPTHIDELIMITED, OPTHIDEMISSING, diff --git a/pager.c b/pager.c index e7601db..12d86b7 100644 --- a/pager.c +++ b/pager.c @@ -1373,24 +1373,18 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) bodyoffset = statusoffset + 1; helpoffset = LINES - 2; bodylen = helpoffset - bodyoffset; - if (!option (OPTHELP)) - bodylen++; } else { helpoffset = 0; indexoffset = 1; statusoffset = LINES - 2; - if (!option (OPTHELP)) - indexoffset = 0; bodyoffset = indexoffset + (IsHeader (extra) ? indexlen : 0); bodylen = statusoffset - bodyoffset; } - if (option (OPTHELP)) { - SETCOLOR (MT_COLOR_STATUS); - wmove (stdscr, helpoffset, SW); - mutt_paddstr (COLS-SW, ""); - SETCOLOR (MT_COLOR_NORMAL); - } + SETCOLOR (MT_COLOR_STATUS); + wmove (stdscr, helpoffset, SW); + mutt_paddstr (COLS-SW, ""); + SETCOLOR (MT_COLOR_NORMAL); if (Resize != NULL) { if ((SearchCompiled = Resize->SearchCompiled)) { @@ -1573,8 +1567,9 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) mutt_query_exit (); continue; } - else if (SigWinch) { - mutt_resize_screen (); + + if (SigWinch) { + ui_layout_resize(); /* Store current position. */ lines = -1; @@ -1611,12 +1606,10 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) redraw = REDRAW_FULL | REDRAW_SIGWINCH; ch = 0; } - - SigWinch = 0; - clearok (stdscr, TRUE); /*force complete redraw */ continue; } - else if (ch == -1) { + + if (ch == -1) { ch = 0; continue; } -- 2.20.1