xref: /original-bsd/lib/libcurses/scroll.c (revision 1e7fda44)
1 # include	"curses.ext"
2 
3 /*
4  *	This routine scrolls the window up a line.
5  *
6  * 05/11/81 (Berkeley) @(#)scroll.c	1.2
7  */
8 scroll(win)
9 reg WINDOW	*win; {
10 
11 	reg char	*sp;
12 	reg int		i;
13 	reg char	*temp;
14 
15 	if (!win->_scroll)
16 		return ERR;
17 	temp = win->_y[0];
18 	for (i = 0; i < win->_maxy - 2; i++)
19 		win->_y[i] = win->_y[i+1];
20 	for (sp = temp; sp - temp < win->_maxx; )
21 		*sp++ = ' ';
22 	win->_y[win->_maxy - 1] = temp;
23 	win->_cury--;
24 	if (win == curscr) {
25 		putchar('\n');
26 		if (!NONL)
27 			win->_curx = 0;
28 # ifdef DEBUG
29 		fprintf(outf, "SCROLL: win == curscr\n");
30 # endif
31 	}
32 # ifdef DEBUG
33 	else
34 		fprintf(outf, "SCROLL: win [0%o] != curscr [0%o]\n",win,curscr);
35 # endif
36 	return OK;
37 }
38