xref: /csrg-svn/lib/libcurses/box.c (revision 56647)
122652Sdist /*
234677Sbostic  * Copyright (c) 1981 Regents of the University of California.
334677Sbostic  * All rights reserved.
434677Sbostic  *
542651Sbostic  * %sccs.include.redist.c%
622652Sdist  */
722652Sdist 
822652Sdist #ifndef lint
9*56647Selan static char sccsid[] = "@(#)box.c	5.8 (Berkeley) 10/26/92";
1055948Sbostic #endif	/* not lint */
1122652Sdist 
1255948Sbostic #include <curses.h>
132237Sarnold 
142237Sarnold /*
1555948Sbostic  * box --
1655948Sbostic  *	Draw a box around the given window with "vert" as the vertical
1755948Sbostic  *	delimiting char, and "hor", as the horizontal one.
182237Sarnold  */
1955948Sbostic int
202237Sarnold box(win, vert, hor)
2155948Sbostic 	register WINDOW *win;
2255948Sbostic 	int vert, hor;
2355948Sbostic {
2455948Sbostic 	register int endy, endx, i;
25*56647Selan 	register __LDATA *fp, *lp;
262237Sarnold 
2756238Selan 	endx = win->maxx;
2856238Selan 	endy = win->maxy - 1;
2956596Selan 	fp = win->lines[0]->line;
3056238Selan 	lp = win->lines[endy]->line;
3156596Selan 	for (i = 0; i < endx; i++) {
32*56647Selan 		fp[i].ch = lp[i].ch = hor;
33*56647Selan 		fp[i].attr &= ~__STANDOUT;
34*56647Selan 		lp[i].attr &= ~__STANDOUT;
3556596Selan 	}
362237Sarnold 	endx--;
3756596Selan 	for (i = 0; i <= endy; i++) {
38*56647Selan 		win->lines[i]->line[0].ch = vert;
39*56647Selan 	        win->lines[i]->line[endx].ch = vert;
40*56647Selan 		win->lines[i]->line[0].attr &= ~__STANDOUT;
41*56647Selan 		win->lines[i]->line[endx].attr &= ~__STANDOUT;
4256596Selan 	}
4356596Selan 	if (!(win->flags & __SCROLLOK) && (win->flags & __SCROLLWIN)) {
44*56647Selan 		fp[0].ch = fp[endx].ch = lp[0].ch = lp[endx].ch = ' ';
45*56647Selan 		fp[0].attr &= ~__STANDOUT;
46*56647Selan 		fp[endx].attr &= ~__STANDOUT;
47*56647Selan 		lp[0].attr &= ~__STANDOUT;
48*56647Selan 		lp[endx].attr &= ~__STANDOUT;
4956596Selan 	}
502237Sarnold 	touchwin(win);
5155948Sbostic 	return (OK);
522237Sarnold }
53