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