+void
+ansi_flush_escape (ANSI * a, VT102 * v)
+{
+ ANSI_Parser *p = &a->parser;
+ int i;
+
+ for (i = 0; i < p->escape_ptr; ++i)
+ {
+ vt102_send (v, p->escape_buf[i]);
+ }
+
+ p->escape_ptr = 0;
+ p->in_escape = 0;
+}
+
+void
+ansi_parse_deckey (ANSI * a, VT102 * v)
+{
+ ANSI_Parser *p = &a->parser;
+ if ((p->escape_buf[1] != '[') && (p->escape_buf[1] != 'O'))
+ {
+ ansi_flush_escape (a, v);
+ return;
+ }
+
+ if ((p->escape_buf[2] >= 'A') || (p->escape_buf[2] <= 'Z'))
+ {
+ vt102_send (v, KEY_UP + (p->escape_buf[2] - 'A'));
+ }
+ else if ((p->escape_buf[2] >= 'a') || (p->escape_buf[2] <= 'z'))
+ {
+ vt102_send (v, KEY_154 + (p->escape_buf[2] - 'a'));
+ }
+ else
+ {
+ ansi_flush_escape (a, v);
+ return;
+ }
+ p->in_escape = 0;
+ p->escape_ptr = 0;
+}
+
+void
+ansi_parse_ansikey (ANSI * a, VT102 * v)
+{
+ ANSI_Parser *p = &a->parser;
+
+ if ((p->escape_buf[1] != '[') || (p->escape_buf[3] != '~'))
+ {
+ ansi_flush_escape (a, v);
+ return;
+ }
+ if ((p->escape_buf[2] >= '0') || (p->escape_buf[2] <= '9'))
+ {
+ vt102_send (v, KEY_180 + (p->escape_buf[2] - '0'));
+ }
+ else
+ {
+ ansi_flush_escape (a, v);
+ return;
+ }
+
+ p->in_escape = 0;
+ p->escape_ptr = 0;
+}
+
+
+
+void
+ansi_parse_escape (ANSI * a, VT102 * v)