chiark / gitweb /
*** empty log message ***
authorjames <james>
Fri, 22 Feb 2008 17:06:59 +0000 (17:06 +0000)
committerjames <james>
Fri, 22 Feb 2008 17:06:59 +0000 (17:06 +0000)
12 files changed:
apps/clients.c
src/ansi.c
src/cmd.c
src/crt.c
src/ipc.c
src/ipc.h
src/keydis.c
src/keydis.h
src/prototypes.h
src/ptty.c
src/vt102.c
src/vt102.h

index 80b77502603205a04fb760e5753bd8d75bcc2b38..069ae40d127574169f4937f222ef67314e08fb9e 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.10  2008/02/22 17:06:59  james
+ * *** empty log message ***
+ *
  * Revision 1.9  2008/02/20 18:49:11  staffcvs
  * *** empty log message ***
  *
@@ -70,6 +73,9 @@ client_msg (IPC_Msg * m, Context * c)
     case IPC_MSG_TYPE_SETFLOW:
       tty_set_flow (c->t, m->setflow.flow);
       break;
+    case IPC_MSG_TYPE_SETANSI:
+      vt102_set_ansi (c->v, m->setansi.ansi);
+      break;
     case IPC_MSG_TYPE_HANGUP:
       tty_hangup (c->t);
       break;
index d2efc467db94738ee091cfc2669754fa6a184349..66c70f1125580fc90daea059e877cec5d4011137 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.28  2008/02/22 17:07:00  james
+ * *** empty log message ***
+ *
  * Revision 1.27  2008/02/20 22:54:22  staffcvs
  * *** empty log message ***
  *
@@ -528,6 +531,9 @@ 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*/
+      ansi_set_color (a, CRT_COLOR_NORMAL);
+
       ansi_showhide_cursor (a, 1);
       i = sprintf (buf, "\033[%d;%dH", HISTORY_GUESS_SCROLL, 1);
       a->terminal->xmit (a->terminal, buf, i);
@@ -553,7 +559,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_erase (&a->crt, s, e, 1,CRT_COLOR_NORMAL);
       }
 
     }
index bf5be83ebba0f06d22824ad12cfa2842f2635140..7105c5b1a28bf920c9c4046194e55bea767bff8e 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.3  2008/02/22 17:07:00  james
+ * *** empty log message ***
+ *
  * Revision 1.2  2008/02/15 23:52:12  james
  * *** empty log message ***
  *
@@ -31,6 +34,10 @@ cmd_parse (Cmd * c, Context * ctx, char *buf)
     ctx->k->set_flow (ctx->k, ctx, 1);
   if (!strcmp (buf, "noflow"))
     ctx->k->set_flow (ctx->k, ctx, 0);
+  if (!strcmp (buf, "ansi"))
+    ctx->k->set_ansi (ctx->k, ctx, 0);
+  if (!strcmp (buf, "noansi"))
+    ctx->k->set_ansi (ctx->k, ctx, 1);
   if (!strncmp (buf, "baud", 4))
     ctx->k->set_baud (ctx->k, ctx, atoi (buf + 4));
   if (!strncmp (buf, "break", 4))
index a9e6e8637655fb0c273ce55ef8f3538fcd29c200..5f5656b2ccf33c46d4eedc8e0260e18b56728451 100644 (file)
--- a/src/crt.c
+++ b/src/crt.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.10  2008/02/22 17:07:00  james
+ * *** empty log message ***
+ *
  * Revision 1.9  2008/02/07 13:22:51  james
  * *** empty log message ***
  *
@@ -42,7 +45,7 @@ static char rcsid[] = "$Id$";
 #include "project.h"
 
 void
-crt_erase (CRT * c, CRT_Pos s, CRT_Pos e, int ea)
+crt_erase (CRT * c, CRT_Pos s, CRT_Pos e, int ea,int color)
 {
   CRT_CA *ps = &c->screen[CRT_ADDR_POS (&s)];
   CRT_CA *pe = &c->screen[CRT_ADDR_POS (&e)];
@@ -53,7 +56,7 @@ crt_erase (CRT * c, CRT_Pos s, CRT_Pos e, int ea)
       if (ea)
         {
           ps->attr = CRT_ATTR_NORMAL;
-          ps->color = CRT_COLOR_NORMAL;
+          ps->color = color;
         }
       ps++;
     }
@@ -67,12 +70,12 @@ crt_cls (CRT * c)
   CRT_Pos e = { CRT_COLS - 1, CRT_ROWS - 1 };
   int i;
 
-  crt_erase (c, s, e, 1);
+  crt_erase (c, s, e, 1, CRT_COLOR_NORMAL);
   c->sh.dir = 0;
 }
 
 void
-crt_scroll_up (CRT * c, CRT_Pos s, CRT_Pos e, int ea)
+crt_scroll_up (CRT * c, CRT_Pos s, CRT_Pos e, int ea,int color)
 {
   int l, n;
   int p;
@@ -101,12 +104,12 @@ crt_scroll_up (CRT * c, CRT_Pos s, CRT_Pos e, int ea)
     }
 
   s.y = e.y;
-  crt_erase (c, s, e, ea);
+  crt_erase (c, s, e, ea,color);
 
 }
 
 void
-crt_scroll_down (CRT * c, CRT_Pos s, CRT_Pos e, int ea)
+crt_scroll_down (CRT * c, CRT_Pos s, CRT_Pos e, int ea,int color)
 {
   int l, n;
   int p;
@@ -134,7 +137,7 @@ crt_scroll_down (CRT * c, CRT_Pos s, CRT_Pos e, int ea)
     }
 
   e.y = s.y;
-  crt_erase (c, s, e, ea);
+  crt_erase (c, s, e, ea,color);
 
 }
 
index b30bef00d93a3d9a7f03da00a00679a32412b45f..8809f362bf42d1e57da1a3c7cc68524d0901514d 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.4  2008/02/22 17:07:00  james
+ * *** empty log message ***
+ *
  * Revision 1.3  2008/02/15 23:52:12  james
  * *** empty log message ***
  *
@@ -192,6 +195,17 @@ ipc_msg_send_setflow (Socket * s, int flow)
   return ipc_msg_send (s, (IPC_Msg *) & m);
 }
 
+int
+ipc_msg_send_setansi (Socket * s, int ansi)
+{
+  IPC_Msg_setansi m;
+
+  m.size = sizeof (m);
+  m.type = IPC_MSG_TYPE_SETANSI;
+  m.ansi = ansi;
+  return ipc_msg_send (s, (IPC_Msg *) & m);
+}
+
 int
 ipc_msg_send_hangup (Socket * s)
 {
index 2713de7a35e266cff68f9a4202605fe02039ad68..1820511b70ce0a7afc7d03ba23217781ceb54a3e 100644 (file)
--- a/src/ipc.h
+++ b/src/ipc.h
@@ -12,6 +12,9 @@
 
 /*
  * $Log$
+ * Revision 1.4  2008/02/22 17:07:00  james
+ * *** empty log message ***
+ *
  * Revision 1.3  2008/02/15 23:52:12  james
  * *** empty log message ***
  *
 
 #define IPC_MSG_TYPE_NOOP  0
 #define IPC_MSG_TYPE_DEBUG 1
-#define IPC_MSG_TYPE_HISTORY 2
-#define IPC_MSG_TYPE_VT102 3
+#define IPC_MSG_TYPE_VT102 2
+#define IPC_MSG_TYPE_HISTORY 3
 #define IPC_MSG_TYPE_KEY 4
 #define IPC_MSG_TYPE_TERM 5
 #define IPC_MSG_TYPE_STATUS 6
 #define IPC_MSG_TYPE_SETBAUD 7
 #define IPC_MSG_TYPE_SENDBREAK 8
 #define IPC_MSG_TYPE_SETFLOW 9
-#define IPC_MSG_TYPE_HANGUP 10
+#define IPC_MSG_TYPE_SETANSI 10
+#define IPC_MSG_TYPE_HANGUP 11
 
 typedef struct
 {
@@ -124,6 +128,14 @@ typedef struct
 } IPC_Msg_setflow;
 
 
+typedef struct 
+{
+  int32_t size;
+  int32_t type;
+  int32_t ansi;
+} IPC_Msg_setansi;
+
+
 typedef struct 
 {
   int32_t size;
@@ -145,6 +157,7 @@ IPC_Msg_status status;
 IPC_Msg_setbaud setbaud;
 IPC_Msg_sendbreak sendbreak;
 IPC_Msg_setflow setflow;
+IPC_Msg_setansi setansi;
 IPC_Msg_hangup hangup;
 } IPC_Msg;
 
index c8883a7f5fabccb65b5c9f215c25d9c86ce454bf..73f6306213268b184eb3f2de47cb53144372894a 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.4  2008/02/22 17:07:00  james
+ * *** empty log message ***
+ *
  * Revision 1.3  2008/02/15 23:52:12  james
  * *** empty log message ***
  *
@@ -87,6 +90,19 @@ keydis_ipc_set_flow (KeyDis * _t, Context * c, int flow)
 }
 
 
+static int
+keydis_ipc_set_ansi (KeyDis * _t, Context * c, int ansi)
+{
+  KeyDis_IPC *t = (KeyDis_IPC *) _t;
+
+      vt102_set_ansi (c->v, ansi);
+
+  ipc_msg_send_setansi (t->s, ansi);
+
+  return 0;
+}
+
+
 static int
 keydis_ipc_hangup (KeyDis * _t, Context * c)
 {
@@ -136,6 +152,16 @@ keydis_vt102_set_flow (KeyDis * _t, Context * c, int flow)
   return 0;
 }
 
+static int
+keydis_vt102_set_ansi (KeyDis * _t, Context * c, int ansi)
+{
+  KeyDis_VT102 *t = (KeyDis_VT102 *) _t;
+
+  if (c->v)
+  c->v->xn_glitch=ansi ? 0:1;
+  return 0;
+}
+
 
 static int
 keydis_vt102_hangup (KeyDis * _t, Context * c)
@@ -158,6 +184,7 @@ keydis_vt102_new (void)
   t->set_baud = keydis_vt102_set_baud;
   t->send_break = keydis_vt102_send_break;
   t->set_flow = keydis_vt102_set_flow;
+  t->set_ansi = keydis_vt102_set_ansi;
   t->hangup = keydis_vt102_hangup;
   return (KeyDis *) t;
 }
@@ -172,6 +199,7 @@ keydis_ipc_new (Socket * s)
   t->set_baud = keydis_ipc_set_baud;
   t->send_break = keydis_ipc_send_break;
   t->set_flow = keydis_ipc_set_flow;
+  t->set_ansi = keydis_ipc_set_ansi;
   t->hangup = keydis_ipc_hangup;
   t->s = s;
   return (KeyDis *) t;
index 4ccfb7d15da41dd304590e447356f7993816d920..89bf9e24274b2293a900509b94657190ef8ec523 100644 (file)
@@ -12,6 +12,9 @@
 
 /*
  * $Log$
+ * Revision 1.4  2008/02/22 17:07:00  james
+ * *** empty log message ***
+ *
  * Revision 1.3  2008/02/15 23:52:12  james
  * *** empty log message ***
  *
@@ -38,6 +41,7 @@ struct Context_struct;
        int (*set_baud)(struct KeyDis_struct *,struct Context_struct *,int rate); \
        int (*send_break)(struct KeyDis_struct *,struct Context_struct *); \
        int (*set_flow)(struct KeyDis_struct *,struct Context_struct *,int flow); \
+       int (*set_ansi)(struct KeyDis_struct *,struct Context_struct *,int ansi); \
        int (*hangup)(struct KeyDis_struct *,struct Context_struct *)
 
        
index 89ada5df0ce2005ff5c9fb3f5586feccf5e8159f..f0aaa8a186a6b87627add7d2cddea5b8b9b56fed 100644 (file)
@@ -2,10 +2,10 @@
 extern int ansi_dispatch(ANSI *a, Context *c);
 extern ANSI *ansi_new_from_terminal(TTY *t);
 /* crt.c */
-extern void crt_erase(CRT *c, CRT_Pos s, CRT_Pos e, int ea);
+extern void crt_erase(CRT *c, CRT_Pos s, CRT_Pos e, int ea, int color);
 extern void crt_cls(CRT *c);
-extern void crt_scroll_up(CRT *c, CRT_Pos s, CRT_Pos e, int ea);
-extern void crt_scroll_down(CRT *c, CRT_Pos s, CRT_Pos e, int ea);
+extern void crt_scroll_up(CRT *c, CRT_Pos s, CRT_Pos e, int ea, int color);
+extern void crt_scroll_down(CRT *c, CRT_Pos s, CRT_Pos e, int ea, int color);
 extern void crt_reset(CRT *c);
 extern void crt_insert(CRT *c, CRT_CA ca);
 /* html.c */
@@ -20,8 +20,8 @@ extern void vt102_clip_cursor(VT102 *v, CRT_Pos tl, CRT_Pos br);
 extern void vt102_cursor_normalize(VT102 *v);
 extern void vt102_cursor_carriage_return(VT102 *v);
 extern void vt102_cursor_advance_line(Context *c);
-extern void vt102_cursor_advance(Context *c);
 extern void vt102_do_pending_wrap(Context *c);
+extern void vt102_cursor_advance(Context *c);
 extern void vt102_cursor_retard(VT102 *v);
 extern void vt102_reset_tabs(VT102 *v);
 extern void vt102_cursor_advance_tab(VT102 *v);
@@ -50,6 +50,7 @@ extern void vt102_reset(VT102 *v);
 extern int vt102_dispatch(Context *c);
 extern int vt102_dispatch_one(Context *c);
 extern VT102 *vt102_new(void);
+extern void vt102_set_ansi(VT102 *v, int ansi);
 extern void vt102_free(VT102 *v);
 /* tty.c */
 extern void tty_pre_select(TTY *t, fd_set *rfds, fd_set *wfds);
@@ -104,6 +105,7 @@ extern int ipc_msg_send_status(Socket *s, char *buf);
 extern int ipc_msg_send_setbaud(Socket *s, int baud);
 extern int ipc_msg_send_sendbreak(Socket *s);
 extern int ipc_msg_send_setflow(Socket *s, int flow);
+extern int ipc_msg_send_setansi(Socket *s, int ansi);
 extern int ipc_msg_send_hangup(Socket *s);
 /* slide.c */
 extern void slide_free(Slide *s);
index 0c69a2b31a3077b7516b1d3b302749aa3efcf603..860928e0135aa5ea81aa0802c22c46921a124047 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.7  2008/02/22 17:07:00  james
+ * *** empty log message ***
+ *
  * Revision 1.6  2008/02/22 14:51:54  james
  * *** empty log message ***
  *
@@ -145,7 +148,7 @@ ptty_open (char *path, char *argv[])
     case -1:                   /*boo hiss */
       return NULL;
     case 0:                    /*waaah */
-      setenv ("TERM", "ansi", 1);
+      setenv ("TERM", "xterm", 1);
       setenv ("LANG", "C", 1);
       if (!path)
         path = "/bin/sh";
index d74437f25758299097efaa448b8adf6cff1cefa1..292e15cf1ebfb51252ae51b692cb9e1964fa26f7 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.31  2008/02/22 17:07:00  james
+ * *** empty log message ***
+ *
  * Revision 1.30  2008/02/22 14:51:54  james
  * *** empty log message ***
  *
@@ -416,7 +419,7 @@ vt102_cursor_advance_line (Context * c)
 
       vt102_history (c, v->top_margin, v->bottom_margin);
 
-      crt_scroll_up (&v->crt, v->top_margin, v->bottom_margin, 1);
+      crt_scroll_up (&v->crt, v->top_margin, v->bottom_margin, 1, v->color);
       return;
     }
 
@@ -473,7 +476,7 @@ vt102_cursor_advance (Context * c)
       return;
     }
   v->pending_wrap++;
-  if (c->v->xn_glitch)
+  if (!c->v->xn_glitch)
        vt102_do_pending_wrap(c);
 }
 
@@ -911,7 +914,7 @@ vt102_parse_esc (Context * c, int ch)
         {
           vt102_log_line (c, v->pos.y);
           vt102_history (c, v->top_margin, v->bottom_margin);
-          crt_scroll_up (&v->crt, v->top_margin, v->bottom_margin, 1);
+          crt_scroll_up (&v->crt, v->top_margin, v->bottom_margin, 1,v->color);
         }
       else
         {
@@ -924,7 +927,7 @@ vt102_parse_esc (Context * c, int ch)
     case 'M':
       if (v->pos.y == v->top_margin.y)
         {
-          crt_scroll_down (&v->crt, v->top_margin, v->bottom_margin, 1);
+          crt_scroll_down (&v->crt, v->top_margin, v->bottom_margin, 1,v->color);
         }
       else
         {
@@ -1035,13 +1038,13 @@ vt102_parse_csi (Context * c, char *buf, int len)
           switch (narg)
             {
             case 0:
-              crt_erase (&v->crt, v->pos, v->screen_end, 1);
+              crt_erase (&v->crt, v->pos, v->screen_end, 1,v->color);
               break;
             case 1:
-              crt_erase (&v->crt, v->screen_start, v->pos, 1);
+              crt_erase (&v->crt, v->screen_start, v->pos, 1,v->color);
               break;
             case 2:
-              crt_erase (&v->crt, v->screen_start, v->screen_end, 1);
+              crt_erase (&v->crt, v->screen_start, v->screen_end, 1,v->color);
               break;
             }
           break;
@@ -1055,13 +1058,13 @@ vt102_parse_csi (Context * c, char *buf, int len)
             switch (narg)
               {
               case 0:
-                crt_erase (&v->crt, v->pos, le, 1);
+                crt_erase (&v->crt, v->pos, le, 1,v->color);
                 break;
               case 1:
-                crt_erase (&v->crt, ls, v->pos, 1);
+                crt_erase (&v->crt, ls, v->pos, 1,v->color);
                 break;
               case 2:
-                crt_erase (&v->crt, ls, le, 1);
+                crt_erase (&v->crt, ls, le, 1,v->color);
                 break;
               }
           }
@@ -1072,7 +1075,7 @@ vt102_parse_csi (Context * c, char *buf, int len)
               && (v->pos.y <= v->bottom_margin.y))
             {
               while (narg--)
-                crt_scroll_down (&v->crt, v->pos, v->bottom_margin, 1);
+                crt_scroll_down (&v->crt, v->pos, v->bottom_margin, 1,v->color);
             }
           break;
 
@@ -1083,7 +1086,7 @@ vt102_parse_csi (Context * c, char *buf, int len)
               while (narg--)
                 {
                   vt102_history (c, v->pos, v->bottom_margin);
-                  crt_scroll_up (&v->crt, v->pos, v->bottom_margin, 1);
+                  crt_scroll_up (&v->crt, v->pos, v->bottom_margin, 1,v->color);
                 }
             }
           break;
@@ -1098,12 +1101,12 @@ vt102_parse_csi (Context * c, char *buf, int len)
           while (narg--)
             {
               vt102_history (c, v->top_margin, v->bottom_margin);
-              crt_scroll_up (&v->crt, v->top_margin, v->bottom_margin, 1);
+              crt_scroll_up (&v->crt, v->top_margin, v->bottom_margin, 1,v->color);
             }
           break;
         case 'T':
           while (narg--)
-            crt_scroll_down (&v->crt, v->top_margin, v->bottom_margin, 1);
+            crt_scroll_down (&v->crt, v->top_margin, v->bottom_margin, 1,v->color);
           break;
         case 'X':
           {
@@ -1114,7 +1117,7 @@ vt102_parse_csi (Context * c, char *buf, int len)
             if (end.x > v->bottom_margin.x)
               end.x = v->bottom_margin.x;
 
-            crt_erase (&v->crt, v->pos, end, 1);
+            crt_erase (&v->crt, v->pos, end, 1,v->color);
           }
           break;
         case 'Z':
@@ -1237,10 +1240,28 @@ vt102_parse_char (Context * c, int ch)
   VT102_parser *p = &v->parser;
 
 #if 1
-  log_f (c->l, "char %3d %c pc %d %d     %2d %2d %d",ch,safe_ch(ch),
-           p->in_csi, p->in_escape, v->pos.x, v->pos.y,v->pending_wrap);
+  log_f (c->l, "char %3d %c pc %d %d %d     %2d %2d %d",ch,safe_ch(ch),
+           p->in_utf8,p->in_escape, p->in_csi, v->pos.x, v->pos.y,v->pending_wrap);
 #endif
-  if (p->in_csi)
+
+  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)
     {
       p->csi_buf[p->csi_ptr++] = ch;
       if (csi_ender (ch) || (p->csi_ptr == VT102_CSI_LEN))
@@ -1275,6 +1296,12 @@ vt102_parse_char (Context * c, int ch)
           vt102_parse_esc (c, ch);
         }
     }
+  else if (ch==0x9b) /*One byte CSI*/
+    {
+          p->csi_ptr = 0;
+         p->csi_buf[p->csi_ptr++] = '[';
+          p->in_csi++;
+   }
   else
     {
 
@@ -1582,7 +1609,6 @@ vt102_reset (VT102 * v)
 
   v->last_reg_char = ' ';
 
-  v->xn_glitch=0;
 
 }
 
@@ -1630,6 +1656,7 @@ vt102_new (void)
   VT102 *v;
 
   v = (VT102 *) malloc (sizeof (VT102));
+  v->xn_glitch=1;
 
   vt102_reset (v);
 
@@ -1637,6 +1664,11 @@ vt102_new (void)
   return v;
 }
 
+void vt102_set_ansi(VT102 *v,int ansi)
+{
+v->xn_glitch=ansi ? 0:1;
+}
+
 void
 vt102_free (VT102 * v)
 {
index 7537969e617ddf3540e87878529da74fb507cb8c..9d7f9d689ab6168ab416b3537eeaa117bff2358c 100644 (file)
@@ -12,6 +12,9 @@
 
 /*
  * $Log$
+ * Revision 1.13  2008/02/22 17:07:00  james
+ * *** empty log message ***
+ *
  * Revision 1.12  2008/02/22 14:51:54  james
  * *** empty log message ***
  *
 
 #define VT102_NMODES           32
 
+
 typedef struct
 {
   int in_escape;
   int in_csi;
+  int in_utf8;
   int csi_ptr;
   char csi_buf[VT102_CSI_LEN];
 } VT102_parser;
@@ -100,7 +105,6 @@ typedef struct
   int application_keypad_mode;
 
   char last_reg_char;
-
   int xn_glitch;
 
 } VT102;