chiark / gitweb /
*** empty log message ***
[sympathy.git] / src / terminal.c
index 1223c0f0b677d610edca450c99e9ec83baac20af..7bbc761080aa390b9c0944efaac8f0f9d446619f 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * 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 +61,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 +79,14 @@ 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);
+
   set_blocking (t->rfd);
   set_blocking (t->wfd);
 
@@ -147,6 +161,7 @@ terminal_read (TTY * _t, void *buf, int len)
   int red, done = 0;
 
   terminal_dispatch ();
+  set_nonblocking (t->rfd);
 
   do
     {
@@ -176,14 +191,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 +252,8 @@ terminal_open (int rfd, int wfd)
   set_nonblocking (wfd);
 
 
-  raw_termios (&termios);
+  cfmakeraw (&termios);
+  //raw_termios (&termios);
 
   tcsetattr (wfd, TCSANOW, &termios);