- case '[':
- switch (last)
- {
- case '@':
- while (narg--)
- vt102_insert_into_line (v, v->pos);
- break;
- case 'A':
- vt102_cursor_relative (v, 0, -narg);
- break;
- case 'e':
- case 'B':
- vt102_cursor_relative (v, 0, narg);
- break;
- case 'a':
- case 'C':
- vt102_cursor_relative (v, narg, 0);
- break;
- case 'D':
- vt102_cursor_relative (v, -narg, 0);
- break;
- case 'E':
- vt102_cursor_relative (v, 0, narg);
- vt102_cursor_carriage_return (v);
- break;
- case 'F':
- vt102_cursor_relative (v, 0, -narg);
- vt102_cursor_carriage_return (v);
- break;
- case 'G':
- vt102_cursor_absolute (v, narg - 1, v->pos.y);
- break;
- case 'H':
- case 'f':
- {
- int x, y;
-
- y = narg - 1;
-
- ptr = index (arg, ';');
- if (ptr)
- x = atoi (ptr + 1) - 1;
- else
- x = 0;
-
- vt102_cursor_absolute (v, x, y);
- }
- break;
- case 'I':
- while (narg--)
- vt102_cursor_advance_tab (c->v);
- break;
- case 'J':
- if (len == 2)
- narg = 0; /*Different default */
- switch (narg)
- {
- case 0:
- crt_erase (&v->crt, v->pos, v->screen_end, 1, v->color);
- break;
- case 1:
- crt_erase (&v->crt, v->screen_start, v->pos, 1, v->color);
- break;
- case 2:
- crt_erase (&v->crt, v->screen_start, v->screen_end, 1,
- v->color);
- break;
- }
- break;
- case 'K':
- {
- CRT_Pos ls = { 0, v->pos.y };
- CRT_Pos le = { VT102_COLS - 1, v->pos.y };
- if (len == 2)
- narg = 0; /*Different default */
-
- switch (narg)
- {
- case 0:
- crt_erase (&v->crt, v->pos, le, 1, v->color);
- break;
- case 1:
- crt_erase (&v->crt, ls, v->pos, 1, v->color);
- break;
- case 2:
- crt_erase (&v->crt, ls, le, 1, v->color);
- break;
- }
- }
- break;
-
- case 'L':
- if ((v->pos.y >= v->top_margin.y)
- && (v->pos.y <= v->bottom_margin.y))
- {
- while (narg--)
- crt_scroll_down (&v->crt, v->pos, v->bottom_margin, 1,
- v->color);
- }
- break;
-
- case 'M':
- if ((v->pos.y >= v->top_margin.y)
- && (v->pos.y <= v->bottom_margin.y))
- {
- while (narg--)
- {
- vt102_history (c, v->pos, v->bottom_margin);
- crt_scroll_up (&v->crt, v->pos, v->bottom_margin, 1,
- v->color);
- }
- }
- break;
- case 'P':
- while (narg--)
- vt102_delete_from_line (v, v->pos);
- break;
- case 'R':
- //FIXME: cursor position report - does anything use that?
- break;
- case 'S':
- while (narg--)
- {
- vt102_history (c, v->top_margin, v->bottom_margin);
- crt_scroll_up (&v->crt, v->top_margin, v->bottom_margin, 1,
- v->color);
- }
- break;
- case 'T':
- while (narg--)
- crt_scroll_down (&v->crt, v->top_margin, v->bottom_margin, 1,
- v->color);
- break;
- case 'X':
- {
- CRT_Pos end = v->pos;
- if (!narg)
- narg++;
-
- end.x += narg - 1;
- if (end.x > v->bottom_margin.x)
- end.x = v->bottom_margin.x;
-
- crt_erase (&v->crt, v->pos, end, 1, v->color);
- }
- break;
- case 'Z':
- while (narg--)
- vt102_cursor_retreat_tab (c->v);
- break;
- case '`':
- vt102_cursor_absolute (v, narg - 1, v->pos.y);
- break;
- case 'b':
- while (narg--)
- vt102_regular_char (c, v, v->last_reg_char);
- break;
- case 'c':
- //FIXME:
- break;
- case 'd':
- vt102_cursor_absolute (v, v->pos.x, narg - 1);
- break;
- case 'g':
- if (len == 2)
- narg = 0; /*Different default */
-
- switch (narg)
- {
- case 0:
- v->tabs[v->pos.x] = 0;
- break;
- case 2: //FIXME: - LA120 says current line only WTF?
- case 3:
- memset (v->tabs, 0, sizeof (v->tabs));
- break;
- }
- break;
-
- case 'i': //4,5 Turn printer on and off WTF?
- //FIXME
- break;
- case 'h':
- case 'l':
- vt102_parse_mode_string (v, &buf[1], len - 1);
- break;
-
-
- case 'm':
- vt102_parse_attr_string (v, &buf[1], len - 1);
- break;
- case 'n': // 6 request cursor position
- //FIXME
- break;
- case 'r':
- v->top_margin = v->screen_start;
- v->bottom_margin = v->screen_end;
-
- if ((len > 2) && (ptr = index (arg, ';')))
- {
- ptr++;
- v->top_margin.y = narg - 1;
- v->bottom_margin.y = atoi (ptr) - 1;
- }
-
- if (v->top_margin.y < v->screen_start.y)
- v->top_margin.y = v->screen_start.y;
- if (v->top_margin.y > v->screen_end.y)
- v->top_margin.y = v->screen_end.y;
- if (v->bottom_margin.y < v->screen_start.y)
- v->bottom_margin.y = v->screen_start.y;
- if (v->bottom_margin.y > v->screen_end.y)
- v->bottom_margin.y = v->screen_end.y;
-
- vt102_cursor_home (v);
- break;
- case 's':
- v->saved.pos = v->pos;
- break;
- case 'u':
- v->pos = v->saved.pos;
- vt102_cursor_normalize (v);
- v->pending_wrap = 0;
- break;
-
- default:
- log_f (c->l, "<%s:%d unhandled CSI: \\033%s>", __FILE__, __LINE__,
- buf);
-
- ;
- }
- break;
- default:
- log_f (c->l, "<%s:%d unhandled sequence: \\033%s>", __FILE__,
- __LINE__, buf);
- ;