xref: /illumos-gate/usr/src/ucblib/libcurses/insertln.c (revision 6d3b960aa395b3d268922a1938aed248a213725b)
1 /*
2  * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
7 /*	  All Rights Reserved  	*/
8 
9 /*
10  * Copyright (c) 1980 Regents of the University of California.
11  * All rights reserved.  The Berkeley software License Agreement
12  * specifies the terms and conditions for redistribution.
13  */
14 
15 /*LINTLIBRARY*/
16 
17 #ifndef lint
18 static char
19 sccsid[] = "@(#)insertln.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */
20 #endif /* not lint */
21 
22 #include	"curses.ext"
23 #include	<string.h>
24 
25 /*
26  *	This routine performs an insert-line on the window, leaving
27  * (_cury,_curx) unchanged.
28  */
29 
30 int
31 winsertln(WINDOW *win)
32 {
33 	char	*temp;
34 	int	y;
35 	char	*end;
36 
37 #ifdef	DEBUG
38 	fprintf(outf, "INSERTLN(%0.2o)\n", win);
39 #endif
40 	if (win->_orig == NULL)
41 		temp = win->_y[win->_maxy - 1];
42 	for (y = win->_maxy - 1; y > win->_cury; --y) {
43 		if (win->_orig == NULL)
44 			win->_y[y] = win->_y[y - 1];
45 		else
46 			(void) memmove(win->_y[y], win->_y[y-1], win->_maxx);
47 		(void) touchline(win, y, 0, win->_maxx - 1);
48 	}
49 	if (win->_orig == NULL)
50 		win->_y[y] = temp;
51 	else
52 		temp = win->_y[y];
53 	for (end = &temp[win->_maxx]; temp < end; )
54 		*temp++ = ' ';
55 	(void) touchline(win, y, 0, win->_maxx - 1);
56 	if (win->_orig == NULL)
57 		_id_subwins(win);
58 	return (OK);
59 }
60