1
1

general: simplify the detection of a SIGWINCH

There is no need for a counter, nor an old counter to compare it with.
Этот коммит содержится в:
Benno Schulenberg 2016-12-14 20:37:03 +01:00
родитель 2bcc6d7f66
Коммит b77e6bd99d
4 изменённых файлов: 11 добавлений и 21 удалений

Просмотреть файл

@ -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__

Просмотреть файл

@ -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);

Просмотреть файл

@ -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__

Просмотреть файл

@ -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;
}