void
emulate(void)
{
char buf[BUFS+1];
int n;
int c;
int standout = 0;
int insmode = 0;
for (;;) {
if (x > xmax || y > ymax) {
x = 0;
newline();
}
buf[0] = get_next_char();
buf[1] = '\0';
switch(buf[0]) {
case '\000': /* nulls, just ignore 'em */
break;
case '\007': /* bell */
ringbell();
break;
case '\t': /* tab modulo 8 */
x = (x|7)+1;
break;
case '\033':
switch(get_next_char()) {
case 'j':
get_next_char();
break;
case '&': /* position cursor &c */
switch(get_next_char()) {
case 'a':
for (;;) {
n = number(buf, nil);
switch(buf[0]) {
case 'r':
case 'y':
y = n;
continue;
case 'c':
x = n;
continue;
case 'R':
case 'Y':
y = n;
break;
case 'C':
x = n;
break;
}
break;
}
break;
case 'd': /* underline stuff */
if ((n=get_next_char())>='A' && n <= 'O')
standout++;
else if (n == '@')
standout = 0;
break;
default:
get_next_char();
break;
}
break;
case 'i': /* back tab */
if (x>0)
x = (x-1) & ~07;
break;
case 'H': /* home cursor */
case 'h':
x = 0;
y = 0;
break;
case 'L': /* insert blank line */
scroll(y, ymax, y+1, y);
break;
case 'M': /* delete line */
scroll(y+1, ymax+1, y, ymax);
break;
case 'J': /* clear to end of display */
xtipple(Rpt(pt(0, y+1),
pt(xmax+1, ymax+1)));
/* flow */
case 'K': /* clear to EOL */
xtipple(Rpt(pt(x, y),
pt(xmax+1, y+1)));
break;