+ fd_set rfds, wfds;
+ ANSI a = { 0 };
+ Context c;
+
+
+ c.t = ptty_open (NULL, NULL);
+ c.v = vt102_new ();
+ c.h = history_new (200);
+ c.l = file_log_new ("log");
+ c.k = keydis_vt102_new (&c);
+
+ terminal_register_handlers ();
+ a.terminal = terminal_open (0, 1);
+
+ ansi_reset (&a, NULL);
+
+ for (;;)
+ {
+ struct timeval tv = { 10, 0 };
+
+ FD_ZERO (&rfds);
+ FD_ZERO (&wfds);
+
+ tty_pre_select (c.t, &rfds, &wfds);
+ tty_pre_select (a.terminal, &rfds, &wfds);
+
+
+ select (FD_SETSIZE, &rfds, &wfds, NULL, &tv);
+
+ if (FD_ISSET (c.t->rfd, &rfds))
+ {
+ if (vt102_dispatch(&c)) break;
+ }
+
+ ansi_dispatch (&a, &c);
+ ansi_update (&a, &c);
+