chiark / gitweb /
*** empty log message ***
[sympathy.git] / src / ansi.c
index 66c70f1125580fc90daea059e877cec5d4011137..7a0d630a18406a3966d4bf9bb949d60d713d8e4b 100644 (file)
@@ -10,6 +10,12 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.30  2008/02/24 00:42:53  james
+ * *** empty log message ***
+ *
+ * Revision 1.29  2008/02/23 11:48:37  james
+ * *** empty log message ***
+ *
  * Revision 1.28  2008/02/22 17:07:00  james
  * *** empty log message ***
  *
@@ -313,21 +319,30 @@ ansi_set_attr (ANSI * a, int attr)
 
 }
 
+static void
+ansi_emit_noutf8 (TTY * t, uint32_t ch)
+{
+  uint8_t c = (ch > 0x7f) ? '?' : ch;
+  t->xmit (t, &c, 1);
+}
 
 static void
 ansi_render (ANSI * a, CRT_CA ca)
 {
   int dif;
 
-  if (ca.chr < 32)
+  if (ca.chr < 0x20)
     ca.chr = ' ';
-  if (ca.chr > 126)
+  if ((ca.chr > 0x7e) && (ca.chr < 0xa0))
     ca.chr = ' ';
 
   ansi_set_attr (a, ca.attr);
   ansi_set_color (a, ca.color);
 
-  a->terminal->xmit (a->terminal, &ca.chr, 1);
+  if (a->utf8)
+    utf8_emit (a->terminal, ca.chr);
+  else
+    ansi_emit_noutf8 (a->terminal, ca.chr);
 
   a->pos.x++;
 
@@ -531,7 +546,7 @@ ansi_history (ANSI * a, History * h)
       /*Roll HISTORY_GUESS_SCROLL lines up putting the top line into the xterm's history */
 
 
-      /*Make extra lines a predictable colour*/
+      /*Make extra lines a predictable colour */
       ansi_set_color (a, CRT_COLOR_NORMAL);
 
       ansi_showhide_cursor (a, 1);
@@ -559,7 +574,7 @@ ansi_history (ANSI * a, History * h)
         /* erase new line */
         s.y = e.y;
         e.x = CRT_COLS - 1;
-        crt_erase (&a->crt, s, e, 1,CRT_COLOR_NORMAL);
+        crt_erase (&a->crt, s, e, 1, CRT_COLOR_NORMAL);
       }
 
     }
@@ -880,7 +895,7 @@ ansi_free (ANSI * a)
 }
 
 ANSI *
-ansi_new_from_terminal (TTY * t)
+ansi_new_from_terminal (TTY * t, int utf8)
 {
   ANSI *ret;
 
@@ -889,6 +904,7 @@ ansi_new_from_terminal (TTY * t)
 
   ret->terminal = t;
 
+  ret->utf8 = utf8;
   ret->update = ansi_update;
   ret->reset = ansi_reset;
   ret->terminal_reset = ansi_terminal_reset;