chiark / gitweb /
*** empty log message ***
authorjames <james>
Tue, 26 Feb 2008 23:56:12 +0000 (23:56 +0000)
committerjames <james>
Tue, 26 Feb 2008 23:56:12 +0000 (23:56 +0000)
apps/mainloop.c
src/ansi.c
src/crt.c
src/terminal.c
src/utf8.c
src/vt102.c
src/vt102_charset.c

index 9e378d18b0a6ad8549aa08a6d1b9099af9173b15..3f1c28dbfec8e1c3897776105b419c52bdd06504 100644 (file)
@@ -11,6 +11,9 @@ static char rcsid[] =
 
 /*
  * $Log$
+ * Revision 1.13  2008/02/26 23:56:12  james
+ * *** empty log message ***
+ *
  * Revision 1.12  2008/02/26 23:23:16  james
  * *** empty log message ***
  *
@@ -394,7 +397,7 @@ mainloop (TTY * tty, Socket * server_socket, Socket * client_socket,
   Context c = { 0 };
   Clients *clients;
 
-  context=&c;
+  context = &c;
 
   c.tp = tty_parser_new ();
   c.u = utf8_new ();
index 3e4ace1c9ac0ed57c92f377411eed8ecdbe99ad9..e029c25d9cdc748412630d924eb872249984c421 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.32  2008/02/26 23:56:12  james
+ * *** empty log message ***
+ *
  * Revision 1.31  2008/02/26 23:23:17  james
  * *** empty log message ***
  *
@@ -325,36 +328,40 @@ ansi_set_attr (ANSI * a, int attr)
 static void
 ascii_emit (TTY * t, uint32_t ch)
 {
-int i;
-       
+  int i;
+
 /*Some quick obvious subsititons for quotation marks*/
-switch(ch) {
-case 0x2018:
-       ch='`';
-       break;
-case 0x2019:
-       ch='\'';
-       break;
-case 0x201c:
-case 0x201d:
-       ch='"';
-       break;
-}
+  switch (ch)
+    {
+    case 0x2018:
+      ch = '`';
+      break;
+    case 0x2019:
+      ch = '\'';
+      break;
+    case 0x201c:
+    case 0x201d:
+      ch = '"';
+      break;
+    }
 
 /*Short cut the easy stuff*/
-if (ch<0x7f)  {
-  uint8_t c = ch ;
-  t->xmit (t, &c, 1);
-  return;
-}
+  if (ch < 0x7f)
+    {
+      uint8_t c = ch;
+      t->xmit (t, &c, 1);
+      return;
+    }
 
-for (i=0;i<VT102_CHARSET_SIZE;++i) {
-if (vt102_charset_gl[i]==ch) {
-  uint8_t c[3] ={016,i,017};
-  t->xmit (t, &c, 3);
-  return;
-}
-}      
+  for (i = 0; i < VT102_CHARSET_SIZE; ++i)
+    {
+      if (vt102_charset_gl[i] == ch)
+        {
+          uint8_t c[3] = { 016, i, 017 };
+          t->xmit (t, &c, 3);
+          return;
+        }
+    }
 
   t->xmit (t, "?", 1);
 
@@ -366,7 +373,7 @@ ansi_render (ANSI * a, CRT_CA ca)
   int dif;
 
   if ((ca.chr < VT102_CHARSET_SIZE) && (vt102_charset_c0[ca.chr]))
-       ca.chr=vt102_charset_c0[ca.chr];
+    ca.chr = vt102_charset_c0[ca.chr];
 
   if ((ca.chr >= 0x80) && (ca.chr < 0xa0))
     ca.chr = ' ';
@@ -377,7 +384,7 @@ ansi_render (ANSI * a, CRT_CA ca)
   if (a->utf8)
     utf8_emit (a->terminal, ca.chr);
   else
-    ascii_emit(a->terminal,ca.chr);
+    ascii_emit (a->terminal, ca.chr);
 
   a->pos.x++;
 
@@ -515,41 +522,46 @@ ansi_draw_line (ANSI * a, CRT_CA * cap, int y)
 }
 
 static void
-ansi_resize_check (ANSI * a,int new_width)
+ansi_resize_check (ANSI * a, int new_width)
 {
 
-  if ((new_width && (new_width != a->crt.width)) || crt_pos_cmp (a->terminal->size, a->size)) {
+  if ((new_width && (new_width != a->crt.width))
+      || crt_pos_cmp (a->terminal->size, a->size))
+    {
 
-  terminal_getsize (a->terminal);
+      terminal_getsize (a->terminal);
 
-  a->size = a->terminal->size;
+      a->size = a->terminal->size;
 
-  a->pos.x = ANSI_INVAL;
-  a->hide_cursor = ANSI_INVAL;
+      a->pos.x = ANSI_INVAL;
+      a->hide_cursor = ANSI_INVAL;
 
-  crt_reset (&a->crt);
+      crt_reset (&a->crt);
 
- if (new_width) 
-       a->crt.width=new_width;
+      if (new_width)
+        a->crt.width = new_width;
 
 // FIXME: -- echos back crap?
 //  a->terminal->xmit (a->terminal, "\033[c", 3);
 
 // maybe - issue 132 column command if we're 132?
 
-  ansi_cls (a);
-  a->terminal->xmit (a->terminal, "\033=", 2);
-  a->terminal->xmit (a->terminal, "\033[?6l", 5);
-  a->terminal->xmit (a->terminal, "\033[r", 3);
-  if (a->utf8) {
-  a->terminal->xmit (a->terminal,"\033%G",3);
-  } else {
-  a->terminal->xmit (a->terminal,"\033(B",3);
-  a->terminal->xmit (a->terminal,"\033)0",3);
-  a->terminal->xmit (a->terminal,"\017",1);
-  }
+      ansi_cls (a);
+      a->terminal->xmit (a->terminal, "\033=", 2);
+      a->terminal->xmit (a->terminal, "\033[?6l", 5);
+      a->terminal->xmit (a->terminal, "\033[r", 3);
+      if (a->utf8)
+        {
+          a->terminal->xmit (a->terminal, "\033%G", 3);
+        }
+      else
+        {
+          a->terminal->xmit (a->terminal, "\033(B", 3);
+          a->terminal->xmit (a->terminal, "\033)0", 3);
+          a->terminal->xmit (a->terminal, "\017", 1);
+        }
 
-}
+    }
 }
 
 #define HISTORY_GUESS_SCROLL 24 /*guess all 24 lines usually scroll */
@@ -564,7 +576,7 @@ ansi_history (ANSI * a, History * h)
 
   if (a->history_ptr == h->wptr)
     return;
-  ansi_resize_check (a,0);
+  ansi_resize_check (a, 0);
 
   if ((a->size.x < a->crt.width) || (a->size.y < CRT_ROWS))
     return;
@@ -615,7 +627,7 @@ ansi_history (ANSI * a, History * h)
           {
             memcpy (&a->crt.screen[CRT_ADDR_POS (&e)],
                     &a->crt.screen[CRT_ADDR_POS (&s)],
-                    sizeof (CRT_CA)*a->crt.width);
+                    sizeof (CRT_CA) * a->crt.width);
           }
 
         /* erase new line */
@@ -641,7 +653,7 @@ ansi_draw (ANSI * a, CRT * c)
   int o;
   int hidden_cursor = 0;
 
-  ansi_resize_check (a,c->width);
+  ansi_resize_check (a, c->width);
 
 
   for (p.y = 0; p.y < CRT_ROWS; ++p.y)
index 693e00384c55009b88ac019ac21f561922ea0b2e..b9174f9cdb7f5093e01749796d671b4d3e170fe6 100644 (file)
--- a/src/crt.c
+++ b/src/crt.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.13  2008/02/26 23:56:12  james
+ * *** empty log message ***
+ *
  * Revision 1.12  2008/02/26 23:23:17  james
  * *** empty log message ***
  *
@@ -161,7 +164,7 @@ crt_reset (CRT * c)
   c->pos.x = 0;
   c->pos.y = 0;
   c->hide_cursor = 1;
-  c->width=CRT_COLS;
+  c->width = CRT_COLS;
 #if 0
   c->sh.dir = 0;
 #endif
index d0cde9916e2c2cc4a13cf83ce5ac8452533b6292..72a7764d3b80163a706ce7d9b65c5c855ce1fa13 100644 (file)
@@ -6,10 +6,14 @@
  *
  */
 
-static char rcsid[] = "$Id$";
+static char rcsid[] =
+  "$Id$";
 
 /*
  * $Log$
+ * Revision 1.11  2008/02/26 23:56:12  james
+ * *** empty log message ***
+ *
  * Revision 1.10  2008/02/26 23:23:17  james
  * *** empty log message ***
  *
@@ -100,15 +104,15 @@ terminal_close (TTY * _t)
   set_nonblocking (t->wfd);
 
 
-  t->xmit (_t,"\033%@",3); //Leave UTF-8
-  t->xmit (_t,"\033(B",3); //US-ASCII in G0
-  t->xmit (_t,"\033)B",3); //US-ASCII in G1
-  t->xmit (_t,"\017",1); //Select G0
-  t->xmit (_t, "\033[r", 3); //No margins
-  t->xmit (_t, "\033[0m", 4); //Default attributes
+  t->xmit (_t, "\033%@", 3);    //Leave UTF-8
+  t->xmit (_t, "\033(B", 3);    //US-ASCII in G0
+  t->xmit (_t, "\033)B", 3);    //US-ASCII in G1
+  t->xmit (_t, "\017", 1);      //Select G0
+  t->xmit (_t, "\033[r", 3);    //No margins
+  t->xmit (_t, "\033[0m", 4);   //Default attributes
   i = sprintf (buf, "\033[%d;%dH", CRT_ROWS + 1, 1); //Cursor to bottom
   t->xmit (_t, buf, i);
-  t->xmit (_t, "\033[J", 3); //erase rest of screen
+  t->xmit (_t, "\033[J", 3);    //erase rest of screen
 
   set_blocking (t->rfd);
   set_blocking (t->wfd);
index e324a532006bf84c32c3e4fd6a0f9afa375d0279..bffc9e408c18c8295010e4e1915ff228b734ba7a 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.7  2008/02/26 23:56:12  james
+ * *** empty log message ***
+ *
  * Revision 1.6  2008/02/26 23:23:17  james
  * *** empty log message ***
  *
@@ -183,4 +186,3 @@ utf8_emit (TTY * t, int ch)
       t->xmit (t, buf, 4);
     }
 }
-
index 721886bd6f32e6fdf1b1b5aae6c6365c3badd5f1..a22fe691a4adb6edac6be91058f6359ce0c108e7 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.42  2008/02/26 23:56:12  james
+ * *** empty log message ***
+ *
  * Revision 1.41  2008/02/26 23:23:17  james
  * *** empty log message ***
  *
@@ -344,12 +347,16 @@ csi_ender (int c)
   return 0;
 }
 
-static inline int ctrl_chr(int ch,int term)
+static inline int
+ctrl_chr (int ch, int term)
 {
-if ((term>0) && (ch==term)) return 0;
-if (ch==033) return 0;
-if ((ch>0) && (ch<040)) return 1;
-return 0;
+  if ((term > 0) && (ch == term))
+    return 0;
+  if (ch == 033)
+    return 0;
+  if ((ch > 0) && (ch < 040))
+    return 1;
+  return 0;
 }
 
 
@@ -555,9 +562,10 @@ vt102_cursor_advance (Context * c)
 void
 vt102_cursor_retreat (VT102 * v)
 {
-  if (v->pos.x != v->top_margin.x) {
-    v->pos.x--;
-  }
+  if (v->pos.x != v->top_margin.x)
+    {
+      v->pos.x--;
+    }
 
   v->pending_wrap = 0;
 }
@@ -716,10 +724,13 @@ vt102_change_mode (VT102 * v, int private, char *ns, int set)
         case VT102_PRIVATE_MODE_132COLS:
           /* We don't implement 132 col mode - yet */
 
-         v->current_width=v->private_modes[VT102_PRIVATE_MODE_132COLS] ? VT102_COLS_132:VT102_COLS_80;
+          v->current_width =
+            v->
+            private_modes[VT102_PRIVATE_MODE_132COLS] ? VT102_COLS_132 :
+            VT102_COLS_80;
 
-         v->crt.width=v->current_width;
-         v->screen_end.x=v->current_width-1;
+          v->crt.width = v->current_width;
+          v->screen_end.x = v->current_width - 1;
           v->top_margin = v->screen_start;
           v->bottom_margin = v->screen_end;
           vt102_cursor_home (v);
@@ -974,12 +985,15 @@ vt102_regular_char (Context * c, VT102 * v, uint32_t ch)
   if (v->modes[VT102_MODE_INSERT])
     vt102_insert_into_line (v, v->pos);
 
-  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;
-  }
+  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;
+    }
   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);
@@ -1000,32 +1014,34 @@ vt102_send_id (Context * c, char *buf)
 void
 vt102_scs (Context * c, int g, int s)
 {
-VT102 *v=c->v;
-int cs=VT102_CSID_US;
+  VT102 *v = c->v;
+  int cs = VT102_CSID_US;
 
 
-switch (s) {
-case 'A':
-       cs=VT102_CSID_UK;
-       break;
-case '1':
-case '2':
-case 'B':
-       cs=VT102_CSID_US;
-       break;
-case '0':
-       cs=VT102_CSID_GL;
-       break;
-}
+  switch (s)
+    {
+    case 'A':
+      cs = VT102_CSID_UK;
+      break;
+    case '1':
+    case '2':
+    case 'B':
+      cs = VT102_CSID_US;
+      break;
+    case '0':
+      cs = VT102_CSID_GL;
+      break;
+    }
 
-switch(g) {
-case '(':
-       v->g[0]=cs;
-       break;
-case ')':
-       v->g[1]=cs;
-       break;
-}
+  switch (g)
+    {
+    case '(':
+      v->g[0] = cs;
+      break;
+    case ')':
+      v->g[1] = cs;
+      break;
+    }
 
 }
 
@@ -1129,7 +1145,7 @@ vt102_parse_csi (Context * c, char *buf, int len)
         case 'K':
           {
             CRT_Pos ls = { 0, v->pos.y };
-            CRT_Pos le = { v->current_width -1, v->pos.y };
+            CRT_Pos le = { v->current_width - 1, v->pos.y };
             if (len == 2)
               narg = 0;         /*Different default */
 
@@ -1174,9 +1190,6 @@ vt102_parse_csi (Context * c, char *buf, int len)
           while (narg--)
             vt102_delete_from_line (v, v->pos);
           break;
-        case 'R':
-          //FIXME: cursor position report - does anything use that?
-          break;
         case 'S':
           while (narg--)
             {
@@ -1215,7 +1228,7 @@ vt102_parse_csi (Context * c, char *buf, int len)
             vt102_regular_char (c, v, v->last_reg_char);
           break;
         case 'c':
-          vt102_send_id (c, terminal_id);
+          vt102_send_id (c, "\033[?2c");
           break;
         case 'd':
           vt102_cursor_absolute (v, v->pos.x, narg - 1);
@@ -1249,9 +1262,23 @@ vt102_parse_csi (Context * c, char *buf, int len)
           vt102_parse_attr_string (v, &buf[1], len - 1);
           break;
         case 'n':              //Device status report
-          //5 requestion status
-          // 6 request cursor position FIXME
+         switch (buf[1]) {
+       case '5':
+          vt102_send_id (c, "\033[0n");
+         break;
+        case '6':
+        if (c->t) {
+        char buf[16];
+       int i;
+        i=sprintf(buf,"\033[%d;%dR",v->pos.y+1,v->pos.x+1);
+       c->t->xmit (c->t, buf, i);
+         }
+       break;
+       default:
           //?15n printer status
+          log_f (c->l, "<%s:%d unhandled DSR: \\033%s>", __FILE__, __LINE__,
+                 buf);
+       }
           break;
         case 'q':              //Load LED on off 
           break;
@@ -1287,6 +1314,8 @@ vt102_parse_csi (Context * c, char *buf, int len)
           break;
         case 'y':              //Invoke confidence test
           break;
+       case 'z':       //request terminal parameters
+         break;
 
         default:
           log_f (c->l, "<%s:%d unhandled CSI: \\033%s>", __FILE__, __LINE__,
@@ -1313,79 +1342,81 @@ vt102_parse_esc (Context * c)
 
 #if 1
   p->cmd_buf[p->cmd_ptr] = 0;
-  log_f (c->l, "<cmd in  x=%3d y=%2d aw=%d <ESC>%s >", v->pos.x, v->pos.y,v->pending_wrap,
-         p->cmd_buf);
+  log_f (c->l, "<cmd in  x=%3d y=%2d aw=%d vt=%d <ESC>%s >", v->pos.x, v->pos.y,
+         v->pending_wrap, !v->private_modes[VT102_PRIVATE_MODE_VT52],p->cmd_buf);
 #endif
 
-if (v->private_modes[VT102_PRIVATE_MODE_VT52]) {
-int ate=1;
-
-  switch (p->cmd_buf[0])
+  if (!v->private_modes[VT102_PRIVATE_MODE_VT52])
     {
-    case 'A':
-      vt102_cursor_relative (v, 0, -1);
-      break;
-    case 'B':
-      vt102_cursor_relative (v, 0, 1);
-      break;
-    case 'C':
-      vt102_cursor_relative (v, 1, 0);
-      break;
-    case 'D':
-      vt102_cursor_relative (v, -1, 0);
-      break;
-    case 'F':
-      v->cs=1;
-      v->g[1]=VT102_CSID_VT52;
-      break;
-    case 'G':
-      v->cs=0;
-      v->g[0]=VT102_CSID_US;
-      break;
-    case 'H':
-      vt102_cursor_absolute (v, 0, 0);
-      break;
-    case 'I':
-      vt102_cursor_retreat_line (c);
-      break;
-    case 'J':
-      crt_erase (&v->crt, v->pos, v->screen_end, 1, v->color);
-      break;
-    case 'K':
-      {
-        CRT_Pos le = { v->current_width - 1, v->pos.y };
-        crt_erase (&v->crt, v->pos, le, 1, v->color);
-      }
-      break;
-    case 'Y':
-      vt102_cursor_absolute (v, p->cmd_buf[2] - 040, p->cmd_buf[1] - 040);
-      break;
-    case 'V':                  //Print current line
-      break;
-    case 'W':                  //Printer on
-      break;
-    case 'X':                  //printer off
-      break;
-    case ']':                  //print screen
-      break;
-    case 'Z':                  //ID
-      vt102_send_id (c, "\033/Z");
-      break;
-case '^':                      //Autoprint on
-  break;
-case '_':                      //Autoprint off
-  break;
-case '=':
-  v->application_keypad_mode = 1;
-  break;
-case '>':
-  v->application_keypad_mode = 0;
-  break;
-default:
-  ate=0;
-}
-if(ate) return;
-}
+      int ate = 1;
+
+      switch (p->cmd_buf[0])
+        {
+        case 'A':
+          vt102_cursor_relative (v, 0, -1);
+          break;
+        case 'B':
+          vt102_cursor_relative (v, 0, 1);
+          break;
+        case 'C':
+          vt102_cursor_relative (v, 1, 0);
+          break;
+        case 'D':
+          vt102_cursor_relative (v, -1, 0);
+          break;
+        case 'F':
+          v->cs = 1;
+          v->g[1] = VT102_CSID_VT52;
+          break;
+        case 'G':
+          v->cs = 0;
+          v->g[0] = VT102_CSID_US;
+          break;
+        case 'H':
+          vt102_cursor_absolute (v, 0, 0);
+          break;
+        case 'I':
+          vt102_cursor_retreat_line (c);
+          break;
+        case 'J':
+          crt_erase (&v->crt, v->pos, v->screen_end, 1, v->color);
+          break;
+        case 'K':
+          {
+            CRT_Pos le = { v->current_width - 1, v->pos.y };
+            crt_erase (&v->crt, v->pos, le, 1, v->color);
+          }
+          break;
+        case 'Y':
+          vt102_cursor_absolute (v, p->cmd_buf[2] - 040, p->cmd_buf[1] - 040);
+          break;
+        case 'V':              //Print current line
+          break;
+        case 'W':              //Printer on
+          break;
+        case 'X':              //printer off
+          break;
+        case ']':              //print screen
+          break;
+        case 'Z':              //ID
+          vt102_send_id (c, "\033/K");
+          break;
+        case '^':              //Autoprint on
+          break;
+        case '_':              //Autoprint off
+          break;
+        case '=':
+          v->application_keypad_mode = 1;
+          break;
+        case '>':
+          v->application_keypad_mode = 0;
+          break;
+        default:
+          ate = 0;
+        }
+      if (ate)
+        return;
+    }
 
 
 /*If you edit this switch don't forget to edit the length and termination tables*/
@@ -1483,31 +1514,33 @@ if(ate) return;
     }
 
   p->cmd_buf[p->cmd_ptr] = 0;
-  log_f (c->l, "<cmd out x=%3d y=%2d aw=%d>", v->pos.x, v->pos.y,v->pending_wrap);
+  log_f (c->l, "<cmd out x=%3d y=%2d aw=%d>", v->pos.x, v->pos.y,
+         v->pending_wrap);
 }
 
 void
 vt102_status_line (VT102 * v, char *str)
 {
-  int i = v->current_width -1;
+  int i = v->current_width - 1;
   CRT_CA *ca = &v->crt.screen[CRT_ADDR (VT102_STATUS_ROW, 0)];
 
-  for (i=0;i<v->current_width;++i)
+  for (i = 0; i < v->current_width; ++i)
     {
       ca->attr = CRT_ATTR_REVERSE;
       ca->color = CRT_COLOR_NORMAL;
-      ca->chr = *str ? *str:' ';
+      ca->chr = *str ? *str : ' ';
       if (*str)
         str++;
       ca++;
     }
-  
-  for (;i<VT102_MAX_COLS;++i) {
+
+  for (; i < VT102_MAX_COLS; ++i)
+    {
       ca->attr = CRT_ATTR_NORMAL;
       ca->color = CRT_COLOR_NORMAL;
-       ca->chr=' ';
+      ca->chr = ' ';
       ca++;
-  }
+    }
 
 }
 
@@ -1532,9 +1565,9 @@ vt102_reset_state (VT102 * v)
 
   v->application_keypad_mode = 0;
 
-  v->current_width=VT102_COLS_80;
-  v->crt.width=v->current_width;
-  v->screen_end.x = v->current_width -1;
+  v->current_width = VT102_COLS_80;
+  v->crt.width = v->current_width;
+  v->screen_end.x = v->current_width - 1;
 
   v->top_margin = v->screen_start;
   v->bottom_margin = v->screen_end;
@@ -1545,12 +1578,13 @@ vt102_reset_state (VT102 * v)
   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->private_modes[VT102_PRIVATE_MODE_VT52] = 1;
   v->modes[VT102_MODE_LOCAL_ECHO_OFF] = 1;
 
   vt102_reset_tabs (v);
 
-  v->g[0]=v->g[1]=VT102_CSID_US;
-  v->cs=0;
+  v->g[0] = v->g[1] = VT102_CSID_US;
+  v->cs = 0;
 }
 
 static void
@@ -1611,11 +1645,11 @@ vt102_parse_char (Context * c, int ch)
     {
       vt102_reset_state (v);
     }
-  else if (p->in_cmd && !ctrl_chr(ch,p->cmd_termination))
+  else if (p->in_cmd && !ctrl_chr (ch, p->cmd_termination))
     {
       p->cmd_buf[p->cmd_ptr++] = ch;
-       if (p->cmd_ptr==VT102_CMD_LEN)
-               p->in_cmd=0;
+      if (p->cmd_ptr == VT102_CMD_LEN)
+        p->in_cmd = 0;
       if (p->cmd_more_bytes)
         {
           p->cmd_more_bytes--;
@@ -1646,7 +1680,7 @@ vt102_parse_char (Context * c, int ch)
           p->cmd_termination = 0;
         }
     }
-  else if (p->in_escape && !ctrl_chr(ch,0))
+  else if (p->in_escape && !ctrl_chr (ch, 0))
     {
       p->cmd_ptr = 0;
       p->cmd_buf[p->cmd_ptr++] = ch;
@@ -1667,10 +1701,10 @@ vt102_parse_char (Context * c, int ch)
   else
     {
 #if 1
-if (ch!=27)
-          log_f (c->l,
-                "<chr in  x=%3d y=%2d aw=%d  \\%03o %3d %c", 
-               v->pos.x, v->pos.y, v->pending_wrap,ch,ch,safe_ch(ch));
+      if (ch != 27)
+        log_f (c->l,
+               "<chr in  x=%3d y=%2d aw=%d  \\%03o %3d %c",
+               v->pos.x, v->pos.y, v->pending_wrap, ch, ch, safe_ch (ch));
 
 #endif
 
@@ -1705,11 +1739,11 @@ if (ch!=27)
           break;
          /*SO*/ case 14:
           /*select G1 */
-       v->cs=1;
+          v->cs = 1;
           break;
          /*SI*/ case 15:
           /*select G0 */
-       v->cs=0;
+          v->cs = 0;
           break;
          /*DLE*/ case 16:
         /*DC1 */ case 17:
@@ -1737,8 +1771,9 @@ if (ch!=27)
         }
 
 #if 1
-       if (ch!=27)
-       log_f (c->l, "<chr out x=%3d y=%2d aw=%d>", v->pos.x, v->pos.y,v->pending_wrap);
+      if (ch != 27)
+        log_f (c->l, "<chr out x=%3d y=%2d aw=%d>", v->pos.x, v->pos.y,
+               v->pending_wrap);
 #endif
     }
 
@@ -1936,9 +1971,9 @@ vt102_reset (VT102 * v)
 
   v->screen_start.x = 0;
   v->screen_start.y = 0;
-  v->current_width=VT102_COLS_80;
-  v->crt.width=v->current_width;
-  v->screen_end.x = v->current_width -1;
+  v->current_width = VT102_COLS_80;
+  v->crt.width = v->current_width;
+  v->screen_end.x = v->current_width - 1;
   v->screen_end.y = VT102_ROWS - 1;
 
   vt102_cursor_home (v);
index bd0597ad56b609b5b08ed901f400b1c9259ce115..1835455b6887ddc1ad381a8145bf16f715020c9b 100644 (file)
@@ -6,10 +6,14 @@
  *
  */
 
-static char rcsid[] = "$Id$";
+static char rcsid[] =
+  "$Id$";
 
 /*
  * $Log$
+ * Revision 1.2  2008/02/26 23:56:12  james
+ * *** empty log message ***
+ *
  * Revision 1.1  2008/02/26 23:23:17  james
  * *** empty log message ***
  *
@@ -17,124 +21,123 @@ static char rcsid[] = "$Id$";
 
 #include "project.h"
 
-uint32_t vt102_charset_c0[VT102_CHARSET_SIZE]={
-[0x00]=0x2400,
-[0x01]=0x2401,
-[0x02]=0x2402,
-[0x03]=0x2403,
-[0x04]=0x2404,
-[0x05]=0x2405,
-[0x06]=0x2406,
-[0x07]=0x2407,
-[0x08]=0x2408,
-[0x09]=0x2409,
-[0x0a]=0x240a,
-[0x0b]=0x240b,
-[0x0c]=0x240c,
-[0x0d]=0x240d,
-[0x0e]=0x240e,
-[0x0f]=0x240f,
-[0x10]=0x2410,
-[0x11]=0x2411,
-[0x12]=0x2412,
-[0x13]=0x2413,
-[0x14]=0x2414,
-[0x15]=0x2415,
-[0x16]=0x2416,
-[0x17]=0x2417,
-[0x18]=0x2418,
-[0x19]=0x2419,
-[0x1a]=0x241a,
-[0x1b]=0x241b,
-[0x1c]=0x241c,
-[0x1d]=0x241d,
-[0x1e]=0x241e,
-[0x1f]=0x241f,
-[0x7f]=0x2421,
+uint32_t vt102_charset_c0[VT102_CHARSET_SIZE] = {
+  [0x00] = 0x2400,
+  [0x01] = 0x2401,
+  [0x02] = 0x2402,
+  [0x03] = 0x2403,
+  [0x04] = 0x2404,
+  [0x05] = 0x2405,
+  [0x06] = 0x2406,
+  [0x07] = 0x2407,
+  [0x08] = 0x2408,
+  [0x09] = 0x2409,
+  [0x0a] = 0x240a,
+  [0x0b] = 0x240b,
+  [0x0c] = 0x240c,
+  [0x0d] = 0x240d,
+  [0x0e] = 0x240e,
+  [0x0f] = 0x240f,
+  [0x10] = 0x2410,
+  [0x11] = 0x2411,
+  [0x12] = 0x2412,
+  [0x13] = 0x2413,
+  [0x14] = 0x2414,
+  [0x15] = 0x2415,
+  [0x16] = 0x2416,
+  [0x17] = 0x2417,
+  [0x18] = 0x2418,
+  [0x19] = 0x2419,
+  [0x1a] = 0x241a,
+  [0x1b] = 0x241b,
+  [0x1c] = 0x241c,
+  [0x1d] = 0x241d,
+  [0x1e] = 0x241e,
+  [0x1f] = 0x241f,
+  [0x7f] = 0x2421,
 };
 
-uint32_t vt102_charset_us[VT102_CHARSET_SIZE]={0};
+uint32_t vt102_charset_us[VT102_CHARSET_SIZE] = { 0 };
 
-uint32_t vt102_charset_uk[VT102_CHARSET_SIZE]={
-[0x23]=0x00a3,
+uint32_t vt102_charset_uk[VT102_CHARSET_SIZE] = {
+  [0x23] = 0x00a3,
 };
 
-uint32_t vt102_charset_vt52[VT102_CHARSET_SIZE]={
-[0x5f]=0x25ae,
-[0x60]=0x25ae,
-[0x61]=0x25ae,
-[0x62]=0x215f, 1/
-[0x63]='3',
-[0x64]='5',
-[0x65]='7',
-[0x66]=0x00b0, 
-[0x67]=0x00b1,
-[0x68]=0x2192, 
-[0x69]=0x2026,  
-[0x6a]=0x00f7,  
-[0x6b]=0x2193,  
-[0x6c]=0x25ba, // bar scan 0
-[0x6d]=0x23ba, bar scan 1
-[0x6e]=0x25ba, // bar scan 2
-[0x6f]=0x23bb, bar scan 3
-[0x70]=0x23bb, //bar scan 4
-[0x71]=0x2500, bar scan 5
-[0x72]=0x23bc, //bar scan 6
-[0x73]=0x23bc, bar scan 7
-[0x74]=0x2080,
-[0x75]=0x2081,
-[0x76]=0x2082,
-[0x77]=0x2083,
-[0x78]=0x2084,
-[0x79]=0x2085,
-[0x7a]=0x2086,
-[0x7b]=0x2087,
-[0x7c]=0x2088,
-[0x7d]=0x2089,
-[0x7e]=0x00b6
+uint32_t vt102_charset_vt52[VT102_CHARSET_SIZE] = {
+  [0x5f] = 0x25ae,
+  [0x60] = 0x25ae,
+  [0x61] = 0x25ae,
+  [0x62] = 0x215f, 
+  [0x63] = '3',          // 3/
+  [0x64] = '5',   // 5/
+  [0x65] = '7',   // 7/
+  [0x66] = 0x00b0,
+  [0x67] = 0x00b1,
+  [0x68] = 0x2192,
+  [0x69] = 0x2026,
+  [0x6a] = 0x00f7,
+  [0x6b] = 0x2193,
+  [0x6c] = 0x25ba, //bar scan 0
+  [0x6d] = 0x23ba, 
+  [0x6e] = 0x25ba, //bar scan 2
+  [0x6f] = 0x23bb, 
+  [0x70] = 0x23bb, //bar scan 4
+  [0x71] = 0x2500, 
+  [0x72] = 0x23bc, //bar scan 6
+  [0x73] = 0x23bc, 
+  [0x74] = 0x2080,
+  [0x75] = 0x2081,
+  [0x76] = 0x2082,
+  [0x77] = 0x2083,
+  [0x78] = 0x2084,
+  [0x79] = 0x2085,
+  [0x7a] = 0x2086,
+  [0x7b] = 0x2087,
+  [0x7c] = 0x2088,
+  [0x7d] = 0x2089,
+  [0x7e] = 0x00b6
 };
 
 
-uint32_t vt102_charset_gl[VT102_CHARSET_SIZE]={
-[0x5f]=0x25ae,
-[0x60]=0x25c6,
-[0x61]=0x2592,
-[0x62]=0x2409,
-[0x63]=0x240c,
-[0x64]=0x240d,
-[0x65]=0x240a,
-[0x66]=0x00b0,
-[0x67]=0x00b1,
-[0x68]=0x2424,
-[0x69]=0x240b,
-[0x6a]=0x2518,
-[0x6b]=0x2510,
-[0x6c]=0x250c,
-[0x6d]=0x2514,
-[0x6e]=0x253c,
-[0x6f]=0x23ba,
-[0x70]=0x23bb,
-[0x71]=0x2500,
-[0x72]=0x23bc,
-[0x73]=0x23bd,
-[0x74]=0x251c,
-[0x75]=0x2524,
-[0x76]=0x2534,
-[0x77]=0x252c,
-[0x78]=0x2502,
-[0x79]=0x2264,
-[0x7a]=0x2265,
-[0x7b]=0x03c0,
-[0x7c]=0x2260,
-[0x7d]=0x00a3,
-[0x7e]=0x00b7
+uint32_t vt102_charset_gl[VT102_CHARSET_SIZE] = {
+  [0x5f] = 0x25ae,
+  [0x60] = 0x25c6,
+  [0x61] = 0x2592,
+  [0x62] = 0x2409,
+  [0x63] = 0x240c,
+  [0x64] = 0x240d,
+  [0x65] = 0x240a,
+  [0x66] = 0x00b0,
+  [0x67] = 0x00b1,
+  [0x68] = 0x2424,
+  [0x69] = 0x240b,
+  [0x6a] = 0x2518,
+  [0x6b] = 0x2510,
+  [0x6c] = 0x250c,
+  [0x6d] = 0x2514,
+  [0x6e] = 0x253c,
+  [0x6f] = 0x23ba,
+  [0x70] = 0x23bb,
+  [0x71] = 0x2500,
+  [0x72] = 0x23bc,
+  [0x73] = 0x23bd,
+  [0x74] = 0x251c,
+  [0x75] = 0x2524,
+  [0x76] = 0x2534,
+  [0x77] = 0x252c,
+  [0x78] = 0x2502,
+  [0x79] = 0x2264,
+  [0x7a] = 0x2265,
+  [0x7b] = 0x03c0,
+  [0x7c] = 0x2260,
+  [0x7d] = 0x00a3,
+  [0x7e] = 0x00b7
 };
 
 
-uint32_t *charset_from_csid[]={
-       [VT102_CSID_US]=vt102_charset_us,
-       [VT102_CSID_UK]=vt102_charset_uk,
-       [VT102_CSID_GL]=vt102_charset_gl,
-       [VT102_CSID_VT52]=vt102_charset_vt52
+uint32_t *charset_from_csid[] = {
+  [VT102_CSID_US] = vt102_charset_us,
+  [VT102_CSID_UK] = vt102_charset_uk,
+  [VT102_CSID_GL] = vt102_charset_gl,
+  [VT102_CSID_VT52] = vt102_charset_vt52
 };
-