chiark / gitweb /
*** empty log message ***
[sympathy.git] / src / terminal.c
index 1223c0f0b677d610edca450c99e9ec83baac20af..03ac5d402b1a146fda1befbe9c4ece145ef74923 100644 (file)
@@ -10,6 +10,12 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.5  2008/02/13 18:05:06  james
+ * *** empty log message ***
+ *
+ * Revision 1.4  2008/02/13 16:57:29  james
+ * *** empty log message ***
+ *
  * Revision 1.3  2008/02/13 09:12:21  james
  * *** empty log message ***
  *
@@ -58,6 +64,9 @@ int terminal_winches;
 static void
 terminal_close (TTY * _t)
 {
+  char buf[32];
+  int i;
+
   TERMINAL *t = (TERMINAL *) _t;
   TERMINAL **ptr = &terminal_list;
 
@@ -73,6 +82,15 @@ terminal_close (TTY * _t)
 
   tcsetattr (t->wfd, TCSANOW, &t->orig_termios);
 
+  set_nonblocking (t->wfd);
+
+
+  t->xmit (_t, "\033[r", 3);
+  t->xmit (_t, "\033[0m", 4);
+  i = sprintf (buf, "\033[%d;%dH", CRT_ROWS + 1, 1);
+  t->xmit (_t, buf, i);
+  t->xmit (_t, "\033[J", 3);
+
   set_blocking (t->rfd);
   set_blocking (t->wfd);
 
@@ -135,7 +153,7 @@ terminal_dispatch (void)
   terminal_winches = 0;
 
   for (t = terminal_list; t; t = t->next)
-    terminal_getsize (t);
+    terminal_getsize ((TTY *)t);
 
 }
 
@@ -147,6 +165,7 @@ terminal_read (TTY * _t, void *buf, int len)
   int red, done = 0;
 
   terminal_dispatch ();
+  set_nonblocking (t->rfd);
 
   do
     {
@@ -176,14 +195,17 @@ terminal_write (TTY * _t, void *buf, int len)
 
   terminal_dispatch ();
 
+  set_blocking (t->wfd);
+
   do
     {
 
       writ = wrap_write (t->wfd, buf, len);
       if (writ < 0)
         return -1;
+
       if (!writ)
-        sleep (1);
+        usleep (1000);
 
       buf += writ;
       len -= writ;
@@ -234,7 +256,8 @@ terminal_open (int rfd, int wfd)
   set_nonblocking (wfd);
 
 
-  raw_termios (&termios);
+  cfmakeraw (&termios);
+  //raw_termios (&termios);
 
   tcsetattr (wfd, TCSANOW, &termios);