+}
+
+void
+vt102_parse_esc (Context * c)
+{
+ VT102 *v = c->v;
+ VT102_parser *p = &v->parser;
+
+#ifdef DEBUG
+ p->cmd_buf[p->cmd_ptr] = 0;
+ log_f (c->l, "<cmd in x=%3d y=%2d aw=%d vt=%d <ESC>%s >", v->pos.x,
+ v->pos.y, v->pending_wrap,
+ !v->private_modes[VT102_PRIVATE_MODE_VT52], p->cmd_buf);
+#endif
+
+ if (!v->private_modes[VT102_PRIVATE_MODE_VT52])
+ {
+ int ate = 1;
+
+ switch (p->cmd_buf[0])
+ {
+ case 'A':
+ vt102_cursor_relative (v, 0, -1);
+ break;
+ case 'B':
+ vt102_cursor_relative (v, 0, 1);
+ break;
+ case 'C':
+ vt102_cursor_relative (v, 1, 0);
+ break;
+ case 'D':
+ vt102_cursor_relative (v, -1, 0);
+ break;
+ case 'F':
+ v->cs = 1;
+ v->g[1] = VT102_CSID_VT52;
+ break;
+ case 'G':
+ v->cs = 0;
+ v->g[0] = VT102_CSID_US;
+ break;
+ case 'H':
+ vt102_cursor_absolute (v, 0, 0);
+ break;
+ case 'I':
+ vt102_cursor_retreat_line (c);
+ break;
+ case 'J':
+ crt_erase (&v->crt, v->pos, v->screen_end, 1, v->color);
+ break;
+ case 'K':
+ {
+ CRT_Pos le = { v->current_width - 1, v->pos.y };
+ crt_erase (&v->crt, v->pos, le, 1, v->color);
+ }
+ break;
+ case 'Y':
+ vt102_cursor_absolute (v, p->cmd_buf[2] - 040, p->cmd_buf[1] - 040);
+ break;
+ case 'V': //Print current line
+ break;
+ case 'W': //Printer on
+ break;
+ case 'X': //printer off
+ break;
+ case ']': //print screen
+ break;
+ case 'Z': //ID
+ vt102_send_id (c, "\033/K");
+ break;
+ case '^': //Autoprint on
+ break;
+ case '_': //Autoprint off
+ break;
+ case '=':
+ v->application_keypad_mode = 1;
+ break;
+ case '>':
+ v->application_keypad_mode = 0;
+ break;
+ default:
+ ate = 0;
+ }
+ if (ate)
+ return;
+ }
+
+
+/*If you edit this switch don't forget to edit the length and termination tables*/
+ switch (p->cmd_buf[0])
+ {
+ case 'D':
+ vt102_cursor_advance_line (c);
+ break;
+
+ case 'E':
+ vt102_cursor_advance_line (c);
+ v->pos.x = v->top_margin.x;
+ vt102_cursor_normalize (v);
+ v->pending_wrap = 0;
+ break;
+ case 'H':
+ v->tabs[v->pos.x]++;
+ break;
+ case 'M':
+ vt102_cursor_retreat_line (c);
+ break;
+ case 'N': //select G2 for one char
+ break;
+ case 'O': //select G3 for one char
+ break;
+ case 'Z':
+ vt102_send_id (c, terminal_id);
+ break;
+ case 'c':
+ vt102_reset (v);
+
+
+ break;
+ case '=':
+ v->application_keypad_mode = 1;
+ break;
+ case '>':
+ v->application_keypad_mode = 0;
+ break;
+
+ case '#':
+ switch (p->cmd_buf[1])
+ {
+ case '3': //top of double height line
+ case '4': //bottom of double height line
+ case '5': //single width line
+ case '6': //double width line
+ break;
+ case '8':
+ /*DECALN*/
+ {
+ int i;
+ crt_erase (&v->crt, v->screen_start, v->screen_end, 1,
+ CRT_COLOR_NORMAL);
+ for (i = 0; i < CRT_ADDR_POS (&v->screen_end); ++i)
+ v->crt.screen[i].chr = 'E';
+ }
+ break;
+ default:
+
+ log_f (c->l,
+ "<%s:%d unhandled ESC: \\033 \\043 \\%03o (ESC # %c)>",
+ __FILE__, __LINE__, p->cmd_buf[1], safe_ch (p->cmd_buf[1]));
+
+ }
+ break;
+ case '<':
+ /*Set ansi mode - ignored */
+ break;
+
+ case '7':
+ vt102_save_state (v);
+ break;
+ case '8':
+ vt102_restore_state (v);
+ break;
+ case ']': /*Set various titles */
+ //FIXME:
+ break;
+ case '[':
+ vt102_parse_csi (c, p->cmd_buf, p->cmd_ptr);
+ break;
+ case '(': /*Charsets */
+ case ')':
+ case '+':
+ case '*':
+ case '%':
+ vt102_scs (c, p->cmd_buf[0], p->cmd_buf[1]);
+ break;
+ default:
+ log_f (c->l, "<%s:%d unhandled ESC: \\033 \\%03o (ESC %c)>", __FILE__,
+ __LINE__, p->cmd_buf[0], safe_ch (p->cmd_buf[0]));
+
+ ;
+ }
+
+ p->cmd_buf[p->cmd_ptr] = 0;
+#ifdef DEBUG
+ log_f (c->l, "<cmd out x=%3d y=%2d aw=%d>", v->pos.x, v->pos.y,
+ v->pending_wrap);
+#endif