chiark / gitweb /
*** empty log message ***
authorjames <james>
Wed, 27 Feb 2008 00:54:16 +0000 (00:54 +0000)
committerjames <james>
Wed, 27 Feb 2008 00:54:16 +0000 (00:54 +0000)
src/log.c
src/prototypes.h
src/utf8.c
src/util.c
src/vt102.c
src/vt102_charset.c

index 0f96964a2096e0be32e16fc602573be5555cc6a8..ef0dfb566d7ba20481f8bca95804bfe110d9353b 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.4  2008/02/27 00:54:16  james
+ * *** empty log message ***
+ *
  * Revision 1.3  2008/02/23 11:48:37  james
  * *** empty log message ***
  *
@@ -98,6 +101,8 @@ file_log_new (char *fn)
   l->fp = f;
   l->do_close = dc;
 
+  fput_cp(f,0xffef);
+
   return (Log *) l;
 }
 
index 735617b26f29a87e0dc5861f4acf3c1b9c40fcb3..a1155924ea49e4fdb3c6fc6d826120ed5850f286 100644 (file)
@@ -96,6 +96,7 @@ extern void set_nonblocking(int fd);
 extern void set_blocking(int fd);
 extern void default_termios(struct termios *termios);
 extern void client_termios(struct termios *termios);
+extern int fput_cp(FILE *f, uint32_t ch);
 /* log.c */
 extern Log *file_log_new(char *fn);
 extern void log_f(Log *log, char *fmt, ...);
@@ -164,6 +165,7 @@ extern Serial_lock *serial_lock_new(char *dev, int mode);
 extern void utf8_flush(Context *c);
 extern void utf8_parse(Context *c, uint32_t ch);
 extern UTF8 *utf8_new(void);
+extern int utf8_encode(char *ptr, int ch);
 extern void utf8_emit(TTY *t, int ch);
 /* vt102_charset.c */
 extern uint32_t vt102_charset_c0[128];
index bffc9e408c18c8295010e4e1915ff228b734ba7a..7512c43ecb18eb272630e82cff6bedb5f34adcc5 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.8  2008/02/27 00:54:16  james
+ * *** empty log message ***
+ *
  * Revision 1.7  2008/02/26 23:56:12  james
  * *** empty log message ***
  *
@@ -151,38 +154,45 @@ utf8_new (void)
 
 }
 
-
-
-void
-utf8_emit (TTY * t, int ch)
+int  utf8_encode (char *ptr, int ch)
 {
-  uint8_t buf[4];
 
   if (ch < 0x80)
     {
-      buf[0] = ch;
-      t->xmit (t, buf, 1);
+      ptr[0] = ch;
+       return 1;
     }
   else if (ch < 0x800)
     {
-      buf[0] = 0xc0 | (ch >> 6);
-      buf[1] = 0x80 | (ch & 0x3f);
-
-      t->xmit (t, buf, 2);
+      ptr[0] = 0xc0 | (ch >> 6);
+      ptr[1] = 0x80 | (ch & 0x3f);
+       return 2;
     }
   else if (ch < 0x10000)
     {
-      buf[0] = 0xe0 | (ch >> 12);
-      buf[1] = 0x80 | ((ch >> 6) & 0x3f);
-      buf[2] = 0x80 | (ch & 0x3f);
-      t->xmit (t, buf, 3);
+      ptr[0] = 0xe0 | (ch >> 12);
+      ptr[1] = 0x80 | ((ch >> 6) & 0x3f);
+      ptr[2] = 0x80 | (ch & 0x3f);
+       return 3;
     }
   else if (ch < 0x1fffff)
     {
-      buf[0] = 0xf0 | (ch >> 18);
-      buf[1] = 0x80 | ((ch >> 12) & 0x3f);
-      buf[2] = 0x80 | ((ch >> 6) & 0x3f);
-      buf[3] = 0x80 | (ch & 0x3f);
-      t->xmit (t, buf, 4);
+      ptr[0] = 0xf0 | (ch >> 18);
+      ptr[1] = 0x80 | ((ch >> 12) & 0x3f);
+      ptr[2] = 0x80 | ((ch >> 6) & 0x3f);
+      ptr[3] = 0x80 | (ch & 0x3f);
+       return 4;
     }
+       return 0;
+}
+
+void
+utf8_emit (TTY * t, int ch)
+{
+  uint8_t buf[4];
+int i;
+  i=utf8_encode(buf,ch);
+  if (!i) return;
+
+      t->xmit (t, buf, i);
 }
index e8b221acba01c78783b1e7a5bfcdf7546f99eede..ea46e7727e9ee3f3f8cc0538c8f2eac328e7752a 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.6  2008/02/27 00:54:16  james
+ * *** empty log message ***
+ *
  * Revision 1.5  2008/02/24 00:42:53  james
  * *** empty log message ***
  *
@@ -139,3 +142,14 @@ client_termios (struct termios *termios)
   cfsetispeed (termios, B9600);
   cfsetospeed (termios, B9600);
 }
+
+int fput_cp(FILE *f,uint32_t ch)
+{
+char buf[4];
+int i;
+i=utf8_encode(buf,ch);
+
+if (!i) return 0;
+
+return fwrite(buf,i,1,f);
+}
index 88210873f2d1e1e31b9dadcbd6e36b38e7f32f36..7c211c51cc3d70902e559e08d21033ca53910da0 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * 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 +387,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 +404,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 +984,30 @@ 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 +1725,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 +1766,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 +1779,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);
         }
index 49abe8fda0740bb702ff3e8b7df332a0714a1c64..43e6012f3e8e267bf98653e8ec3a272e16daf499 100644 (file)
@@ -11,6 +11,9 @@ static char rcsid[] =
 
 /*
  * $Log$
+ * Revision 1.4  2008/02/27 00:54:16  james
+ * *** empty log message ***
+ *
  * Revision 1.3  2008/02/27 00:27:22  james
  * *** empty log message ***
  *
@@ -80,14 +83,14 @@ uint32_t vt102_charset_vt52[VT102_CHARSET_SIZE] = {
   [0x69] = 0x2026,
   [0x6a] = 0x00f7,
   [0x6b] = 0x2193,
-  [0x6c] = 0x25ba,              //bar scan 0
+  [0x6c] = 0x23ba,              //bar scan 0
   [0x6d] = 0x23ba,
-  [0x6e] = 0x25ba,              //bar scan 2
+  [0x6e] = 0x23bb,              //bar scan 2
   [0x6f] = 0x23bb,
-  [0x70] = 0x23bb,              //bar scan 4
-  [0x71] = 0x2500,
-  [0x72] = 0x23bc,              //bar scan 6
-  [0x73] = 0x23bc,
+  [0x70] = 0x2500,              //bar scan 4
+  [0x71] = 0x23bc,
+  [0x72] = 0x23bd,              //bar scan 6
+  [0x73] = 0x23bd,
   [0x74] = 0x2080,
   [0x75] = 0x2081,
   [0x76] = 0x2082,