chiark / gitweb /
*** empty log message ***
authorjames <james>
Wed, 6 Feb 2008 11:49:47 +0000 (11:49 +0000)
committerjames <james>
Wed, 6 Feb 2008 11:49:47 +0000 (11:49 +0000)
src/vt102.c

index 8b6192971f645704c7bc4d6faf98324701e46c02..1649c4f2acd7a615a8a1689e49a5da630c695ca0 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.8  2008/02/06 11:49:47  james
+ * *** empty log message ***
+ *
  * Revision 1.7  2008/02/06 11:30:37  james
  * *** empty log message ***
  *
@@ -243,6 +246,25 @@ vt102_delete_from_line (VT102 * v, CRT_Pos p)
 /*But not attr due to vt102 bug*/
 }
 
+void
+vt102_insert_into_line (VT102 * v, CRT_Pos p)
+{
+  int n = v->bottom_margin.x - p.x;
+
+  if (n < 0)
+    return;
+
+  if (n)
+    {
+
+      memmove (&v->crt.screen[CRT_ADDR_POS (&p) + 1],
+               &v->crt.screen[CRT_ADDR_POS (&p) ], sizeof (CRT_CA) * n);
+    }
+
+  v->crt.screen[CRT_ADDR (p.y, v->bottom_margin.x)].chr = ' ';
+  v->crt.screen[CRT_ADDR (p.y, v->bottom_margin.x)].attr = CRT_ATTR_NORMAL;
+}
+
 void
 vt102_change_mode (VT102 * v, int private, char *ns, int set)
 {
@@ -566,6 +588,8 @@ vt102_parse_char (VT102 * v, int c)
          /*VT*/ case 11:
          /*FF*/ case 12:
           vt102_cursor_motion (v, 0, 1, 1);
+         if (v->modes[VT102_MODE_NEWLINE_MODE]) 
+               v->pos.x = v->top_margin.x;
           break;
          /*CR*/ case 13:
           v->pos.x = v->top_margin.x;
@@ -594,6 +618,10 @@ vt102_parse_char (VT102 * v, int c)
          /*DEL*/ case 127:
           break;
         /*regular character */ default:
+
+         if (v->modes[VT102_MODE_INSERT]) 
+               vt102_insert_into_line(v,v->pos);
+
           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);
@@ -632,4 +660,11 @@ vt102_reset (VT102 * v)
 
   v->pos = v->screen_start;
 
+  memset(v->modes,0,VT102_NMODES);
+  memset(v->private_modes,0,VT102_NMODES);
+
+  v->modes[VT102_PRIVATE_MODE_AUTO_WRAP]=1;
+  v->modes[VT102_PRIVATE_MODE_AUTO_REPEAT]=1;
+
+
 }