From: Kevin McCarthy Date: Tue, 9 May 2017 23:07:46 +0000 (-0700) Subject: Create R_PAGER_FLOW config variable flag. X-Git-Tag: neomutt-20170526~26^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=385ba3032f349cdc78ecfc7f6c19eba0fddedeff;p=neomutt Create R_PAGER_FLOW config variable flag. Use this for $header_color_partial, $markers, and $smart_wrap. When these options are changed in the pager, this flag will force a recalculation of lineInfo. Remove the manual checks in OP_ENTER_COMMAND for $markers and $smart_wrap, and instead use the same REDRAW_FLOW processing used for a SigWinch. --- diff --git a/init.c b/init.c index 8fe1dc590..024f4e6ab 100644 --- a/init.c +++ b/init.c @@ -1999,6 +1999,11 @@ static void restore_default(struct option_t *p) mutt_set_menu_redraw_full(MENU_MAIN); if (p->flags & R_PAGER) mutt_set_menu_redraw_full(MENU_PAGER); + if (p->flags & R_PAGER_FLOW) + { + mutt_set_menu_redraw_full(MENU_PAGER); + mutt_set_menu_redraw(MENU_PAGER, REDRAW_FLOW); + } if (p->flags & R_RESORT_SUB) set_option(OPTSORTSUBTHREADS); if (p->flags & R_RESORT) @@ -2888,6 +2893,11 @@ static int parse_set(BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) mutt_set_menu_redraw_full(MENU_MAIN); if (MuttVars[idx].flags & R_PAGER) mutt_set_menu_redraw_full(MENU_PAGER); + if (MuttVars[idx].flags & R_PAGER_FLOW) + { + mutt_set_menu_redraw_full(MENU_PAGER); + mutt_set_menu_redraw(MENU_PAGER, REDRAW_FLOW); + } if (MuttVars[idx].flags & R_RESORT_SUB) set_option(OPTSORTSUBTHREADS); if (MuttVars[idx].flags & R_RESORT) diff --git a/init.h b/init.h index 4199d5c09..b78ae1322 100644 --- a/init.h +++ b/init.h @@ -46,13 +46,14 @@ #define R_NONE 0 #define R_INDEX (1 << 0) /* redraw the index menu (MENU_MAIN) */ #define R_PAGER (1 << 1) /* redraw the pager menu */ -#define R_RESORT (1 << 2) /* resort the mailbox */ -#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 and full redraw */ -#define R_SIDEBAR (1 << 7) /* redraw the sidebar */ -#define R_MENU (1 << 8) /* redraw all menus */ +#define R_PAGER_FLOW (1 << 2) /* reflow lineInfo and redraw the pager menu */ +#define R_RESORT (1 << 3) /* resort the mailbox */ +#define R_RESORT_SUB (1 << 4) /* resort subthreads */ +#define R_RESORT_INIT (1 << 5) /* resort from scratch */ +#define R_TREE (1 << 6) /* redraw the thread tree */ +#define R_REFLOW (1 << 7) /* reflow window layout and full redraw */ +#define R_SIDEBAR (1 << 8) /* redraw the sidebar */ +#define R_MENU (1 << 9) /* redraw all menus */ #define R_BOTH (R_INDEX | R_PAGER) #define R_RESORT_BOTH (R_RESORT | R_RESORT_SUB) @@ -1130,7 +1131,7 @@ struct option_t MuttVars[] = { */ #endif /* HAVE_GDBM || HAVE_BDB */ #endif /* USE_HCACHE */ - { "header_color_partial", DT_BOOL, R_PAGER | R_REFLOW, OPTHEADERCOLORPARTIAL, 0 }, + { "header_color_partial", DT_BOOL, R_PAGER_FLOW, OPTHEADERCOLORPARTIAL, 0 }, /* ** .pp ** When \fIset\fP, color header regexps behave like color body regexps: @@ -1705,7 +1706,7 @@ struct option_t MuttVars[] = { ** will show up with an ``O'' next to them in the index menu, ** indicating that they are old. */ - { "markers", DT_BOOL, R_PAGER, OPTMARKERS, 1 }, + { "markers", DT_BOOL, R_PAGER_FLOW, OPTMARKERS, 1 }, /* ** .pp ** Controls the display of wrapped lines in the internal pager. If set, a @@ -3343,7 +3344,7 @@ struct option_t MuttVars[] = { ** messages from the current folder. The default is to pause one second, so ** a value of zero for this option suppresses the pause. */ - { "smart_wrap", DT_BOOL, R_PAGER, OPTWRAP, 1 }, + { "smart_wrap", DT_BOOL, R_PAGER_FLOW, OPTWRAP, 1 }, /* ** .pp ** Controls the display of lines longer than the screen width in the diff --git a/menu.c b/menu.c index ac8423e3a..5bef50167 100644 --- a/menu.c +++ b/menu.c @@ -857,6 +857,12 @@ void mutt_set_current_menu_redraw_full(void) current_menu->redraw = REDRAW_FULL; } +void mutt_set_menu_redraw(int menu_type, int redraw) +{ + if (CurrentMenu == menu_type) + mutt_set_current_menu_redraw(redraw); +} + void mutt_set_menu_redraw_full(int menu_type) { if (CurrentMenu == menu_type) diff --git a/mutt_menu.h b/mutt_menu.h index 2f83b223b..0a82c1c68 100644 --- a/mutt_menu.h +++ b/mutt_menu.h @@ -127,7 +127,8 @@ void mutt_push_current_menu(MUTTMENU *); void mutt_pop_current_menu(MUTTMENU *); void mutt_set_current_menu_redraw(int redraw); void mutt_set_current_menu_redraw_full(void); -void mutt_set_menu_redraw_full(int); +void mutt_set_menu_redraw(int menu_type, int redraw); +void mutt_set_menu_redraw_full(int menu_type); void mutt_current_menu_redraw(void); int mutt_menu_loop(MUTTMENU *menu); diff --git a/pager.c b/pager.c index 720a9fc7f..1a1b8f1a7 100644 --- a/pager.c +++ b/pager.c @@ -1956,10 +1956,9 @@ int mutt_pager(const char *banner, const char *fname, int flags, pager_t *extra) char buffer[LONG_STRING]; char helpstr[SHORT_STRING * 2]; char tmphelp[SHORT_STRING * 2]; - int i, j, ch = 0, rc = -1; + int i, ch = 0, rc = -1; int err, first = 1; int r = -1, wrapped = 0, searchctx = 0; - int old_smart_wrap, old_markers; MUTTMENU *pager_menu = NULL; int old_PagerIndexLines; /* some people want to resize it @@ -2743,8 +2742,6 @@ int mutt_pager(const char *banner, const char *fname, int flags, pager_t *extra) break; case OP_ENTER_COMMAND: - old_smart_wrap = option(OPTWRAP); - old_markers = option(OPTMARKERS); old_PagerIndexLines = PagerIndexLines; mutt_enter_command(); @@ -2763,64 +2760,14 @@ int mutt_pager(const char *banner, const char *fname, int flags, pager_t *extra) rd.index = NULL; } - if (option(OPTWRAP) != old_smart_wrap || option(OPTMARKERS) != old_markers) + if ((pager_menu->redraw & REDRAW_FLOW) && (flags & MUTT_PAGER_RETWINCH)) { - if (flags & MUTT_PAGER_RETWINCH) - { - ch = -1; - rc = OP_REFORMAT_WINCH; - continue; - } - - /* count the real lines above */ - j = 0; - for (i = 0; i <= rd.topline; i++) - { - if (!rd.lineInfo[i].continuation) - j++; - } - - /* we need to restart the whole thing */ - for (i = 0; i < rd.maxLine; i++) - { - rd.lineInfo[i].offset = 0; - rd.lineInfo[i].type = -1; - rd.lineInfo[i].continuation = 0; - rd.lineInfo[i].chunks = 0; - rd.lineInfo[i].search_cnt = -1; - rd.lineInfo[i].quote = NULL; - - safe_realloc(&(rd.lineInfo[i].syntax), sizeof(struct syntax_t)); - if (rd.SearchCompiled && rd.lineInfo[i].search) - FREE(&(rd.lineInfo[i].search)); - } - - if (rd.SearchCompiled) - { - regfree(&rd.SearchRE); - rd.SearchCompiled = 0; - } - rd.SearchFlag = 0; - - /* try to keep the old position */ - rd.topline = 0; - rd.lastLine = 0; - while (j > 0 && - display_line(rd.fp, &rd.last_pos, &rd.lineInfo, rd.topline, - &rd.lastLine, &rd.maxLine, - (rd.has_types ? MUTT_TYPES : 0) | (flags & MUTT_PAGER_NOWRAP), - &rd.QuoteList, &rd.q_level, &rd.force_redraw, - &rd.SearchRE, rd.pager_window) == 0) - { - if (!rd.lineInfo[rd.topline].continuation) - j--; - if (j > 0) - rd.topline++; - } - - ch = 0; + ch = -1; + rc = OP_REFORMAT_WINCH; + continue; } + ch = 0; break; case OP_FLAG_MESSAGE: