/*
* $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 ***
+ *
+ * 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 ***
+ *
+ * Revision 1.45 2008/02/27 01:31:14 james
+ * *** empty log message ***
+ *
* Revision 1.44 2008/02/27 00:54:16 james
* *** empty log message ***
*
return 1;
}
+void
+vt102_crt_update (Context * c)
+{
+ VT102 *v = c->v;
+
+ v->crt.pos = v->pos;
+ v->crt.hide_cursor =
+ v->private_modes[VT102_PRIVATE_MODE_SHOW_CURSOR] ? 0 : 1;
+
+ 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
+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);
+}
+
+
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;
+ char logbuf[4 * (VT102_MAX_COLS + 1)], *logptr = logbuf;
if (!c->l)
return;
int ch = c->v->crt.screen[CRT_ADDR_POS (&p)].chr;
if (ch < 32)
ch = ' ';
- logptr+=utf8_encode(logptr,ch);
+ logptr += utf8_encode (logptr, ch);
}
- *logptr=0;
+ *logptr = 0;
c->l->log (c->l, 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');
}
if (ch < VT102_CHARSET_SIZE)
{
- int cs;
- if ((cs=vt102_charset_c0[ch])) {
- ch=cs;
- } else if ((cs=charset_from_csid[v->g[v->cs]][ch])) {
- ch=cs;
- }
+ int cs;
+ if ((cs = vt102_charset_c0[ch]))
+ {
+ ch = cs;
+ }
+ else if ((cs = charset_from_csid[v->g[v->cs]][ch]))
+ {
+ ch = cs;
+ }
}
v->crt.screen[CRT_ADDR_POS (&v->pos)].chr = ch;
v->crt.screen[CRT_ADDR_POS (&v->pos)].attr = v->attr;
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))
{
break;
#if 0
/*ACK*/ case 6:
- break;
+ break;
#endif
/*BEL*/ case 7:
- //FIXME beep
+ //FIXME beep
break;
/*BS*/ case 8:
vt102_cursor_retreat (c->v);
#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
}
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 (void)
+vt102_new (CRT_Pos * size)
{
VT102 *v;
v->xn_glitch = 1;
- vt102_reset (v);
+ 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_MAX_ROWS)
+ v->original_size.y = VT102_MAX_ROWS;
+
+ }
+ else
+ {
+ v->original_size.x = VT102_COLS_80;
+ v->original_size.y = VT102_ROWS_24;
+ }
return v;
}
v->xn_glitch = ansi ? 0 : 1;
}
+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 > 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);
+}
+
void
vt102_free (VT102 * v)
{