xref: /original-bsd/lib/libcurses/box.c (revision 7748387a)
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[] = "@(#)box.c	5.5 (Berkeley) 08/23/92";
10 #endif	/* not lint */
11 
12 #include <curses.h>
13 
14 /*
15  * box --
16  *	Draw a box around the given window with "vert" as the vertical
17  *	delimiting char, and "hor", as the horizontal one.
18  */
19 int
20 box(win, vert, hor)
21 	register WINDOW *win;
22 	int vert, hor;
23 {
24 	register int endy, endx, i;
25 	register char *fp, *lp;
26 
27 	endx = win->_maxx;
28 	endy = win->_maxy - 1;
29 	fp = win->_y[0];
30 	lp = win->_y[endy];
31 	for (i = 0; i < endx; i++)
32 		fp[i] = lp[i] = hor;
33 	endx--;
34 	for (i = 0; i <= endy; i++)
35 		win->_y[i][0] = (win->_y[i][endx] = vert);
36 	if (!win->_scroll && (win->_flags & _SCROLLWIN))
37 		fp[0] = fp[endx] = lp[0] = lp[endx] = ' ';
38 	touchwin(win);
39 	return (OK);
40 }
41