chiark / gitweb /
*** empty log message ***
[sympathy.git] / src / vt102.c
index 52f7fb959f60f70d8a22e88a223394214fd68a8e..1940dcf513de86d1dde690e0753636f6d715631f 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.47  2008/02/27 09:42:22  james
+ * *** empty log message ***
+ *
  * Revision 1.46  2008/02/27 01:31:38  james
  * *** empty log message ***
  *
@@ -391,7 +394,7 @@ in_margins (VT102 * v, CRT_Pos p)
 void
 vt102_log_line (Context * c, int line)
 {
-  CRT_Pos e = { c->v->current_width - 1, line };
+  CRT_Pos e = { c->v->current_size.x - 1, line };
   CRT_Pos p = { 0, line };
   char logbuf[4 * (VT102_MAX_COLS + 1)], *logptr = logbuf;
 
@@ -734,13 +737,16 @@ 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->current_size.x =
             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.size = v->current_size;
+         v->crt.size.y++;
+         v->screen_end=v->current_size;
+       v->screen_end.x--;
+       v->screen_end.y--;
           v->top_margin = v->screen_start;
           v->bottom_margin = v->screen_end;
           vt102_cursor_home (v);
@@ -1163,7 +1169,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_size.x - 1, v->pos.y };
             if (len == 2)
               narg = 0;         /*Different default */
 
@@ -1405,7 +1411,7 @@ vt102_parse_esc (Context * c)
           break;
         case 'K':
           {
-            CRT_Pos le = { v->current_width - 1, v->pos.y };
+            CRT_Pos le = { v->current_size.x - 1, v->pos.y };
             crt_erase (&v->crt, v->pos, le, 1, v->color);
           }
           break;
@@ -1545,10 +1551,10 @@ vt102_parse_esc (Context * c)
 void
 vt102_status_line (VT102 * v, char *str)
 {
-  int i = v->current_width - 1;
-  CRT_CA *ca = &v->crt.screen[CRT_ADDR (VT102_STATUS_ROW, 0)];
+  int i;
+  CRT_CA *ca = &v->crt.screen[CRT_ADDR (v->current_size.y, 0)];
 
-  for (i = 0; i < v->current_width; ++i)
+  for (i = 0; i < v->current_size.x; ++i)
     {
       ca->attr = CRT_ATTR_REVERSE;
       ca->color = CRT_COLOR_NORMAL;
@@ -1589,9 +1595,12 @@ 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_size=v->original_size;
+  v->crt.size = v->current_size;
+         v->crt.size.y++;
+  v->screen_end = v->current_size;
+  v->screen_end.x--;
+  v->screen_end.y--;
 
   v->top_margin = v->screen_start;
   v->bottom_margin = v->screen_end;
@@ -2005,10 +2014,12 @@ 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->screen_end.y = VT102_ROWS - 1;
+  v->current_size=v->original_size;
+  v->crt.size=v->current_size;
+         v->crt.size.y++;
+  v->screen_end=v->current_size;
+  v->screen_end.x--;
+  v->screen_end.y--;
 
   vt102_cursor_home (v);
   vt102_status_line (v, "");
@@ -2025,7 +2036,7 @@ vt102_reset (VT102 * v)
 }
 
 VT102 *
-vt102_new (int width)
+vt102_new (CRT_Pos *size)
 {
   VT102 *v;
 
@@ -2033,18 +2044,23 @@ vt102_new (int width)
 
   v->xn_glitch = 1;
 
-  vt102_reset (v);
+  if (size) {
+      v->original_size = *size;
 
-  if (width)
-    {
-      v->current_width = width;
-      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);
+       if (v->original_size.x<1) v->original_size.x=1;
+       if (v->original_size.y<1) v->original_size.y=1;
+
+       if (v->original_size.x>VT102_MAX_COLS) v->original_size.x=VT102_MAX_COLS; 
+       if (v->original_size.y>VT102_ROWS) v->original_size.y=VT102_ROWS; 
+
+    } else {
+       v->original_size.x=VT102_COLS_80;
+       v->original_size.y=VT102_ROWS;
     }
 
+  vt102_reset (v);
+
   return v;
 }