diff --git a/src/global.c b/src/global.c index 77c8d8420955f4c34dc87ef42af09fefdef81e79..a24c373f5bc8a232c3ea4a672a67bac7f7a4c74a 100644 --- a/src/global.c +++ b/src/global.c @@ -29,8 +29,8 @@ /* Global variables. */ #ifndef NANO_TINY -volatile sig_atomic_t sigwinch_counter = 0; - /* Is incremented by the handler whenever a SIGWINCH occurs. */ +volatile sig_atomic_t the_window_resized = FALSE; + /* Set to TRUE by the handler whenever a SIGWINCH occurs. */ #endif #ifdef __linux__ diff --git a/src/nano.c b/src/nano.c index 02732238a3dceb575feb88c110aee1753f81dac8..efb43ea11b2842da40df35026369d40c349a3e34 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1289,7 +1289,7 @@ RETSIGTYPE do_continue(int signal) RETSIGTYPE handle_sigwinch(int signal) { /* Let the input routine know that a SIGWINCH has occurred. */ - sigwinch_counter++; + the_window_resized = TRUE; } /* Reinitialize and redraw the screen completely. */ @@ -1299,6 +1299,9 @@ void regenerate_screen(void) int fd, result = 0; struct winsize win; + /* Reset the trigger. */ + the_window_resized = FALSE; + if (tty == NULL) return; fd = open(tty, O_RDWR); diff --git a/src/proto.h b/src/proto.h index c49868106330019415f06d41de19aaba91a4459f..a7fe31103791659d73aa33adbc2c36075c0d4855 100644 --- a/src/proto.h +++ b/src/proto.h @@ -26,7 +26,7 @@ /* All external variables. See global.c for their descriptions. */ #ifndef NANO_TINY -extern volatile sig_atomic_t sigwinch_counter; +extern volatile sig_atomic_t the_window_resized; #endif #ifdef __linux__ diff --git a/src/winio.c b/src/winio.c index 5beec66dbfa9b48b9ba68689d6c50a81a774a511..7237b8ac30b35b87f409d56219b7298c7f7a1bfc 100644 --- a/src/winio.c +++ b/src/winio.c @@ -55,21 +55,6 @@ static bool seen_wide = FALSE; /* Whether we've seen a multicolumn character in the current line. */ #endif -#ifndef NANO_TINY -static sig_atomic_t last_sigwinch_counter = 0; - -/* Did we receive a SIGWINCH since we were last called? */ -bool the_window_resized(void) -{ - if (sigwinch_counter == last_sigwinch_counter) - return FALSE; - - last_sigwinch_counter = sigwinch_counter; - regenerate_screen(); - return TRUE; -} -#endif - /* Control character compatibility: * * - Ctrl-H is Backspace under ASCII, ANSI, VT100, and VT220. @@ -144,8 +129,9 @@ void get_key_buffer(WINDOW *win) input = wgetch(win); #ifndef NANO_TINY - if (the_window_resized()) { + if (the_window_resized) { ungetch(input); + regenerate_screen(); input = KEY_WINCH; } #endif @@ -162,7 +148,8 @@ void get_key_buffer(WINDOW *win) handle_hupterm(0); #ifndef NANO_TINY - if (the_window_resized()) { + if (the_window_resized) { + regenerate_screen(); input = KEY_WINCH; break; }