Make libncurses catch SIGWINCH and update the values for LINES and COLS.
I was perplexed when an example I'd written to show the values for these variables changing as an xterm window was resized didn't work, and looking into it I see that size tracking for LINES and COLS seems to be one SVR4 enhancement which didn't come across with libncurses.
This commit is contained in:
parent
950ac9c810
commit
4d444750e2
@ -31,6 +31,17 @@ static void cleanup(int sig)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
size_change(int sig)
|
||||
{
|
||||
struct ttysize ws;
|
||||
|
||||
if (ioctl(0, TIOCGSIZE, &ws) == -1)
|
||||
return;
|
||||
LINES = ws.ts_lines;
|
||||
COLS = ws.ts_cols;
|
||||
}
|
||||
|
||||
WINDOW *stdscr, *curscr, *newscr;
|
||||
SCREEN *SP;
|
||||
|
||||
@ -130,6 +141,10 @@ char *use_it = _ncurses_copyright;
|
||||
act.sa_flags = 0;
|
||||
sigaction(SIGINT, &act, NULL);
|
||||
sigaction(SIGTERM, &act, NULL);
|
||||
act.sa_handler = size_change;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
sigaction(SIGWINCH, &act, NULL);
|
||||
#if 0
|
||||
sigaction(SIGSEGV, &act, NULL);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user