chiark / gitweb /
@@
[sympathy.git] / src / ansi.c
index 7f44957cbb0516b708b7202e16e0b690de73d202..8d4d640e9b07460d4c76da33f62c70001b96cec2 100644 (file)
@@ -10,6 +10,24 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.25  2008/02/20 19:44:37  james
+ * @@
+ *
+ * Revision 1.24  2008/02/20 19:36:06  james
+ * @@
+ *
+ * Revision 1.23  2008/02/20 19:25:09  james
+ * *** empty log message ***
+ *
+ * Revision 1.22  2008/02/15 03:32:07  james
+ * *** empty log message ***
+ *
+ * Revision 1.21  2008/02/14 02:46:44  james
+ * *** empty log message ***
+ *
+ * Revision 1.20  2008/02/14 01:55:57  james
+ * *** empty log message ***
+ *
  * Revision 1.19  2008/02/13 16:57:29  james
  * *** empty log message ***
  *
@@ -71,7 +89,7 @@ static char rcsid[] = "$Id$";
 #include "project.h"
 
 
-void
+static void
 ansi_move (ANSI * a, CRT_Pos p)
 {
   char buf[16];
@@ -161,7 +179,7 @@ ansi_move (ANSI * a, CRT_Pos p)
 }
 
 
-void
+static void
 ansi_showhide_cursor (ANSI * a, int hide)
 {
   if (a->hide_cursor == hide)
@@ -180,7 +198,7 @@ ansi_showhide_cursor (ANSI * a, int hide)
 }
 
 
-void
+static void
 ansi_force_attr_normal (ANSI * a)
 {
   a->terminal->xmit (a->terminal, "\033[0m", 4);
@@ -188,7 +206,7 @@ ansi_force_attr_normal (ANSI * a)
   a->color = ANSI_INVAL;
 }
 
-void
+static void
 ansi_set_color (ANSI * a, int color)
 {
   int dif;
@@ -229,7 +247,7 @@ ansi_set_color (ANSI * a, int color)
     }
 }
 
-void
+static void
 ansi_set_attr (ANSI * a, int attr)
 {
   int dif;
@@ -287,7 +305,7 @@ ansi_set_attr (ANSI * a, int attr)
 }
 
 
-void
+static void
 ansi_render (ANSI * a, CRT_CA ca)
 {
   int dif;
@@ -312,7 +330,7 @@ ansi_render (ANSI * a, CRT_CA ca)
 
 }
 
-void
+static void
 ansi_cls (ANSI * a)
 {
   CRT_Pos p = { 0 };
@@ -359,7 +377,7 @@ ansi_scroll_up (ANSI * a, CRT_Pos s, CRT_Pos e)
 }
 
 
-void
+static void
 ansi_spot_scroll_up (ANSI * a, CRT * c)
 {
   int l, n, p;
@@ -394,7 +412,7 @@ ansi_spot_scroll_up (ANSI * a, CRT * c)
 
 }
 
-void
+static void
 ansi_spot_scroll (ANSI * a, CRT * c)
 {
 
@@ -412,7 +430,7 @@ ansi_spot_scroll (ANSI * a, CRT * c)
 #endif
 
 
-void
+static void
 ansi_draw_line (ANSI * a, CRT_CA * cap, int y)
 {
   CRT_Pos p = { 0, y };
@@ -437,7 +455,7 @@ ansi_draw_line (ANSI * a, CRT_CA * cap, int y)
     }
 }
 
-void
+static void
 ansi_resize_check (ANSI * a)
 {
 
@@ -466,7 +484,7 @@ ansi_resize_check (ANSI * a)
 #define HISTORY_GUESS_SCROLL 24 /*guess all 24 lines usually scroll */
 /*if they haven't then ansi_draw will patch it up*/
 
-void
+static void
 ansi_history (ANSI * a, History * h)
 {
   char buf[32];
@@ -542,7 +560,7 @@ ansi_history (ANSI * a, History * h)
 
 
 
-void
+static void
 ansi_draw (ANSI * a, CRT * c)
 {
   CRT_Pos p;
@@ -597,14 +615,14 @@ ansi_draw (ANSI * a, CRT * c)
   ansi_showhide_cursor (a, a->crt.hide_cursor);
 }
 
-void
+static void
 ansi_reset (ANSI * a, CRT * c)
 {
   a->size.x = -1;
   ansi_draw (a, c ? c : &a->crt);
 }
 
-void
+static void
 ansi_terminal_reset (ANSI * a)
 {
   CRT_Pos p = { 0, CRT_ROWS };
@@ -613,7 +631,7 @@ ansi_terminal_reset (ANSI * a)
   ansi_move (a, p);
 }
 
-void
+static void
 ansi_flush_escape (ANSI * a, Context * c)
 {
   ANSI_Parser *p = &a->parser;
@@ -621,14 +639,14 @@ ansi_flush_escape (ANSI * a, Context * c)
 
   for (i = 0; i < p->escape_ptr; ++i)
     {
-      vt102_send (c, p->escape_buf[i]);
+      keydis_key (c->k, c, p->escape_buf[i]);
     }
 
   p->escape_ptr = 0;
   p->in_escape = 0;
 }
 
-void
+static void
 ansi_parse_deckey (ANSI * a, Context * c)
 {
   ANSI_Parser *p = &a->parser;
@@ -640,11 +658,11 @@ ansi_parse_deckey (ANSI * a, Context * c)
 
   if ((p->escape_buf[2] >= 'A') || (p->escape_buf[2] <= 'Z'))
     {
-      vt102_send (c, KEY_UP + (p->escape_buf[2] - 'A'));
+      keydis_key (c->k, c, KEY_UP + (p->escape_buf[2] - 'A'));
     }
   else if ((p->escape_buf[2] >= 'a') || (p->escape_buf[2] <= 'z'))
     {
-      vt102_send (c, KEY_154 + (p->escape_buf[2] - 'a'));
+      keydis_key (c->k, c, KEY_154 + (p->escape_buf[2] - 'a'));
     }
   else
     {
@@ -655,7 +673,7 @@ ansi_parse_deckey (ANSI * a, Context * c)
   p->escape_ptr = 0;
 }
 
-void
+static void
 ansi_parse_ansikey (ANSI * a, Context * c)
 {
   ANSI_Parser *p = &a->parser;
@@ -667,7 +685,7 @@ ansi_parse_ansikey (ANSI * a, Context * c)
     }
   if ((p->escape_buf[2] >= '0') || (p->escape_buf[2] <= '9'))
     {
-      vt102_send (c, KEY_180 + (p->escape_buf[2] - '0'));
+      keydis_key (c->k, c, KEY_180 + (p->escape_buf[2] - '0'));
     }
   else
     {
@@ -681,7 +699,7 @@ ansi_parse_ansikey (ANSI * a, Context * c)
 
 
 
-void
+static void
 ansi_parse_escape (ANSI * a, Context * c)
 {
   ANSI_Parser *p = &a->parser;
@@ -730,7 +748,7 @@ ansi_parse_escape (ANSI * a, Context * c)
 }
 
 
-void
+static void
 ansi_check_escape (ANSI * a, Context * c)
 {
   ANSI_Parser *p = &a->parser;
@@ -754,7 +772,7 @@ ansi_check_escape (ANSI * a, Context * c)
 }
 
 
-void
+static void
 ansi_parse_char (ANSI * a, Context * c, int ch)
 {
   ANSI_Parser *p = &a->parser;
@@ -780,12 +798,12 @@ ansi_parse_char (ANSI * a, Context * c, int ch)
     }
   else
     {
-      vt102_send (c, ch);
+      keydis_key (c->k, c, ch);
     }
 
 }
 
-void
+static void
 ansi_parse (ANSI * a, Context * c, char *buf, int len)
 {
   while (len--)
@@ -802,7 +820,7 @@ ansi_dispatch (ANSI * a, Context * c)
 
 
   if (!a->terminal)
-    return;
+    return 0;
 
   red = a->terminal->recv (a->terminal, buf, sizeof (buf));
   if (red <= 0)
@@ -813,17 +831,14 @@ ansi_dispatch (ANSI * a, Context * c)
     return -1;
 #endif
 
-#if 1
-  if (*buf == 1)
-    {
-      ansi_reset (a, NULL);
-      return 0;
-    }
+#if 0
   if (*buf == 2)
     {
+#if  0
       a->history_ptr = c->h->wptr;
       HISTORY_INC (c->h, a->history_ptr);
-      return 0;
+#endif
+      return -1;
     }
 #endif
 
@@ -834,9 +849,35 @@ ansi_dispatch (ANSI * a, Context * c)
 }
 
 
-void
+static void
 ansi_update (ANSI * a, Context * c)
 {
   ansi_history (a, c->h);
   ansi_draw (a, &c->v->crt);
 }
+
+static void ansi_free(ANSI *a)
+{
+      a->terminal_reset(a);
+      if (a->terminal) 
+       a->terminal->close(a->terminal);
+
+       free(a);
+
+}
+
+ANSI *ansi_new_from_terminal(ANSI *a,TTY *t)
+{
+ANSI *ret;
+
+ret=malloc(sizeof(ANSI));
+memset(ret,0,sizeof(ANSI));
+
+ret->terminal=t;
+
+ret->update=ansi_update;
+ret->reset=ansi_reset;
+ret->terminal_reset=ansi_terminal_reset;
+ret->close=ansi_free;
+
+}