xref: /original-bsd/lib/libcurses/box.c (revision 237fdba6)
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.4 (Berkeley) 06/01/90";
10 #endif /* not lint */
11 
12 # include	"curses.ext"
13 
14 /*
15  *	This routine draws a box around the given window with "vert"
16  * as the vertical delimiting char, and "hor", as the horizontal one.
17  *
18  */
19 box(win, vert, hor)
20 reg WINDOW	*win;
21 char		vert, hor; {
22 
23 	reg int		i;
24 	reg int		endy, endx;
25 	reg 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 }
40