summaryrefslogtreecommitdiffstats
path: root/lib/libncurses/lib_newterm.c
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1996-08-15 21:06:52 +0000
committerjkh <jkh@FreeBSD.org>1996-08-15 21:06:52 +0000
commit4d444750e2dda0a0801165c209533979cec07c02 (patch)
treeb98665a282e643c01c6d30aac73a6c07384688fe /lib/libncurses/lib_newterm.c
parent950ac9c81002ff25c73ffe17977bc160127616f7 (diff)
downloadFreeBSD-src-4d444750e2dda0a0801165c209533979cec07c02.zip
FreeBSD-src-4d444750e2dda0a0801165c209533979cec07c02.tar.gz
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.
Diffstat (limited to 'lib/libncurses/lib_newterm.c')
-rw-r--r--lib/libncurses/lib_newterm.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/libncurses/lib_newterm.c b/lib/libncurses/lib_newterm.c
index 79e5b4e..d72946e 100644
--- a/lib/libncurses/lib_newterm.c
+++ b/lib/libncurses/lib_newterm.c
@@ -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
OpenPOWER on IntegriCloud