chiark / gitweb /
*** empty log message ***
[sympathy.git] / src / ansi.c
index 5d6105eb83437fb366cd78d0db48a60a70219a05..49a7bc9b331e8d9db9229ea9e295c0ef77df7f36 100644 (file)
@@ -10,10 +10,14 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.2  2008/02/04 02:05:06  james
+ * *** empty log message ***
+ *
  * Revision 1.1  2008/02/03 23:31:25  james
  * *** empty log message ***
  *
  */
+#include "project.h"
 
 void
 ansi_write (ANSI * a, char *buf, int n)
@@ -131,60 +135,62 @@ ansi_showhide_cursor (ANSI * a, int hide)
 }
 
 
-void ansi_force_attr_normal(ANSI *a)
+void
+ansi_force_attr_normal (ANSI * a)
 {
   ansi_write (a, "\033[0m", 4);
-  a->attr=CRT_ATTR_NORMAL;
+  a->attr = CRT_ATTR_NORMAL;
 }
 
 void
 ansi_set_attr (ANSI * a, int attr)
 {
+  int dif;
 
   dif = attr ^ a->attr;
 
   if (!dif)
     return;
 
-  if (attr == ATTR_NORMAL)
+  if (attr == CRT_ATTR_NORMAL)
     {
-       ansi_force_attr_normal(a);
-       return;
+      ansi_force_attr_normal (a);
+      return;
     }
 
-      if (dif & CRT_ATTR_UNDERLINE)
+  if (dif & CRT_ATTR_UNDERLINE)
+    {
+      if (attr & CRT_ATTR_UNDERLINE)
         {
-          if (attr & CRT_ATTR_UNDERLINE)
-            {
-              ansi_write (a, "\033[4m", 4);
-            }
-          else
-            {
-              ansi_write (a, "\033[24m", 5);
-            }
+          ansi_write (a, "\033[4m", 4);
         }
-      if (dif & CRT_ATTR_REVERSE)
+      else
         {
-          if (attr & CRT_ATTR_REVERSE)
-            {
-              ansi_write (a, "\033[7m", 4);
-            }
-          else
-            {
-              ansi_write (a, "\033[27m", 5);
-            }
+          ansi_write (a, "\033[24m", 5);
+        }
+    }
+  if (dif & CRT_ATTR_REVERSE)
+    {
+      if (attr & CRT_ATTR_REVERSE)
+        {
+          ansi_write (a, "\033[7m", 4);
         }
-      if (dif & CRT_ATTR_BOLD)
+      else
         {
-          if (attr & CRT_ATTR_REVERSE)
-            {
-              ansi_write (a, "\033[1m", 4);
-            }
-          else
-            {
-              ansi_write (a, "\033[22m", 5);
-            }
+          ansi_write (a, "\033[27m", 5);
         }
+    }
+  if (dif & CRT_ATTR_BOLD)
+    {
+      if (attr & CRT_ATTR_REVERSE)
+        {
+          ansi_write (a, "\033[1m", 4);
+        }
+      else
+        {
+          ansi_write (a, "\033[22m", 5);
+        }
+    }
 }
 
 
@@ -218,7 +224,7 @@ ansi_cls (ANSI * a)
   CRT_Pos p = { 0 };
 
   crt_cls (&a->crt);
-  ansi_force_attr_normal(a);
+  ansi_force_attr_normal (a);
   ansi_move (a, p);
   ansi_write (a, "\033[2J", 4);
 /*different emulators leave cursor in different places after cls differently*/
@@ -238,17 +244,17 @@ ansi_draw (ANSI * a, CRT * c)
     {
       if (p.y >= a->size.y)
         continue;
-      o = CRT_ADDR (r, 0);
+      o = CRT_ADDR (p.y, 0);
       for (p.x = 0; p.x < CRT_COLS; ++p.x, ++o)
         {
           if (p.x >= a->size.x)
             continue;
-          if (crt_ca_cmp (a->crt.screen[p], c->screen[p]))
+          if (crt_ca_cmp (a->crt.screen[o], c->screen[o]))
             {
-              a->crt.screen[p] = c->screen[p];
+              a->crt.screen[o] = c->screen[o];
 
               ansi_move (a, p);
-              ansi_render (a, a->crt.screen[p]);
+              ansi_render (a, a->crt.screen[o]);
             }
         }
     }
@@ -257,7 +263,7 @@ ansi_draw (ANSI * a, CRT * c)
   ansi_move (a, a->crt.pos);
 
   a->crt.hide_cursor = c->hide_cursor;
-  ansi_showhide_cursor (a, ci->crt.hide_cursor);
+  ansi_showhide_cursor (a, a->crt.hide_cursor);
 }
 
 void