xref: /original-bsd/lib/libcurses/insertln.c (revision e9b82df0)
1 /*
2  * Copyright (c) 1981 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)insertln.c	5.4 (Berkeley) 06/01/90";
10 #endif /* not lint */
11 
12 # include	"curses.ext"
13 
14 /*
15  *	This routine performs an insert-line on the window, leaving
16  * (_cury,_curx) unchanged.
17  *
18  */
19 winsertln(win)
20 reg WINDOW	*win; {
21 
22 	reg char	*temp;
23 	reg int		y;
24 	reg char	*end;
25 	reg int		x;
26 
27 #ifdef	DEBUG
28 	fprintf(outf, "INSERTLN(%0.2o)\n", win);
29 #endif
30 	if (win->_orig == NULL)
31 		temp = win->_y[win->_maxy - 1];
32 	for (y = win->_maxy - 1; y > win->_cury; --y) {
33 		if (win->_orig == NULL)
34 			win->_y[y] = win->_y[y - 1];
35 		else
36 			bcopy(win->_y[y - 1], win->_y[y], win->_maxx);
37 		touchline(win, y, 0, win->_maxx - 1);
38 	}
39 	if (win->_orig == NULL)
40 		win->_y[y] = temp;
41 	else
42 		temp = win->_y[y];
43 	for (end = &temp[win->_maxx]; temp < end; )
44 		*temp++ = ' ';
45 	touchline(win, y, 0, win->_maxx - 1);
46 	if (win->_orig == NULL)
47 		_id_subwins(win);
48 }
49