xref: /csrg-svn/lib/libcurses/box.c (revision 67082)
122652Sdist /*
2*67082Sbostic  * Copyright (c) 1981, 1993, 1994
361262Sbostic  *	The Regents of the University of California.  All rights reserved.
434677Sbostic  *
542651Sbostic  * %sccs.include.redist.c%
622652Sdist  */
722652Sdist 
822652Sdist #ifndef lint
9*67082Sbostic static char sccsid[] = "@(#)box.c	8.2 (Berkeley) 05/04/94";
1055948Sbostic #endif	/* not lint */
1122652Sdist 
12*67082Sbostic #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
box(win,vert,hor)202237Sarnold box(win, vert, hor)
2155948Sbostic 	register WINDOW *win;
2255948Sbostic 	int vert, hor;
2355948Sbostic {
2455948Sbostic 	register int endy, endx, i;
2556647Selan 	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++) {
3256647Selan 		fp[i].ch = lp[i].ch = hor;
3356647Selan 		fp[i].attr &= ~__STANDOUT;
3456647Selan 		lp[i].attr &= ~__STANDOUT;
3556596Selan 	}
362237Sarnold 	endx--;
3756596Selan 	for (i = 0; i <= endy; i++) {
3856647Selan 		win->lines[i]->line[0].ch = vert;
3956647Selan 	        win->lines[i]->line[endx].ch = vert;
4056647Selan 		win->lines[i]->line[0].attr &= ~__STANDOUT;
4156647Selan 		win->lines[i]->line[endx].attr &= ~__STANDOUT;
4256596Selan 	}
4356596Selan 	if (!(win->flags & __SCROLLOK) && (win->flags & __SCROLLWIN)) {
4456647Selan 		fp[0].ch = fp[endx].ch = lp[0].ch = lp[endx].ch = ' ';
4556647Selan 		fp[0].attr &= ~__STANDOUT;
4656647Selan 		fp[endx].attr &= ~__STANDOUT;
4756647Selan 		lp[0].attr &= ~__STANDOUT;
4856647Selan 		lp[endx].attr &= ~__STANDOUT;
4956596Selan 	}
5056650Selan 	__touchwin(win);
5157472Sbostic 	return (OK);
522237Sarnold }
53