chiark / gitweb /
*** empty log message ***
[sympathy.git] / src / vt102.c
index f1e00e8ae8d6211c450e08da548d461fc5035035..74888035be62746b0bd559c00299c755b96f37b1 100644 (file)
@@ -10,6 +10,15 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.52  2008/02/28 16:57:52  james
+ * *** empty log message ***
+ *
+ * Revision 1.51  2008/02/28 16:37:16  james
+ * *** empty log message ***
+ *
+ * Revision 1.50  2008/02/28 12:12:25  james
+ * *** empty log message ***
+ *
  * Revision 1.49  2008/02/28 11:27:48  james
  * *** empty log message ***
  *
@@ -397,23 +406,46 @@ in_margins (VT102 * v, CRT_Pos p)
   return 1;
 }
 
-void vt102_do_resize(Context *c)
+void
+vt102_crt_update (Context * c)
 {
+  VT102 *v = c->v;
 
-VT102 *v=c->v;
+  v->crt.pos = v->pos;
+  v->crt.hide_cursor =
+    v->private_modes[VT102_PRIVATE_MODE_SHOW_CURSOR] ? 0 : 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);
-          crt_cls (&v->crt);
+  if (v->current_line.y != v->pos.y)
+    {
+      vt102_log_line (c, v->current_line.y);
+      v->current_line = v->pos;
+    }
 
-         if (c->t)
-               tty_winch(c->t,v->current_size);
+  if (c->d)
+    cmd_show_status (c->d, c);
+}
+
+void
+vt102_do_resize (Context * c)
+{
+
+  VT102 *v = c->v;
+
+  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);
+  crt_cls (&v->crt);
+
+  if (c->t)
+    tty_winch (c->t, v->current_size);
+
+  log_f (c->l, "<size now %dx%d>", v->current_size.x, v->current_size.y);
+  vt102_crt_update (c);
 }
 
 
@@ -725,9 +757,9 @@ vt102_insert_into_line (VT102 * v, CRT_Pos p)
 
 
 void
-vt102_change_mode (Context *c, int private, char *ns, int set)
+vt102_change_mode (Context * c, int private, char *ns, int set)
 {
-  VT102 *v=c->v;
+  VT102 *v = c->v;
   int m;
 
 
@@ -769,7 +801,7 @@ vt102_change_mode (Context *c, int private, char *ns, int set)
             private_modes[VT102_PRIVATE_MODE_132COLS] ? VT102_COLS_132 :
             VT102_COLS_80;
 
-         vt102_do_resize(c);
+          vt102_do_resize (c);
           break;
         }
 
@@ -783,9 +815,9 @@ vt102_change_mode (Context *c, int private, char *ns, int set)
 }
 
 void
-vt102_parse_mode_string (Context *c, char *buf, int len)
+vt102_parse_mode_string (Context * c, char *buf, int len)
 {
-  VT102 *v=c->v;
+  VT102 *v = c->v;
   int private = 0;
   char last = buf[len - 1];
   char num[4];
@@ -1602,9 +1634,9 @@ vt102_parser_reset (VT102_parser * p)
 
 
 void
-vt102_reset_state (Context *c)
+vt102_reset_state (Context * c)
 {
-  VT102 *v=c->v;
+  VT102 *v = c->v;
   vt102_parser_reset (&v->parser);
 
   v->attr = CRT_ATTR_NORMAL;
@@ -1614,7 +1646,7 @@ vt102_reset_state (Context *c)
 
   v->current_size = v->original_size;
 
-  vt102_do_resize(c);
+  vt102_do_resize (c);
 
   memset (v->modes, 0, VT102_NMODES);
   memset (v->private_modes, 0, VT102_NMODES);
@@ -1831,18 +1863,9 @@ vt102_parse_char (Context * c, int ch)
 #endif
     }
 
-  v->crt.pos = v->pos;
-  v->crt.hide_cursor =
-    v->private_modes[VT102_PRIVATE_MODE_SHOW_CURSOR] ? 0 : 1;
+  vt102_crt_update (c);
 
-  if (v->current_line.y != v->pos.y)
-    {
-      vt102_log_line (c, v->current_line.y);
-      v->current_line = v->pos;
-    }
 
-  if (c->d)
-    cmd_show_status (c->d, c);
 }
 
 void
@@ -2016,7 +2039,7 @@ vt102_send (Context * c, uint8_t key)
 void
 vt102_reset (Context * c)
 {
-  VT102 *v=c->v;
+  VT102 *v = c->v;
   VT102_parser *p = &v->parser;
 
 
@@ -2068,14 +2091,14 @@ vt102_new (CRT_Pos * size)
 
       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;
+      if (v->original_size.y > VT102_MAX_ROWS)
+        v->original_size.y = VT102_MAX_ROWS;
 
     }
   else
     {
       v->original_size.x = VT102_COLS_80;
-      v->original_size.y = VT102_ROWS;
+      v->original_size.y = VT102_ROWS_24;
     }
 
   return v;
@@ -2087,22 +2110,28 @@ vt102_set_ansi (VT102 * v, int ansi)
   v->xn_glitch = ansi ? 0 : 1;
 }
 
-void vt102_resize(Context *c,CRT_Pos size)
+void
+vt102_resize (Context * c, CRT_Pos size)
 {
+  log_f (c->l, "<size change to %dx%d requested>", size.x, size.y);
 
+  if (!size.x)
+    size.x = c->v->current_size.x;
+  if (!size.y)
+    size.y = c->v->current_size.y;
 
-      if (size.x < 1)
-        size.x = 1;
-      if (size.y < 1)
-        size.y = 1;
+  if (size.x < 1)
+    size.x = 1;
+  if (size.y < 1)
+    size.y = 1;
 
-      if (size.x > VT102_MAX_COLS)
-        size.x = VT102_MAX_COLS;
-      if (size.y > VT102_ROWS)
-        size.y = VT102_ROWS;
+  if (size.x > VT102_MAX_COLS)
+    size.x = VT102_MAX_COLS;
+  if (size.y > VT102_MAX_ROWS)
+    size.y = VT102_MAX_ROWS;
 
-       c->v->current_size=size;
-       vt102_do_resize(c);
+  c->v->current_size = size;
+  vt102_do_resize (c);
 }
 
 void