chiark / gitweb /
*** empty log message ***
authorjames <james>
Mon, 4 Feb 2008 02:05:06 +0000 (02:05 +0000)
committerjames <james>
Mon, 4 Feb 2008 02:05:06 +0000 (02:05 +0000)
src/ansi.c
src/crt.c
src/html.c
src/libsympathy.c
src/project.h
src/render.c
src/testtty.c
src/version.c
src/vt102.c
src/vt102.h

index 5d6105eb83437fb366cd78d0db48a60a70219a05..49a7bc9b331e8d9db9229ea9e295c0ef77df7f36 100644 (file)
@@ -10,10 +10,14 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.2  2008/02/04 02:05:06  james
+ * *** empty log message ***
+ *
  * Revision 1.1  2008/02/03 23:31:25  james
  * *** empty log message ***
  *
  */
+#include "project.h"
 
 void
 ansi_write (ANSI * a, char *buf, int n)
@@ -131,60 +135,62 @@ ansi_showhide_cursor (ANSI * a, int hide)
 }
 
 
-void ansi_force_attr_normal(ANSI *a)
+void
+ansi_force_attr_normal (ANSI * a)
 {
   ansi_write (a, "\033[0m", 4);
-  a->attr=CRT_ATTR_NORMAL;
+  a->attr = CRT_ATTR_NORMAL;
 }
 
 void
 ansi_set_attr (ANSI * a, int attr)
 {
+  int dif;
 
   dif = attr ^ a->attr;
 
   if (!dif)
     return;
 
-  if (attr == ATTR_NORMAL)
+  if (attr == CRT_ATTR_NORMAL)
     {
-       ansi_force_attr_normal(a);
-       return;
+      ansi_force_attr_normal (a);
+      return;
     }
 
-      if (dif & CRT_ATTR_UNDERLINE)
+  if (dif & CRT_ATTR_UNDERLINE)
+    {
+      if (attr & CRT_ATTR_UNDERLINE)
         {
-          if (attr & CRT_ATTR_UNDERLINE)
-            {
-              ansi_write (a, "\033[4m", 4);
-            }
-          else
-            {
-              ansi_write (a, "\033[24m", 5);
-            }
+          ansi_write (a, "\033[4m", 4);
         }
-      if (dif & CRT_ATTR_REVERSE)
+      else
         {
-          if (attr & CRT_ATTR_REVERSE)
-            {
-              ansi_write (a, "\033[7m", 4);
-            }
-          else
-            {
-              ansi_write (a, "\033[27m", 5);
-            }
+          ansi_write (a, "\033[24m", 5);
+        }
+    }
+  if (dif & CRT_ATTR_REVERSE)
+    {
+      if (attr & CRT_ATTR_REVERSE)
+        {
+          ansi_write (a, "\033[7m", 4);
         }
-      if (dif & CRT_ATTR_BOLD)
+      else
         {
-          if (attr & CRT_ATTR_REVERSE)
-            {
-              ansi_write (a, "\033[1m", 4);
-            }
-          else
-            {
-              ansi_write (a, "\033[22m", 5);
-            }
+          ansi_write (a, "\033[27m", 5);
         }
+    }
+  if (dif & CRT_ATTR_BOLD)
+    {
+      if (attr & CRT_ATTR_REVERSE)
+        {
+          ansi_write (a, "\033[1m", 4);
+        }
+      else
+        {
+          ansi_write (a, "\033[22m", 5);
+        }
+    }
 }
 
 
@@ -218,7 +224,7 @@ ansi_cls (ANSI * a)
   CRT_Pos p = { 0 };
 
   crt_cls (&a->crt);
-  ansi_force_attr_normal(a);
+  ansi_force_attr_normal (a);
   ansi_move (a, p);
   ansi_write (a, "\033[2J", 4);
 /*different emulators leave cursor in different places after cls differently*/
@@ -238,17 +244,17 @@ ansi_draw (ANSI * a, CRT * c)
     {
       if (p.y >= a->size.y)
         continue;
-      o = CRT_ADDR (r, 0);
+      o = CRT_ADDR (p.y, 0);
       for (p.x = 0; p.x < CRT_COLS; ++p.x, ++o)
         {
           if (p.x >= a->size.x)
             continue;
-          if (crt_ca_cmp (a->crt.screen[p], c->screen[p]))
+          if (crt_ca_cmp (a->crt.screen[o], c->screen[o]))
             {
-              a->crt.screen[p] = c->screen[p];
+              a->crt.screen[o] = c->screen[o];
 
               ansi_move (a, p);
-              ansi_render (a, a->crt.screen[p]);
+              ansi_render (a, a->crt.screen[o]);
             }
         }
     }
@@ -257,7 +263,7 @@ ansi_draw (ANSI * a, CRT * c)
   ansi_move (a, a->crt.pos);
 
   a->crt.hide_cursor = c->hide_cursor;
-  ansi_showhide_cursor (a, ci->crt.hide_cursor);
+  ansi_showhide_cursor (a, a->crt.hide_cursor);
 }
 
 void
index 24c0f02128b1baf4b0c43bbd1eea65531a1a157c..8b7f9d58ee961c812dd7e0c234fe1b6000b4a075 100644 (file)
--- a/src/crt.c
+++ b/src/crt.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.2  2008/02/04 02:05:06  james
+ * *** empty log message ***
+ *
  * Revision 1.1  2008/02/03 23:31:25  james
  * *** empty log message ***
  *
@@ -17,35 +20,42 @@ static char rcsid[] = "$Id$";
 
 #include "project.h"
 
-void crt_cls(CRT *c)
+void
+crt_cls (CRT * c)
 {
-int i;
+  int i;
 
-for (i=0;i<CRT_CELS;++i) {
-       c->screen[i].chr=' ';
-       c->screen[i].chr=CRT_ATTR_NORMAL;
-}
+  for (i = 0; i < CRT_CELS; ++i)
+    {
+      c->screen[i].chr = ' ';
+      c->screen[i].chr = CRT_ATTR_NORMAL;
+    }
 }
 
-void crt_reset(CRT *c)
+void
+crt_reset (CRT * c)
 {
-crt_cls(c);
+  crt_cls (c);
 
-crt->pos.x=0;
-crt->pos.y=0;
-crt->hide_cursor=1;
+  c->pos.x = 0;
+  c->pos.y = 0;
+  c->hide_cursor = 1;
 }
 
-void crt_insert(CRT *c,CRT_CA ca)
+void
+crt_insert (CRT * c, CRT_CA ca)
 {
-if (c->pos.x<0) c->pos.x=0;
-if (c->pos.x>=CRT_COLS) c->pos.x=CRT_COLS-1;
-if (c->pos.y<0) c->pos.y=0;
-if (c->pos.y>=CRT_ROWS) c->pos.y=CRT_ROWS-1;
+  if (c->pos.x < 0)
+    c->pos.x = 0;
+  if (c->pos.x >= CRT_COLS)
+    c->pos.x = CRT_COLS - 1;
+  if (c->pos.y < 0)
+    c->pos.y = 0;
+  if (c->pos.y >= CRT_ROWS)
+    c->pos.y = CRT_ROWS - 1;
 
-crt->screen[CRT_ADDR(c->pos.y,c->pos.x)]=ca;
+  c->screen[CRT_ADDR (c->pos.y, c->pos.x)] = ca;
 
 
 
 }
-
index 5f48fe378c7b45a9eda10b437b8b2a4c15c6c7d1..db142a901cf4bd36ab82bbe1dcd450e86563e612 100644 (file)
@@ -10,11 +10,16 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.2  2008/02/04 02:05:06  james
+ * *** empty log message ***
+ *
  * Revision 1.1  2008/02/03 23:31:25  james
  * *** empty log message ***
  *
  */
 
+#include "project.h"
+
 void
 html_entity (FILE * f, int c)
 {
index 40f8a9d247498b867d1bf21f5116dd2e1d8f3f20..d43bbc558c55d88a2aef42591774a08697ac3858 100644 (file)
@@ -6,10 +6,14 @@
  *
  */
 
-static char rcsid[] = "$Id$";
+static char rcsid[] =
+  "$Id$";
 
 /*
  * $Log$
+ * Revision 1.2  2008/02/04 02:05:06  james
+ * *** empty log message ***
+ *
  * Revision 1.1  2008/02/03 16:20:24  james
  * *** empty log message ***
  *
@@ -17,4 +21,3 @@ static char rcsid[] = "$Id$";
  */
 
 #include "project.h"
-
index 079f38a48b1ce068184520a12d98f965e32290ee..9ce651fdf33eb0c35b277d13432e311194e323e5 100644 (file)
@@ -12,6 +12,9 @@
 
 /*
  * $Log$
+ * Revision 1.2  2008/02/04 02:05:06  james
+ * *** empty log message ***
+ *
  * Revision 1.1  2008/02/03 16:20:24  james
  * *** empty log message ***
  *
 #include <sys/int_types.h>
 #endif
 
+#include <termio.h>
+#include <termios.h>
+
+#include "crt.h"
+#include "ansi.h"
+#include "vt102.h"
+
 #include "prototypes.h"
 
 #endif /* __PROJECT_H__ */
index 6ef0e67fd52593d3c41d3bea59c82c7780fce592..52fa0fffc5d6ee1eed74e6aa888b46ac24061651 100644 (file)
@@ -10,19 +10,10 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.2  2008/02/04 02:05:06  james
+ * *** empty log message ***
+ *
  * Revision 1.1  2008/02/03 23:31:25  james
  * *** empty log message ***
  *
  */
-
-
-
-
-
-
-
-
-
-}
-
-
index 2cef3e0bda8e59956cbf74a32118ab3eeca23dee..dbdc918635b6dcb9da95563c334041eb3780cd78 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.2  2008/02/04 02:05:06  james
+ * *** empty log message ***
+ *
  * Revision 1.1  2008/02/04 01:32:39  james
  * *** empty log message ***
  *
@@ -17,60 +20,63 @@ static char rcsid[] = "$Id$";
 
 #include "project.h"
 
-static void  default_termios(struct termios *termios)
+static void
+default_termios (struct termios *termios)
 {
 
-memset(termios,0,sizeof(termios));
-
-termios->c_iflag=ICRNL|IXON;
-termios->c_oflag=OPOST | ONLCR | NL0 | CR0 | TAB0 | BS0 | VT0 | FF0;
-termios->c_lflag=ISIG | ICANON | IEXTEN | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE;
-
-termios->c_cc[VINTR]=003;
-termios->c_cc[VQUIT]=034;
-termios->c_cc[VERASE]=0177;
-termios->c_cc[VKILL]=025;
-termios->c_cc[VEOF]=004;
-termios->c_cc[VEOL]=0;
-termios->c_cc[VEOL2]=0;
-termios->c_cc[VSTART]=021;
-termios->c_cc[VSTOP]=023;
-termios->c_cc[VSUSP]=032;
-termios->c_cc[VLNEXT]=026;
-termios->c_cc[VWERASE]=027;
-termios->c_cc[VREPRINT]=022;
-termios->c_cc[VDISCARD]=017;
-
-termios->c_cflag=CS8 | CREAD | CLOCAL;
-
-cfsetispeed(termios,B9600);
-cfsetospeed(termios,B9600);
+  memset (termios, 0, sizeof (termios));
+
+  termios->c_iflag = ICRNL | IXON;
+  termios->c_oflag = OPOST | ONLCR | NL0 | CR0 | TAB0 | BS0 | VT0 | FF0;
+  termios->c_lflag =
+    ISIG | ICANON | IEXTEN | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE;
+
+  termios->c_cc[VINTR] = 003;
+  termios->c_cc[VQUIT] = 034;
+  termios->c_cc[VERASE] = 0177;
+  termios->c_cc[VKILL] = 025;
+  termios->c_cc[VEOF] = 004;
+  termios->c_cc[VEOL] = 0;
+  termios->c_cc[VEOL2] = 0;
+  termios->c_cc[VSTART] = 021;
+  termios->c_cc[VSTOP] = 023;
+  termios->c_cc[VSUSP] = 032;
+  termios->c_cc[VLNEXT] = 026;
+  termios->c_cc[VWERASE] = 027;
+  termios->c_cc[VREPRINT] = 022;
+  termios->c_cc[VDISCARD] = 017;
+
+  termios->c_cflag = CS8 | CREAD | CLOCAL;
+
+  cfsetispeed (termios, B9600);
+  cfsetospeed (termios, B9600);
 }
 
 
-int open_fd_to_bash(void) /*thump*/
+int
+open_fd_to_bash (void)          /*thump */
 {
-pid_t child;
-int fd;
-struct winsize winsize={0};
-struct termios termios;
+  pid_t child;
+  int fd;
+  struct winsize winsize = { 0 };
+  struct termios termios;
 
-default_termios(&termios);
+  default_termios (&termios);
 
-winsize.ws_row=CRT_ROWS;
-winsize.ws_col=CRT_COLS;
+  winsize.ws_row = CRT_ROWS;
+  winsize.ws_col = CRT_COLS;
 
-child=forkpty(&fd,NULL,&termios,&winsize);
+  child = forkpty (&fd, NULL, &termios, &winsize);
 
-switch (child) 
-{
-case -1:/*boo hiss*/
-       return -1;
-case 0: /*waaah*/
-       setenv("TERM","vt102",1);
-       execl("/bin/sh","-",(char *) 0);
-       _exit(-1);
-}
+  switch (child)
+    {
+    case -1:                   /*boo hiss */
+      return -1;
+    case 0:                    /*waaah */
+      setenv ("TERM", "vt102", 1);
+      execl ("/bin/sh", "-", (char *) 0);
+      _exit (-1);
+    }
 
-return fd;
+  return fd;
 }
index 244ade03c9ee1a98717b5168ea345accea230e36..651093db5aa90e38c2582d2398e0577697a590dc 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.2  2008/02/04 02:05:06  james
+ * *** empty log message ***
+ *
  * Revision 1.1  2008/02/03 16:20:24  james
  * *** empty log message ***
  *
@@ -19,7 +22,7 @@ static char rcsid[] = "$Id$";
 #include "version.h"
 
 static char *
-GetVersion(void)
+GetVersion (void)
 {
   return VERSION;
 }
index eb365daff45a856219f121eeede4642f8e60e63c..8a7dc56ebae2ca4abeda216007afb5af0e58ca58 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.3  2008/02/04 02:05:06  james
+ * *** empty log message ***
+ *
  * Revision 1.2  2008/02/04 01:32:39  james
  * *** empty log message ***
  *
@@ -104,6 +107,8 @@ ESC[?8h
 
 */
 
+#include "project.h"
+
 
 static inline int
 csi_ender (int c)
@@ -128,63 +133,74 @@ csi_starter (int c)
   return 0;
 }
 
-void vt102_cursor_normalize(VT102 *v,int wrap,int scroll)
+void
+vt102_cursor_normalize (VT102 * v, int wrap, int scroll)
 {
-       if (v->pos.x<-1)   /*don't wrap backwards*/
-               c->pos.x=0;
-
-       if (v->pos.x>=CRT_COLS)  {
-       if (wrap) {
-               c->pos.x=0;
-               c->pos.y++;
-       } else {
-               c->pos.x=CRT_COLS-1;
-       }
-       } 
-
-       if (v->pos.y<0)  
-               c->pos.y=0
-
-       if (v->pos.y>=CRT_ROWS)  {
-       if (scroll) 
-               vt102_scroll(v,0,CRT_ROWS-1);
-               c->pos.y=CRT_ROWS-1;
-       } 
+  if (v->pos.x < -1)            /*don't wrap backwards */
+    v->pos.x = 0;
+
+  if (v->pos.x >= CRT_COLS)
+    {
+      if (wrap)
+        {
+          v->pos.x = 0;
+          v->pos.y++;
+        }
+      else
+        {
+          v->pos.x = CRT_COLS - 1;
+        }
+    }
+
+  if (v->pos.y < 0)
+    v->pos.y = 0;
+
+  if (v->pos.y >= CRT_ROWS)
+    {
+      if (scroll)
+        vt102_scroll (v, 0, CRT_ROWS - 1);
+      v->pos.y = CRT_ROWS - 1;
+    }
 }
 
-       
-void vt102_cursor_motion(VT102 *v,int x,int y,int wrap,scroll)
+
+void
+vt102_cursor_motion (VT102 * v, int x, int y, int wrap, int scroll)
 {
-while (x>0) {
-       x--;
-       v->pos.x++;
-       vt102_cursor_normalize(v,wrap,scroll);
-}
-               
-while (x<0) {
-       x++;
-       v->pos.x--;
-       vt102_cursor_normalize(v,wrap,scroll);
-}
-       
-while (y>0) {
-       y--;
-       v->pos.y++;
-       vt102_cursor_normalize(v,wrap,scroll);
-}
-               
-while (y<0) {
-       y++;
-       v->pos.y--;
-       vt102_cursor_normalize(v,wrap,scroll);
+  while (x > 0)
+    {
+      x--;
+      v->pos.x++;
+      vt102_cursor_normalize (v, wrap, scroll);
+    }
+
+  while (x < 0)
+    {
+      x++;
+      v->pos.x--;
+      vt102_cursor_normalize (v, wrap, scroll);
+    }
+
+  while (y > 0)
+    {
+      y--;
+      v->pos.y++;
+      vt102_cursor_normalize (v, wrap, scroll);
+    }
+
+  while (y < 0)
+    {
+      y++;
+      v->pos.y--;
+      vt102_cursor_normalize (v, wrap, scroll);
+    }
 }
-}      
 
 
 void
 vt102_parse_char (VT102 * v, int c)
 {
-  VT102_parser *p = &v->p;
+  VT102_parser *p = &v->parser;
 
 
   if (p->in_csi)
@@ -225,27 +241,27 @@ vt102_parse_char (VT102 * v, int c)
          /*ACK*/ case 6:
          /*BEL*/ case 7:
          /*BS*/ case 8:
-               vt102_cursor_motion(v,-1,0,0,0);
+          vt102_cursor_motion (v, -1, 0, 0, 0);
           break;
          /*HT*/ case 9:
           break;
          /*LF*/ case 10:
-               vt102_cursor_motion(v,0,1,0,1);
+          vt102_cursor_motion (v, 0, 1, 0, 1);
           break;
          /*VT*/ case 11:
           break;
          /*FF*/ case 12:
           break;
          /*CR*/ case 13:
-               v->pos.x=0;
+          v->pos.x = 0;
           break;
          /*SO*/ case 14:
          /*SI*/ case 15:
          /*DLE*/ case 16:
-        /*DC1*/ case 17:
-        /*DC2*/ case 18:
-        /*DC3*/ case 19:
-        /*DC4*/ case 20:
+        /*DC1 */ case 17:
+        /*DC2 */ case 18:
+        /*DC3 */ case 19:
+        /*DC4 */ case 20:
          /*NAK*/ case 21:
          /*SYN*/ case 22:
          /*ETB*/ case 23:
@@ -262,10 +278,10 @@ vt102_parse_char (VT102 * v, int c)
          /*US*/ case 31:
          /*DEL*/ case 127:
           break;
-        /*regular character*/ default:
-               v->crt->screen[CRT_ADDR_POS(&v->pos)].chr=c;
-               v->crt->screen[CRT_ADDR_POS(&v->pos)].attr=v->attr;
-               vt102_cursor_motion(v,1,0);
+        /*regular character */ default:
+          v->crt.screen[CRT_ADDR_POS (&v->pos)].chr = c;
+          v->crt.screen[CRT_ADDR_POS (&v->pos)].attr = v->attr;
+          vt102_cursor_motion (v, 1, 0, 1, 1);
         }
     }
 }
index e5b62a58031bf4370b621486cf571882c058886f..5a2d68603d73762b834ce3bd6a77b460ef76091c 100644 (file)
@@ -12,6 +12,9 @@
 
 /*
  * $Log$
+ * Revision 1.2  2008/02/04 02:05:06  james
+ * *** empty log message ***
+ *
  * Revision 1.1  2008/02/03 23:36:41  james
  * *** empty log message ***
  *
@@ -32,13 +35,10 @@ typedef struct
 
 typedef struct
 {
-  VT102_parser p;
+  VT102_parser parser;
   int attr;
   CRT crt;
-  CRT_Pos p;
-
-
-
+  CRT_Pos pos;
 } VT102;