chiark / gitweb /
*** empty log message ***
[sympathy.git] / src / libsympathy.c
1 /*
2  * libsympathy.c:
3  *
4  * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
5  * All rights reserved.
6  *
7  */
8
9 static char rcsid[] =
10   "$Id$";
11
12 /*
13  * $Log$
14  * Revision 1.7  2008/02/07 00:39:13  james
15  * *** empty log message ***
16  *
17  * Revision 1.6  2008/02/06 20:26:58  james
18  * *** empty log message ***
19  *
20  * Revision 1.5  2008/02/06 17:53:28  james
21  * *** empty log message ***
22  *
23  * Revision 1.4  2008/02/04 20:23:55  james
24  * *** empty log message ***
25  *
26  * Revision 1.3  2008/02/04 05:45:55  james
27  * ::
28  *
29  * Revision 1.2  2008/02/04 02:05:06  james
30  * *** empty log message ***
31  *
32  * Revision 1.1  2008/02/03 16:20:24  james
33  * *** empty log message ***
34  *
35  *
36  */
37
38 #include "project.h"
39
40 struct termios old = { 0 };
41 static int had_winch = 0;
42
43 static void
44 quit (int not)
45 {
46   tcsetattr (0, TCSANOW, &old);
47   exit (1);
48 }
49
50 static void
51 winch (int not)
52 {
53   had_winch++;
54 }
55
56
57 void
58 testy (void)
59 {
60   struct termios raw = { 0 };
61   ANSI a = { 0 };
62   fd_set rfd;
63   int fd;
64   char c;
65   TTY *t;
66   VT102 *v;
67
68
69   signal (SIGINT, quit);
70   {
71     struct sigaction sa = { 0 };
72
73     sa.sa_handler = winch;
74     sa.sa_flags = SA_RESTART;
75     sigaction (SIGWINCH, &sa, NULL);
76   }
77
78
79   tcgetattr (0, &old);
80   tcgetattr (0, &raw);
81   cfmakeraw (&raw);
82   tcsetattr (0, TCSANOW, &raw);
83
84   a.fd = 0;
85   ansi_reset (&a);
86
87
88   t=tty_new_test();  
89   v=vt102_new(t);
90
91   FD_ZERO (&rfd);
92   for (;;)
93     {
94       struct timeval tv = { 0, 100000 };
95
96       FD_SET (t->fd, &rfd);
97       FD_SET (a.fd, &rfd);
98       select (t->fd + 1, &rfd, NULL, NULL, &tv);
99
100 #if 0
101       if (FD_ISSET (a.fd, &rfd))
102         {
103         }
104 #endif
105         if (ansi_dispatch(&a,v))
106                 break;
107
108       if (FD_ISSET (t->fd, &rfd)) {
109           if (vt102_dispatch (v)) break;
110       }
111
112       if (had_winch)
113         {
114           had_winch = 0;
115           ansi_getsize (&a);
116           ansi_reset (&a);
117           ansi_draw (&a, &v->crt);
118         }
119        ansi_draw (&a, &v->crt);
120     }
121   tcsetattr (0, TCSANOW, &old);
122   printf ("QUAT\n");
123 }