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