/*
* $Log$
+ * 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 ***
+ *
+ * Revision 1.48 2008/02/27 09:42:53 james
+ * *** empty log message ***
+ *
+ * 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 ***
*
return 1;
}
+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);
+}
+
+
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;
void
-vt102_change_mode (VT102 * v, int private, char *ns, int set)
+vt102_change_mode (Context *c, int private, char *ns, int set)
{
+ VT102 *v=c->v;
int m;
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->top_margin = v->screen_start;
- v->bottom_margin = v->screen_end;
- vt102_cursor_home (v);
- crt_cls (&v->crt);
-
-
+ vt102_do_resize(c);
break;
}
}
void
-vt102_parse_mode_string (VT102 * v, char *buf, int len)
+vt102_parse_mode_string (Context *c, char *buf, int len)
{
+ VT102 *v=c->v;
int private = 0;
char last = buf[len - 1];
char num[4];
{
if (*buf == ';')
{
- vt102_change_mode (v, private, &num[o], last == 'h');
+ vt102_change_mode (c, private, &num[o], last == 'h');
memset (num, 0, sizeof (num));
o = sizeof (num) - 1;
buf++;
buf++;
}
- vt102_change_mode (v, private, &num[o], last == 'h');
+ vt102_change_mode (c, private, &num[o], last == 'h');
}
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 */
break;
case 'h':
case 'l':
- vt102_parse_mode_string (v, &buf[1], len - 1);
+ vt102_parse_mode_string (c, &buf[1], len - 1);
break;
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;
vt102_send_id (c, terminal_id);
break;
case 'c':
- vt102_reset (v);
-
-
+ vt102_reset (c);
break;
case '=':
v->application_keypad_mode = 1;
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;
void
-vt102_reset_state (VT102 * v)
+vt102_reset_state (Context *c)
{
+ VT102 *v=c->v;
vt102_parser_reset (&v->parser);
v->attr = CRT_ATTR_NORMAL;
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->top_margin = v->screen_start;
- v->bottom_margin = v->screen_end;
+ vt102_do_resize(c);
memset (v->modes, 0, VT102_NMODES);
memset (v->private_modes, 0, VT102_NMODES);
#endif
if (ch == SYM_CHAR_RESET)
{
- vt102_reset_state (v);
+ vt102_reset_state (c);
}
else if (p->in_cmd && !ctrl_chr (ch, p->cmd_termination))
{
}
void
-vt102_reset (VT102 * v)
+vt102_reset (Context * c)
{
+ VT102 *v=c->v;
VT102_parser *p = &v->parser;
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, "");
v->current_line = v->pos;
vt102_parser_reset (p);
- vt102_reset_state (v);
+ vt102_reset_state (c);
vt102_save_state (v);
}
VT102 *
-vt102_new (int width)
+vt102_new (CRT_Pos * size)
{
VT102 *v;
v->xn_glitch = 1;
- vt102_reset (v);
- if (width)
+ if (size)
+ {
+ v->original_size = *size;
+
+ 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->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);
+ v->original_size.x = VT102_COLS_80;
+ v->original_size.y = VT102_ROWS;
}
return v;
v->xn_glitch = ansi ? 0 : 1;
}
+void vt102_resize(Context *c,CRT_Pos size)
+{
+
+ if (!size.x) size.x=c->v->current_size.x;
+ if (!size.y) size.x=c->v->current_size.y;
+
+ 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;
+
+ c->v->current_size=size;
+ vt102_do_resize(c);
+}
+
void
vt102_free (VT102 * v)
{