- unsigned long *scroll_top;
- unsigned long *newscr;
- int scroll_size, size, i;
- int scrtop_is_disptop = (scrtop==disptop);
-static int recursive = 0;
-
- /* Only scroll more than the window if we're doing a 10% scroll */
- if (!recursive && lines > botline - topline + 1)
- lines = botline - topline + 1;
-
- scroll_top = scrtop + topline*(cols+1);
- size = (lines < 0 ? -lines : lines) * (cols+1);
- scroll_size = (botline - topline + 1) * (cols+1) - size;
-
- if (lines > 0 && topline == 0 && alt_which == 0 && sb) {
- /*
- * Since we're going to scroll the top line and we're on the
- * scrolling screen let's also effect the scrollback buffer.
- *
- * This is normally done by moving the position the screen
- * painter reads from to reduce the amount of memory copying
- * required.
- */
- if (scroll_size >= 0 && !recursive) {
- newscr = scrtop + lines * (cols+1);
-
- if (newscr > sbbot && botline == rows-1) {
- /* We've hit the bottom of memory, so we have to do a
- * physical scroll. But instead of just 1 line do it
- * by 10% of the available memory.
- *
- * If the scroll region isn't the whole screen then we can't
- * do this as it stands. We would need to recover the bottom
- * of the screen from the scroll buffer after being sure that
- * it doesn't get deleted.
- */
-
- i = (rows+savelines)/10;
-
- /* Make it simple and ensure safe recursion */
- if ( i<savelines-1) {
- recursive ++;
- scroll(topline, botline, i, sb);
- recursive --;