changeset: 7040:3fd8c4af4658 user: Kevin McCarthy <ke...@8t8.us> date: Tue May 09 16:07:42 2017 -0700 link: http://dev.mutt.org/hg/mutt/rev/3fd8c4af4658
Rename REDRAW_SIGWINCH to REDRAW_FLOW. The next patch will attach this redraw flag to pager settings. The former name becomes somewhat confusing with the expanded usage, so rename it to something more relevant to what is being redrawn. changeset: 7041:7f95b4c993b2 user: Kevin McCarthy <ke...@8t8.us> date: Tue May 09 16:07:46 2017 -0700 link: http://dev.mutt.org/hg/mutt/rev/7f95b4c993b2 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. diffs (261 lines): diff -r 92d9db08a35e -r 7f95b4c993b2 curs_lib.c --- a/curs_lib.c Mon May 08 18:48:25 2017 -0700 +++ b/curs_lib.c Tue May 09 16:07:46 2017 -0700 @@ -608,7 +608,7 @@ mutt_set_current_menu_redraw_full (); /* the pager menu needs this flag set to recalc lineInfo */ - mutt_set_current_menu_redraw (REDRAW_SIGWINCH); + mutt_set_current_menu_redraw (REDRAW_FLOW); } static void reflow_message_window_rows (int mw_rows) @@ -629,7 +629,7 @@ MuttSidebarWindow->rows = MuttIndexWindow->rows; #endif - /* We don't also set REDRAW_SIGWINCH because this function only + /* We don't also set REDRAW_FLOW because this function only * changes rows and is a temporary adjustment. */ mutt_set_current_menu_redraw_full (); } diff -r 92d9db08a35e -r 7f95b4c993b2 init.c --- a/init.c Mon May 08 18:48:25 2017 -0700 +++ b/init.c Tue May 09 16:07:46 2017 -0700 @@ -1797,6 +1797,11 @@ 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) @@ -2580,6 +2585,11 @@ 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 -r 92d9db08a35e -r 7f95b4c993b2 init.h --- a/init.h Mon May 08 18:48:25 2017 -0700 +++ b/init.h Tue May 09 16:07:46 2017 -0700 @@ -59,13 +59,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) @@ -1007,7 +1008,7 @@ */ #endif /* HAVE_GDBM || HAVE_DB4 */ #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: @@ -1518,7 +1519,7 @@ ** 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 @@ -2911,7 +2912,7 @@ ** 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 -r 92d9db08a35e -r 7f95b4c993b2 menu.c --- a/menu.c Mon May 08 18:48:25 2017 -0700 +++ b/menu.c Tue May 09 16:07:46 2017 -0700 @@ -792,6 +792,12 @@ 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 -r 92d9db08a35e -r 7f95b4c993b2 mutt_menu.h --- a/mutt_menu.h Mon May 08 18:48:25 2017 -0700 +++ b/mutt_menu.h Tue May 09 16:07:46 2017 -0700 @@ -34,7 +34,7 @@ #define REDRAW_STATUS (1<<4) #define REDRAW_FULL (1<<5) #define REDRAW_BODY (1<<6) -#define REDRAW_SIGWINCH (1<<7) +#define REDRAW_FLOW (1<<7) /* Used by pager to reflow text */ #ifdef USE_SIDEBAR #define REDRAW_SIDEBAR (1<<8) #endif @@ -128,6 +128,7 @@ void mutt_pop_current_menu (MUTTMENU *); void mutt_set_current_menu_redraw (int); void mutt_set_current_menu_redraw_full (); +void mutt_set_menu_redraw (int, int); void mutt_set_menu_redraw_full (int); void mutt_current_menu_redraw (void); int mutt_menuLoop (MUTTMENU *); diff -r 92d9db08a35e -r 7f95b4c993b2 pager.c --- a/pager.c Mon May 08 18:48:25 2017 -0700 +++ b/pager.c Tue May 09 16:07:46 2017 -0700 @@ -1703,7 +1703,7 @@ rd->SearchBack = Resize->SearchBack; } rd->lines = Resize->line; - pager_menu->redraw |= REDRAW_SIGWINCH; + pager_menu->redraw |= REDRAW_FLOW; FREE (&Resize); } @@ -1745,7 +1745,7 @@ mutt_show_error (); } - if (pager_menu->redraw & REDRAW_SIGWINCH) + if (pager_menu->redraw & REDRAW_FLOW) { if (!(rd->flags & MUTT_PAGER_RETWINCH)) { @@ -1905,10 +1905,9 @@ 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 @@ -2045,7 +2044,7 @@ else { /* note: mutt_resize_screen() -> mutt_reflow_windows() sets - * REDRAW_FULL and REDRAW_SIGWINCH */ + * REDRAW_FULL and REDRAW_FLOW */ ch = 0; } continue; @@ -2562,8 +2561,6 @@ break; case OP_ENTER_COMMAND: - old_smart_wrap = option (OPTWRAP); - old_markers = option (OPTMARKERS); old_PagerIndexLines = PagerIndexLines; mutt_enter_command (); @@ -2581,65 +2578,16 @@ mutt_menuDestroy (&rd.index); rd.index = NULL; } - - if (option (OPTWRAP) != old_smart_wrap || - option (OPTMARKERS) != old_markers) - { - 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++; - } + if ((pager_menu->redraw & REDRAW_FLOW) && + (flags & MUTT_PAGER_RETWINCH)) + { + ch = -1; + rc = OP_REFORMAT_WINCH; + continue; + } - /* 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 = 0; break; case OP_FLAG_MESSAGE: