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