chiark / gitweb /
*** empty log message ***
authorjames <james>
Fri, 22 Feb 2008 19:12:05 +0000 (19:12 +0000)
committerjames <james>
Fri, 22 Feb 2008 19:12:05 +0000 (19:12 +0000)
src/tty.h
src/utf8.c [new file with mode: 0644]
src/utf8.h [new file with mode: 0644]
src/vt102.c

index 2ad10038c2da971f4afe2c6f97866eaff9c186c7..5585a027958f902cbe55792a9b7e8b754468284c 100644 (file)
--- a/src/tty.h
+++ b/src/tty.h
@@ -12,6 +12,9 @@
 
 /*
  * $Log$
+ * Revision 1.9  2008/02/22 19:12:05  james
+ * *** empty log message ***
+ *
  * Revision 1.8  2008/02/15 23:52:12  james
  * *** empty log message ***
  *
@@ -41,6 +44,9 @@
 #ifndef __TTY_H__
 #define __TTY_H__
 
+
+#define SYM_CHAR_RESET         (-1)
+
 #define TTY_SIGNATURE \
        char name[1024]; \
         int blocked; \
diff --git a/src/utf8.c b/src/utf8.c
new file mode 100644 (file)
index 0000000..18ca3eb
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * utf8.c:
+ *
+ * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
+ * All rights reserved.
+ *
+ */
+
+static char rcsid[] = "$Id$";
+
+/*
+ * $Log$
+ * Revision 1.1  2008/02/22 19:12:05  james
+ * *** empty log message ***
+ *
+ */
+
+#include "project.h"
+
+
+  /*FIXME: for the moment we bodge utf8 support*/
+  if ((ch>=0xc0) && (ch<0xe0)) /*Start of two byte unicode sequence*/
+  {
+       p->in_utf8=2;
+  } else if ((ch>=0xe0) && (ch<0xf0)) /*Start of three byte unicode sequence*/
+  {
+       p->in_utf8=3;
+  } else if ((ch>=0xf0) && (ch<0xf7)) /*Start of four byte unicode sequence*/
+       p->in_utf8=4;
+  }
+
+  if (p->utf_8) {
+       p->in_utf8--;
+       ch='?';
+  }  
+
+  if (!p->utf_8)  {
+       /*Not first or last byte in sequence*/
diff --git a/src/utf8.h b/src/utf8.h
new file mode 100644 (file)
index 0000000..faa8d7a
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * utf8.h:
+ *
+ * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
+ * All rights reserved.
+ *
+ */
+
+/*
+ * $Id$
+ */
+
+/*
+ * $Log$
+ * Revision 1.1  2008/02/22 19:12:05  james
+ * *** empty log message ***
+ *
+ *
+ */
+
+#ifndef __UTF8_H__
+#define __UTF8_H__
+
+
+typedef struct
+{
+  int in_escape;
+  int in_csi;
+  int in_utf8;
+  int csi_ptr;
+  char csi_buf[VT102_CSI_LEN];
+} UTF8_Parser;
+
+#endif /* __UTF8_H__ */
index 292e15cf1ebfb51252ae51b692cb9e1964fa26f7..e136637afd7e9c6d653e8383b4c9c4a9ee5bba3a 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.32  2008/02/22 19:12:05  james
+ * *** empty log message ***
+ *
  * Revision 1.31  2008/02/22 17:07:00  james
  * *** empty log message ***
  *
@@ -1233,6 +1236,39 @@ vt102_status_line (VT102 * v, char *str)
 }
 
 
+void
+vt102_parser_reset (VT102_parser * p)
+{
+  p->in_csi = 0;
+  p->in_escape = 0;
+}
+
+
+void
+vt102_reset_state(VT102 *v)
+{
+  vt102_parser_reset(&v->parser);
+
+  v->attr = CRT_ATTR_NORMAL;
+  v->color = CRT_COLOR_NORMAL;
+
+  v->application_keypad_mode = 0;
+
+  v->top_margin = v->screen_start;
+  v->bottom_margin = v->screen_end;
+
+  memset (v->modes, 0, VT102_NMODES);
+  memset (v->private_modes, 0, VT102_NMODES);
+
+  v->private_modes[VT102_PRIVATE_MODE_AUTO_WRAP] = 1;
+  v->private_modes[VT102_PRIVATE_MODE_AUTO_REPEAT] = 1;
+  v->private_modes[VT102_PRIVATE_MODE_SHOW_CURSOR] = 1;
+  v->modes[VT102_MODE_LOCAL_ECHO_OFF] = 1;
+
+  vt102_reset_tabs (v);
+}
+
+
 void
 vt102_parse_char (Context * c, int ch)
 {
@@ -1244,24 +1280,9 @@ vt102_parse_char (Context * c, int ch)
            p->in_utf8,p->in_escape, p->in_csi, v->pos.x, v->pos.y,v->pending_wrap);
 #endif
 
-  if ((ch>=0xc0) && (ch<0xe0)) /*Start of two byte unicode sequence*/
-  {
-       p->in_utf8=2;
-  } else if ((ch>=0xe0) && (ch<0xf0)) /*Start of three byte unicode sequence*/
-  {
-       p->in_utf8=3;
-  } else if ((ch>=0xf0) && (ch<0xf7)) /*Start of four byte unicode sequence*/
-       p->in_utf8=4;
-  }
-
-  if (p->utf_8) {
-       p->in_utf8--;
-       ch='?';
-  }  
-
-  if (p->utf_8) {
-       /*Not first or last byte in sequence*/
-  }else if (p->in_csi)
+  if (ch==SYM_CHAR_RESET) {
+       vt102_reset_state(v);
+  } else if (p->in_csi)
     {
       p->csi_buf[p->csi_ptr++] = ch;
       if (csi_ender (ch) || (p->csi_ptr == VT102_CSI_LEN))
@@ -1383,22 +1404,6 @@ vt102_parse_char (Context * c, int ch)
     cmd_show_status (c->d, c);
 }
 
-vt102_parse (Context * c, char *buf, int len)
-{
-  while (len--)
-    vt102_parse_char (c, *(buf++));
-}
-
-
-void
-vt102_parser_reset (VT102_parser * p)
-{
-  p->in_csi = 0;
-  p->in_escape = 0;
-  p->csi_ptr = 0;
-}
-
-
 void
 vt102_send (Context * c, uint8_t key)
 {
@@ -1573,13 +1578,9 @@ vt102_reset (VT102 * v)
   VT102_parser *p = &v->parser;
 
   vt102_parser_reset (p);
-  crt_cls (&v->crt);
-
-  v->attr = CRT_ATTR_NORMAL;
-  v->color = CRT_COLOR_NORMAL;
-
-  v->application_keypad_mode = 0;
+  vt102_reset_state(p);
 
+  crt_cls (&v->crt);
   v->current_line = v->pos;
   v->pending_wrap = 0;
 
@@ -1588,74 +1589,23 @@ vt102_reset (VT102 * v)
   v->screen_end.x = VT102_COLS - 1;
   v->screen_end.y = VT102_ROWS - 1;
 
-  v->top_margin = v->screen_start;
-  v->bottom_margin = v->screen_end;
-
-  memset (v->modes, 0, VT102_NMODES);
-  memset (v->private_modes, 0, VT102_NMODES);
-
-  v->private_modes[VT102_PRIVATE_MODE_AUTO_WRAP] = 1;
-  v->private_modes[VT102_PRIVATE_MODE_AUTO_REPEAT] = 1;
-  v->private_modes[VT102_PRIVATE_MODE_SHOW_CURSOR] = 1;
-  v->modes[VT102_MODE_LOCAL_ECHO_OFF] = 1;
-
   vt102_cursor_home (v);
+  vt102_status_line (v, "");
+
   vt102_reset_tabs (v);
   v->current_line = v->pos;
 
   vt102_save_state (v);
 
-  vt102_status_line (v, "");
-
   v->last_reg_char = ' ';
-
-
-}
-
-int
-vt102_dispatch (Context * c)
-{
-  char buf[1024];
-  int red;
-
-  red = c->t->recv (c->t, buf, sizeof (buf));
-
-  if (red < 0)
-    return -1;
-  if (!red)
-    return 0;
-
-
-  vt102_parse (c, buf, red);
-
-  return 0;
 }
-
-
-int
-vt102_dispatch_one (Context * c)
-{
-  char buf;
-  int red;
-
-  red = c->t->recv (c->t, &buf, sizeof (buf));
-
-  if (red < 0)
-    return -1;
-  if (!red)
-    return 0;
-
-  vt102_parse_char (c, buf);
-
-  return 0;
-}
-
 VT102 *
 vt102_new (void)
 {
   VT102 *v;
 
   v = (VT102 *) malloc (sizeof (VT102));
+
   v->xn_glitch=1;
 
   vt102_reset (v);