xref: /original-bsd/lib/libcurses/insertln.c (revision c3e32dec)
1 /*
2  * Copyright (c) 1981, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)insertln.c	8.1 (Berkeley) 06/04/93";
10 #endif	/* not lint */
11 
12 #include <curses.h>
13 #include <string.h>
14 
15 /*
16  * winsertln --
17  *	Do an insert-line on the window, leaving (cury, curx) unchanged.
18  */
19 int
20 winsertln(win)
21 	register WINDOW *win;
22 {
23 
24 	register int y, i;
25 	register __LINE *temp;
26 
27 #ifdef DEBUG
28 	__CTRACE("insertln: (%0.2o)\n", win);
29 #endif
30 	if (win->orig == NULL)
31 		temp = win->lines[win->maxy - 1];
32 	for (y = win->maxy - 1; y > win->cury; --y) {
33 		win->lines[y]->flags &= ~__ISPASTEOL;
34 		win->lines[y - 1]->flags &= ~__ISPASTEOL;
35 		if (win->orig == NULL)
36 			win->lines[y] = win->lines[y - 1];
37 		else
38 			(void)memcpy(win->lines[y]->line,
39 			    win->lines[y - 1]->line,
40 			    win->maxx * __LDATASIZE);
41 		__touchline(win, y, 0, win->maxx - 1, 0);
42 	}
43 	if (win->orig == NULL)
44 		win->lines[y] = temp;
45 	else
46 		temp = win->lines[y];
47 	for(i = 0; i < win->maxx; i++) {
48 		temp->line[i].ch = ' ';
49 		temp->line[i].attr = 0;
50 	}
51 	__touchline(win, y, 0, win->maxx - 1, 0);
52 	if (win->orig == NULL)
53 		__id_subwins(win);
54 	return (OK);
55 }
56