Scroll(screen, amount) register TScreen *screen; register int amount;
Scroll(register TScreen *screen, register int amount)
Scroll(screen, amount)register TScreen *screen;register int amount;{	register int i = screen->bot_marg - screen->top_marg + 1;	register int shift;	register int bot;	register int refreshtop = 0;	register int refreshheight;	register int scrolltop;	register int scrollheight;	if(screen->cursor_state)		HideCursor();	if (amount > i)		amount = i;    if(screen->jumpscroll) {	if(screen->scroll_amt > 0) {		if(screen->refresh_amt + amount > i)			FlushScroll(screen);		screen->scroll_amt += amount;		screen->refresh_amt += amount;	} else {		if(screen->scroll_amt < 0)			FlushScroll(screen);		screen->scroll_amt = amount;		screen->refresh_amt = amount;	}	refreshheight = 0;    } else {	ScrollSelection(screen, -(amount));	if (amount == i) {		ClearScreen(screen);		return;	}	shift = -screen->topline;	bot = screen->max_row - shift;	scrollheight = i - amount;	refreshheight = amount;	if((refreshtop = screen->bot_marg - refreshheight + 1 + shift) >	 (i = screen->max_row - refreshheight + 1))		refreshtop = i;	if(screen->scrollWidget && !screen->alternate	 && screen->top_marg == 0) {		scrolltop = 0;		if((scrollheight += shift) > i)			scrollheight = i;		if((i = screen->savedlines) < screen->savelines) {			if((i += amount) > screen->savelines)				i = screen->savelines;			screen->savedlines = i;			ScrollBarDrawThumb(screen->scrollWidget);		}	} else {		scrolltop = screen->top_marg + shift;		if((i = screen->bot_marg - bot) > 0) {			scrollheight -= i;			if((i = screen->top_marg + amount - 1 - bot) >= 0) {				refreshtop += i;				refreshheight -= i;			}		}	}	if (screen->multiscroll && amount == 1 &&	    screen->topline == 0 && screen->top_marg == 0 &&	    screen->bot_marg == screen->max_row) {	    if (screen->incopy < 0 && screen->scrolls == 0)		CopyWait(screen);	    screen->scrolls++;	}	scrolling_copy_area(screen, scrolltop+amount, scrollheight, amount);	if(refreshheight > 0) {		ClearCurBackground(screen,		    (int) refreshtop * FontHeight(screen) + screen->border,		    (int) OriginX(screen),		    (unsigned) refreshheight * FontHeight(screen),		    (unsigned) Width(screen));		if(refreshheight > shift)			refreshheight = shift;	}    }	if(screen->scrollWidget && !screen->alternate && screen->top_marg == 0)		ScrnDeleteLine(screen, screen->allbuf,			screen->bot_marg + screen->savelines, 0,			amount, screen->max_col + 1);	else		ScrnDeleteLine(screen, screen->visbuf,			screen->bot_marg, screen->top_marg,			amount, screen->max_col + 1);	if(refreshheight > 0)		ScrnRefresh(screen, refreshtop, 0, refreshheight,		 screen->max_col + 1, False);}