seltop = sb ? -savelines : 0;
seltop = sb ? -savelines : topline;
static void scroll(int topline, int botline, int lines, int sb){    unsigned long *line, *line2;    int i, seltop;    if (topline != 0 || alt_which != 0)	sb = FALSE;    if (lines < 0) {	while (lines < 0) {	    line = delpos234(screen, botline);            line = resizeline(line, cols);	    for (i = 0; i < cols; i++)		line[i + 1] = erase_char;	    line[cols + 1] = 0;	    addpos234(screen, line, topline);	    if (selstart.y >= topline && selstart.y <= botline) {		selstart.y++;		if (selstart.y > botline) {		    selstart.y = botline;		    selstart.x = 0;		}	    }	    if (selend.y >= topline && selend.y <= botline) {		selend.y++;		if (selend.y > botline) {		    selend.y = botline;		    selend.x = 0;		}	    }	    lines++;	}    } else {	while (lines > 0) {	    line = delpos234(screen, topline);	    if (sb && savelines > 0) {		int sblen = count234(scrollback);		/*		 * We must add this line to the scrollback. We'll		 * remove a line from the top of the scrollback to		 * replace it, or allocate a new one if the		 * scrollback isn't full.		 */		if (sblen == savelines) {		    sblen--, line2 = delpos234(scrollback, 0);		} else {		    line2 = smalloc(TSIZE * (cols + 2));		    line2[0] = cols;		}		addpos234(scrollback, line, sblen);		line = line2;		/*		 * If the user is currently looking at part of the		 * scrollback, and they haven't enabled any options		 * that are going to reset the scrollback as a		 * result of this movement, then the chances are		 * they'd like to keep looking at the same line. So		 * we move their viewpoint at the same rate as the		 * scroll, at least until their viewpoint hits the		 * top end of the scrollback buffer, at which point		 * we don't have the choice any more.		 * 		 * Thanks to Jan Holmen Holsten for the idea and		 * initial implementation.		 */		if (disptop > -savelines && disptop < 0)		    disptop--;	    }            line = resizeline(line, cols);	    for (i = 0; i < cols; i++)		line[i + 1] = erase_char;	    line[cols + 1] = 0;	    addpos234(screen, line, botline);	    /*	     * If the selection endpoints move into the scrollback,	     * we keep them moving until they hit the top. However,	     * of course, if the line _hasn't_ moved into the	     * scrollback then we don't do this, and cut them off	     * at the top of the scroll region.	     * 	     * This applies to selstart and selend (for an existing	     * selection), and also selanchor (for one being	     * selected as we speak).	     */	    seltop = sb ? -savelines : 0;	    if (selstart.y >= seltop && selstart.y <= botline) {		selstart.y--;		if (selstart.y < seltop) {		    selstart.y = seltop;		    selstart.x = 0;		}	    }	    if (selend.y >= seltop && selend.y <= botline) {		selend.y--;		if (selend.y < seltop) {		    selend.y = seltop;		    selend.x = 0;		}	    }	    if (selanchor.y >= seltop && selanchor.y <= botline) {		selanchor.y--;		if (selanchor.y < seltop) {		    selanchor.y = seltop;		    selanchor.x = 0;		}	    }	    lines--;	}    }}