chiark / gitweb /
*** empty log message ***
[sympathy.git] / src / vt102.c
index 88210873f2d1e1e31b9dadcbd6e36b38e7f32f36..52f7fb959f60f70d8a22e88a223394214fd68a8e 100644 (file)
@@ -10,6 +10,15 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.46  2008/02/27 01:31:38  james
+ * *** empty log message ***
+ *
+ * Revision 1.45  2008/02/27 01:31:14  james
+ * *** empty log message ***
+ *
+ * Revision 1.44  2008/02/27 00:54:16  james
+ * *** empty log message ***
+ *
  * Revision 1.43  2008/02/27 00:27:22  james
  * *** empty log message ***
  *
@@ -384,7 +393,7 @@ vt102_log_line (Context * c, int line)
 {
   CRT_Pos e = { c->v->current_width - 1, line };
   CRT_Pos p = { 0, line };
-  char logbuf[VT102_MAX_COLS + 1];
+  char logbuf[4 * (VT102_MAX_COLS + 1)], *logptr = logbuf;
 
   if (!c->l)
     return;
@@ -401,11 +410,9 @@ vt102_log_line (Context * c, int line)
       int ch = c->v->crt.screen[CRT_ADDR_POS (&p)].chr;
       if (ch < 32)
         ch = ' ';
-      if (ch > 126)
-        ch = ' ';
-      logbuf[p.x] = ch;
+      logptr += utf8_encode (logptr, ch);
     }
-  logbuf[p.x] = 0;
+  *logptr = 0;
 
   c->l->log (c->l, logbuf);
 }
@@ -983,25 +990,33 @@ void
 vt102_regular_char (Context * c, VT102 * v, uint32_t ch)
 {
 
+
   vt102_do_pending_wrap (c);
 
+
   if (v->modes[VT102_MODE_INSERT])
     vt102_insert_into_line (v, v->pos);
 
+  v->last_reg_char = ch;
+
+
   if (ch < VT102_CHARSET_SIZE)
     {
-      int cs = charset_from_csid[v->g[v->cs]][ch];
-      v->crt.screen[CRT_ADDR_POS (&v->pos)].chr = cs ? cs : ch;
-    }
-  else
-    {
-      v->crt.screen[CRT_ADDR_POS (&v->pos)].chr = ch;
+      int cs;
+      if ((cs = vt102_charset_c0[ch]))
+        {
+          ch = cs;
+        }
+      else if ((cs = charset_from_csid[v->g[v->cs]][ch]))
+        {
+          ch = cs;
+        }
     }
+  v->crt.screen[CRT_ADDR_POS (&v->pos)].chr = ch;
   v->crt.screen[CRT_ADDR_POS (&v->pos)].attr = v->attr;
   v->crt.screen[CRT_ADDR_POS (&v->pos)].color = v->color;
   vt102_cursor_advance (c);
 
-  v->last_reg_char = ch;
 }
 
 vt102_send_id (Context * c, char *buf)
@@ -1719,17 +1734,23 @@ vt102_parse_char (Context * c, int ch)
 
       switch (ch)
         {
+#if 0
          /*NUL*/ case 0:
          /*SOH*/ case 1:
          /*STX*/ case 2:
          /*ETX*/ case 3:
          /*EOT*/ case 4:
           break;
+#endif
          /*ENQ*/ case 5:
           vt102_send_id (c, terminal_id);
           break;
+#if 0
          /*ACK*/ case 6:
+          break;
+#endif
          /*BEL*/ case 7:
+          //FIXME beep
           break;
          /*BS*/ case 8:
           vt102_cursor_retreat (c->v);
@@ -1754,6 +1775,7 @@ vt102_parse_char (Context * c, int ch)
           /*select G0 */
           v->cs = 0;
           break;
+#if 0
          /*DLE*/ case 16:
         /*DC1 */ case 17:
         /*DC2 */ case 18:
@@ -1766,15 +1788,18 @@ vt102_parse_char (Context * c, int ch)
          /*EM*/ case 25:
          /*SUB*/ case 26:
           break;
+#endif
          /*ESC*/ case 27:
           p->in_escape++;
           return;
+#if 0
          /*FS*/ case 28:
          /*GS*/ case 29:
          /*RS*/ case 30:
          /*US*/ case 31:
          /*DEL*/ case 127:
           break;
+#endif
         /*regular character */ default:
           vt102_regular_char (c, v, ch);
         }
@@ -2000,7 +2025,7 @@ vt102_reset (VT102 * v)
 }
 
 VT102 *
-vt102_new (void)
+vt102_new (int width)
 {
   VT102 *v;
 
@@ -2010,6 +2035,15 @@ vt102_new (void)
 
   vt102_reset (v);
 
+  if (width)
+    {
+      v->current_width = width;
+      v->crt.width = v->current_width;
+      v->screen_end.x = v->current_width - 1;
+      v->top_margin = v->screen_start;
+      v->bottom_margin = v->screen_end;
+      vt102_cursor_home (v);
+    }
 
   return v;
 }