diff options
Diffstat (limited to 'src/libsympathy.c')
-rw-r--r-- | src/libsympathy.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/libsympathy.c b/src/libsympathy.c index e86c088..d8eb76f 100644 --- a/src/libsympathy.c +++ b/src/libsympathy.c @@ -11,6 +11,9 @@ static char rcsid[] = /* * $Log$ + * Revision 1.5 2008/02/06 17:53:28 james + * *** empty log message *** + * * Revision 1.4 2008/02/04 20:23:55 james * *** empty log message *** * @@ -29,14 +32,19 @@ static char rcsid[] = #include "project.h" struct termios old = { 0 }; +static int had_winch=0; -static void -foo (int not) +static void quit (int not) { tcsetattr (0, TCSANOW, &old); exit (1); } +static void winch (int not) +{ + had_winch++; +} + void testy (void) @@ -49,7 +57,15 @@ testy (void) char c; - signal (SIGINT, foo); + signal (SIGINT, quit); +{ +struct sigaction sa={0}; + +sa.sa_handler=winch; +sa.sa_flags=SA_RESTART; +sigaction(SIGWINCH,&sa,NULL); +} + tcgetattr (0, &old); tcgetattr (0, &raw); @@ -69,10 +85,12 @@ testy (void) for (;;) { + struct timeval tv={0,100000}; + FD_SET (fd, &rfd); FD_SET (0, &rfd); - if (select (fd + 1, &rfd, NULL, NULL, NULL) <= 0) - continue; + if (select (fd + 1, &rfd, NULL, NULL, &tv)<0) continue; + if (FD_ISSET (0, &rfd)) { if ((read (0, &c, 1) <= 0) || (c == 3)) @@ -88,6 +106,12 @@ testy (void) vt102_parse_char (&v, c); ansi_draw (&a, &v.crt); } + if (had_winch) { + had_winch=0; + ansi_getsize(&a); + ansi_reset(&a); + ansi_draw (&a, &v.crt); + } } tcsetattr (0, TCSANOW, &old); printf ("QUAT\n"); |