+ case '[':
+ switch (last)
+ {
+ case 'A':
+ vt102_cursor_relative (v, 0, -narg);
+ break;
+ case 'B':
+ vt102_cursor_relative (v, 0, narg);
+ break;
+ 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 'J':
+ switch (narg)
+ {
+ case 1:
+ crt_erase (&v->crt, v->pos, v->screen_end, 1);
+ break;
+ case 2:
+ crt_erase (&v->crt, v->screen_start, v->screen_end, 1);
+ 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);
+ break;
+ case 1:
+ crt_erase (&v->crt, ls, v->pos, 1);
+ break;
+ case 2:
+ crt_erase (&v->crt, ls, le, 1);
+ break;
+ }
+ }
+ break;
+
+ case 'P':
+ while (narg--)
+ vt102_delete_from_line (v, v->pos);
+ 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);
+ }
+ 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);
+ }
+ }
+ break;
+
+ case 'g':
+ if (len == 2)
+ narg = 0; /*Different default */
+
+ switch (narg)
+ {
+ case 0:
+ v->tabs[v->pos.x] = 0;
+ break;
+ case 3:
+ memset (v->tabs, 0, sizeof (v->tabs));
+ break;
+ }
+ 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 '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:
+#if 0
+ fprintf (stderr, "unhandled CSI \\033%s\n", buf, buf[0]);
+#endif
+ ;
+ }
+ break;
+ default:
+#if 0
+ fprintf (stderr, "unhandled CSI \\033%s\n", buf, buf[0]);
+#endif
+ ;