diff options
author | Kevin McCarthy <kevin@8t8.us> | 2022-09-19 18:41:48 +0800 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2022-10-08 12:37:58 -0700 |
commit | 925a292766f32afadd1496871964348223657335 (patch) | |
tree | 15475471002fd8ccca325d525534005b2211caee | |
parent | e43a42bfdbdbd968f15dbdf00bf6c04bedcf1ca3 (diff) |
Move SigWinch handling before refresh in menus.
This will prevent an unneeded double-refresh after an endwin() when we
set SigWinch in the next commit.
In the pager, change RETWINCH handling to account for a sigwinch while
in the handler. Previously a redraw would occur and use/free the
Resize data, but since the SigWinch check now occurs before the
redraw, keep existing data.
-rw-r--r-- | curs_main.c | 35 | ||||
-rw-r--r-- | menu.c | 24 | ||||
-rw-r--r-- | pager.c | 72 |
3 files changed, 72 insertions, 59 deletions
diff --git a/curs_main.c b/curs_main.c index 94df2037..34b327aa 100644 --- a/curs_main.c +++ b/curs_main.c @@ -784,6 +784,26 @@ int mutt_index_menu (void) if (!in_pager) { + +#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM) + while (SigWinch) + { + do + { + SigWinch = 0; + mutt_resize_screen (); + } + while (SigWinch); + + menu->top = 0; /* so we scroll the right amount */ + /* + * force a real complete redraw. clrtobot() doesn't seem to be able + * to handle every case without this. + */ + clearok(stdscr,TRUE); + } +#endif + index_menu_redraw (menu); /* give visual indication that the next command is a tag- command */ @@ -807,21 +827,6 @@ int mutt_index_menu (void) MuttIndexWindow->cols - 1); mutt_refresh (); -#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM) - if (SigWinch) - { - SigWinch = 0; - mutt_resize_screen (); - menu->top = 0; /* so we scroll the right amount */ - /* - * force a real complete redraw. clrtobot() doesn't seem to be able - * to handle every case without this. - */ - clearok(stdscr,TRUE); - continue; - } -#endif - op = km_dokey (MENU_MAIN); dprint(4, (debugfile, "mutt_index_menu[%d]: Got op %d\n", __LINE__, op)); @@ -1047,6 +1047,20 @@ int mutt_menuLoop (MUTTMENU *menu) mutt_curs_set (0); +#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM) + if (SigWinch) + { + do + { + SigWinch = 0; + mutt_resize_screen (); + } + while (SigWinch); + + clearok(stdscr,TRUE);/*force complete redraw*/ + } +#endif + if (menu->custom_menu_update) menu->custom_menu_update (menu); @@ -1074,16 +1088,6 @@ int mutt_menuLoop (MUTTMENU *menu) mutt_refresh (); -#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM) - if (SigWinch) - { - SigWinch = 0; - mutt_resize_screen (); - clearok(stdscr,TRUE);/*force complete redraw*/ - continue; - } -#endif - /* try to catch dialog keys before ops */ if (menu->dialog && menu_dialog_dokey (menu, &i) == 0) return i; @@ -2161,6 +2161,44 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) { mutt_curs_set (0); +#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM) + if (SigWinch) + { + do + { + SigWinch = 0; + mutt_resize_screen (); + } + while (SigWinch); + + clearok(stdscr,TRUE);/*force complete redraw*/ + + if (flags & MUTT_PAGER_RETWINCH) + { + /* A SigWinch could occur while in the RETWINCH handler, so + * just keep the previously stored values */ + if (!Resize) + { + /* Store current position. */ + rd.lines = -1; + for (i = 0; i <= rd.topline; i++) + if (!rd.lineInfo[i].continuation) + rd.lines++; + + Resize = safe_malloc (sizeof (struct resize)); + + Resize->line = rd.lines; + Resize->SearchCompiled = rd.SearchCompiled; + Resize->SearchBack = rd.SearchBack; + } + + ch = -1; + rc = OP_REFORMAT_WINCH; + continue; + } + } +#endif + pager_menu_redraw (pager_menu); if (option(OPTBRAILLEFRIENDLY)) @@ -2188,40 +2226,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) else OldHdr = NULL; -#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM) - if (SigWinch) - { - SigWinch = 0; - mutt_resize_screen (); - clearok(stdscr,TRUE);/*force complete redraw*/ - - if (flags & MUTT_PAGER_RETWINCH) - { - /* Store current position. */ - rd.lines = -1; - for (i = 0; i <= rd.topline; i++) - if (!rd.lineInfo[i].continuation) - rd.lines++; - - Resize = safe_malloc (sizeof (struct resize)); - - Resize->line = rd.lines; - Resize->SearchCompiled = rd.SearchCompiled; - Resize->SearchBack = rd.SearchBack; - - ch = -1; - rc = OP_REFORMAT_WINCH; - } - else - { - /* note: mutt_resize_screen() -> mutt_reflow_windows() sets - * REDRAW_FULL and REDRAW_FLOW */ - ch = 0; - } - continue; - } -#endif - ch = km_dokey (MENU_PAGER); if (ch >= 0) mutt_clear_error (); |