i = par[0]; do { if (y == scrreg_top) scrolldown(); else y--; i--; } while (i > 0);
y -= par[0] ? par[0] : 1;
putc_gotpars(ch)	char ch;{	int i;	vt100state = ESnormal;	switch (ch) {	case 'A':		/* Up			 */		i = par[0];		do {			if (y == scrreg_top)				scrolldown();			else				y--;			i--;		} while (i > 0);		break;	case 'B':		/* Down			 */		i = par[0];		do {			if (y == scrreg_bottom)				scrollup();			else				y++;			i--;		} while (i > 0);		break;	case 'C':		/* Right		 */		x+= par[0] ? par[0] : 1;		break;	case 'D':		/* Left			 */		x-= par[0] ? par[0] : 1;		break;	case 'H':		/* Set cursor position	 */		x = par[1] - 1;		y = par[0] - 1;		hanging_cursor = 0;		break;	case 'J':		/* Clear part of screen	 */		clear_screen(par[0]);		break;	case 'K':		/* Clear part of line	 */		clear_line(par[0]);		break;	case 'L':		/* Add line		*/		if (scrreg_top < scrreg_bottom) {			i = scrreg_top;			scrreg_top = y;			scrolldown();			scrreg_top = i;		} else			clear_line(0);		break;	case 'M':		/* Delete line		*/		if (scrreg_top < scrreg_bottom) {			i = scrreg_top;			scrreg_top = y;			scrollup();			scrreg_top = i;		} else			clear_line(0);		break;	case 'g':		/* Clear tab stops	 */		if (numpars >= 1 && par[0] == 3)			reset_tabs();		break;	case 'm':		/* Set attribute	 */		for (i = 0; i < numpars; i++) {			switch (par[i]) {			case 0:				attr = ATTR_NONE;				break;			case 1:				attr |= ATTR_BOLD;				break;			case 4:				attr |= ATTR_UNDER;				break;			case 7:				attr |= ATTR_REVERSE;				break;			case 21:				attr &= ~ATTR_BOLD;				break;			case 24:				attr &= ~ATTR_UNDER;				break;			case 27:				attr &= ~ATTR_REVERSE;				break;			}		}		break;	case 'r':		/* Set scroll region	 */		/* ensure top < bottom, and both within limits */		if ((numpars > 0) && (par[0] < scrrows))			scrreg_top = par[0] - 1;		else			scrreg_top = 0;		if ((numpars > 1) && (par[1] <= scrrows) && (par[1] > par[0]))			scrreg_bottom = par[1] - 1;		else			scrreg_bottom = scrrows - 1;		break;	}}