Index: src/browser.c =================================================================== --- src/browser.c (revision 5213) +++ src/browser.c (working copy) @@ -111,7 +111,11 @@ /* Display the file list if we don't have a key, or if the * selected file has changed, and set width in the process. */ - if (kbinput == ERR || old_selected != selected) + if (kbinput == ERR || +#ifndef NANO_TINY + kbinput == KEY_WINCH || +#endif + old_selected != selected) browser_refresh(); old_selected = selected; @@ -118,6 +122,13 @@ kbinput = get_kbinput(edit); +#ifndef NANO_TINY + if (kbinput == KEY_WINCH) { + curs_set(0); + continue; + } +#endif + #ifndef DISABLE_MOUSE if (kbinput == KEY_MOUSE) { int mouse_x, mouse_y; Index: src/global.c =================================================================== --- src/global.c (revision 5213) +++ src/global.c (working copy) @@ -30,12 +30,9 @@ /* Global variables. */ #ifndef NANO_TINY -sigjmp_buf jump_buf; - /* Used to return to either main() or the unjustify routine in - * do_justify() after a SIGWINCH. */ -bool jump_buf_main = FALSE; - /* Have we set jump_buf so that we return to main() after a - * SIGWINCH? */ +volatile sig_atomic_t sigwinch_flag = 0; + /* Used to indicate whether SIGWINCH handler has been executed + * or not */ #endif bool meta_key; Index: src/help.c =================================================================== --- src/help.c (revision 5213) +++ src/help.c (working copy) @@ -88,7 +88,12 @@ /* Display the help text if we don't have a key, or if the help * text has moved. */ - if (kbinput == ERR || line != old_line) { + if (kbinput == ERR || +#ifndef NANO_TINY + kbinput == KEY_WINCH || +#endif + line != old_line) { + blank_edit(); ptr = help_text; @@ -117,6 +122,13 @@ kbinput = get_kbinput(edit); +#ifndef NANO_TINY + if (kbinput == KEY_WINCH) { + curs_set(0); + continue; + } +#endif + #ifndef DISABLE_MOUSE if (kbinput == KEY_MOUSE) { int mouse_x, mouse_y; Index: src/nano.c =================================================================== --- src/nano.c (revision 5213) +++ src/nano.c (working copy) @@ -1406,14 +1406,10 @@ window_init(); /* Redraw the contents of the windows that need it. */ - blank_statusbar(); - wnoutrefresh(bottomwin); - currmenu = MMAIN; total_refresh(); - /* Jump back to either main() or the unjustify routine in - * do_justify(). */ - siglongjmp(jump_buf, 1); + /* Let the others know the handler has been executed */ + sigwinch_flag = sigwinch_flag ? 0 : 1; } /* If allow is TRUE, block any SIGWINCH signals that we get, so that we @@ -1608,6 +1604,12 @@ /* Read in a character. */ input = get_kbinput(edit); +#ifndef NANO_TINY + if (input == KEY_WINCH) { + return KEY_WINCH; + } +#endif + #ifndef DISABLE_MOUSE if (func_key && input == KEY_MOUSE) { /* We received a mouse click. */ @@ -2807,17 +2809,6 @@ reset_cursor(); wnoutrefresh(edit); -#ifndef NANO_TINY - if (!jump_buf_main) { - /* If we haven't already, we're going to set jump_buf so - * that we return here after a SIGWINCH. Indicate this. */ - jump_buf_main = TRUE; - - /* Return here after a SIGWINCH. */ - sigsetjmp(jump_buf, 1); - } -#endif - /* Just in case we were at the statusbar prompt, make sure the * statusbar cursor position is reset. */ do_prompt_abort(); Index: src/nano.h =================================================================== --- src/nano.h (revision 5213) +++ src/nano.h (working copy) @@ -571,6 +571,11 @@ #define CONTROL_RIGHT 554 +#ifndef NANO_TINY +/* An imaginary key we return to caller when we get SIGWINCH */ +#define KEY_WINCH -2 +#endif + #ifndef NANO_TINY /* Extra bits for the undo function. */ #define UNdel_del (1<<0) #define UNdel_backspace (1<<1) Index: src/prompt.c =================================================================== --- src/prompt.c (revision 5213) +++ src/prompt.c (working copy) @@ -66,6 +66,12 @@ /* Read in a character. */ input = get_kbinput(bottomwin); +#ifndef NANO_TINY + if (input == KEY_WINCH) { + return KEY_WINCH; + } +#endif + #ifndef DISABLE_MOUSE /* If we got a mouse click and it was on a shortcut, read in the * shortcut character. */ @@ -794,6 +800,13 @@ kbinput = do_statusbar_input(&ran_func, &finished, refresh_func); assert(statusbar_x <= strlen(answer)); +#ifndef NANO_TINY + if (kbinput == KEY_WINCH) { + update_statusbar_line(answer, statusbar_x); + continue; + } +#endif + func = func_from_key(&kbinput); if (func == do_cancel || func == do_enter_void) @@ -1055,58 +1068,65 @@ nostr = _("Nn"); allstr = _("Aa"); - if (!ISSET(NO_HELP)) { - char shortstr[3]; + do { + int kbinput; + functionptrtype func; +#ifndef DISABLE_MOUSE + int mouse_x, mouse_y; +#endif + + if (!ISSET(NO_HELP)) { + char shortstr[3]; /* Temp string for Yes, No, All. */ - if (COLS < 32) - width = COLS / 2; + if (COLS < 32) + width = COLS / 2; - /* Clear the shortcut list from the bottom of the screen. */ - blank_bottombars(); + /* Clear the shortcut list from the bottom of the screen. */ + blank_bottombars(); - sprintf(shortstr, " %c", yesstr[0]); - wmove(bottomwin, 1, 0); - onekey(shortstr, _("Yes"), width); + sprintf(shortstr, " %c", yesstr[0]); + wmove(bottomwin, 1, 0); + onekey(shortstr, _("Yes"), width); - if (all) { - wmove(bottomwin, 1, width); - shortstr[1] = allstr[0]; - onekey(shortstr, _("All"), width); - } + if (all) { + wmove(bottomwin, 1, width); + shortstr[1] = allstr[0]; + onekey(shortstr, _("All"), width); + } - wmove(bottomwin, 2, 0); - shortstr[1] = nostr[0]; - onekey(shortstr, _("No"), width); + wmove(bottomwin, 2, 0); + shortstr[1] = nostr[0]; + onekey(shortstr, _("No"), width); - wmove(bottomwin, 2, 16); - onekey("^C", _("Cancel"), width); - } + wmove(bottomwin, 2, 16); + onekey("^C", _("Cancel"), width); + } - if (interface_color_pair[TITLE_BAR].bright) - wattron(bottomwin, A_BOLD); - wattron(bottomwin, interface_color_pair[TITLE_BAR].pairnum); + if (interface_color_pair[TITLE_BAR].bright) + wattron(bottomwin, A_BOLD); + wattron(bottomwin, interface_color_pair[TITLE_BAR].pairnum); - blank_statusbar(); - mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1)); + blank_statusbar(); + mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1)); - wattroff(bottomwin, A_BOLD); - wattroff(bottomwin, interface_color_pair[TITLE_BAR].pairnum); + wattroff(bottomwin, A_BOLD); + wattroff(bottomwin, interface_color_pair[TITLE_BAR].pairnum); - /* Refresh the edit window and the statusbar before getting - * input. */ - wnoutrefresh(edit); - wnoutrefresh(bottomwin); + /* Refresh the edit window and the statusbar before getting + * input. */ + wnoutrefresh(edit); + wnoutrefresh(bottomwin); - do { - int kbinput; - functionptrtype func; -#ifndef DISABLE_MOUSE - int mouse_x, mouse_y; + currmenu = MYESNO; + kbinput = get_kbinput(bottomwin); + +#ifndef NANO_TINY + if (kbinput == KEY_WINCH) { + continue; + } #endif - currmenu = MYESNO; - kbinput = get_kbinput(bottomwin); func = func_from_key(&kbinput); if (func == do_cancel) Index: src/proto.h =================================================================== --- src/proto.h (revision 5213) +++ src/proto.h (working copy) @@ -28,8 +28,7 @@ /* All external variables. See global.c for their descriptions. */ #ifndef NANO_TINY -extern sigjmp_buf jump_buf; -extern bool jump_buf_main; +extern volatile sig_atomic_t sigwinch_flag; #endif extern bool meta_key; Index: src/text.c =================================================================== --- src/text.c (revision 5213) +++ src/text.c (working copy) @@ -2207,15 +2207,6 @@ edit_refresh(); -#ifndef NANO_TINY - /* We're going to set jump_buf so that we return here after a - * SIGWINCH instead of to main(). Indicate this. */ - jump_buf_main = FALSE; - - /* Return here after a SIGWINCH. */ - sigsetjmp(jump_buf, 1); -#endif - statusbar(_("Can now UnJustify!")); /* If constant cursor position display is on, make sure the current @@ -3184,6 +3175,13 @@ } kbinput = get_kbinput(bottomwin); + +#ifndef NANO_TINY + if (kbinput == KEY_WINCH) { + continue; + } +#endif + func = func_from_key(&kbinput); tmplint = curlint; Index: src/winio.c =================================================================== --- src/winio.c (revision 5213) +++ src/winio.c (working copy) @@ -107,6 +107,9 @@ { int input; size_t errcount; +#ifndef NANO_TINY + sig_atomic_t sigwinch_flag_save; +#endif /* If the keystroke buffer isn't empty, get out. */ if (key_buffer != NULL) @@ -122,11 +125,21 @@ /* Read in the first character using whatever mode we're in. */ errcount = 0; +#ifndef NANO_TINY + sigwinch_flag_save = sigwinch_flag; +#endif if (nodelay_mode) { if ((input = wgetch(win)) == ERR) return; } else while ((input = wgetch(win)) == ERR) { +#ifndef NANO_TINY + /* Did we get SIGWINCH while we were in blocking mode? */ + if (sigwinch_flag != sigwinch_flag_save) { + input = KEY_WINCH; + break; + } else +#endif errcount++; /* If we've failed to get a character MAX_BUF_SIZE times in a @@ -148,6 +161,13 @@ key_buffer = (int *)nmalloc(sizeof(int)); key_buffer[0] = input; +#ifndef NANO_TINY + /* If we got SIGWINCH, get out immediately since win argument is + * no longer valid */ + if (sigwinch_flag != sigwinch_flag_save) + return; +#endif + /* Read in the remaining characters using non-blocking input. */ nodelay(win, TRUE); @@ -643,6 +663,12 @@ retval = sc_seq_or(do_next_word_void, 0); #endif break; + +#ifndef NANO_TINY + case KEY_WINCH: + retval = KEY_WINCH; + break; +#endif } /* If our result is an extended keypad value (i.e. a value