xref: /csrg-svn/lib/libcurses/box.c (revision 34677)
122652Sdist /*
2*34677Sbostic  * Copyright (c) 1981 Regents of the University of California.
3*34677Sbostic  * All rights reserved.
4*34677Sbostic  *
5*34677Sbostic  * Redistribution and use in source and binary forms are permitted
6*34677Sbostic  * provided that this notice is preserved and that due credit is given
7*34677Sbostic  * to the University of California at Berkeley. The name of the University
8*34677Sbostic  * may not be used to endorse or promote products derived from this
9*34677Sbostic  * software without specific prior written permission. This software
10*34677Sbostic  * is provided ``as is'' without express or implied warranty.
1122652Sdist  */
1222652Sdist 
1322652Sdist #ifndef lint
14*34677Sbostic static char sccsid[] = "@(#)box.c	5.2 (Berkeley) 06/08/88";
15*34677Sbostic #endif /* not lint */
1622652Sdist 
175862Sarnold # include	"curses.ext"
182237Sarnold 
192237Sarnold /*
202237Sarnold  *	This routine draws a box around the given window with "vert"
212237Sarnold  * as the vertical delimiting char, and "hor", as the horizontal one.
222237Sarnold  *
232237Sarnold  */
242237Sarnold box(win, vert, hor)
252237Sarnold reg WINDOW	*win;
262237Sarnold char		vert, hor; {
272237Sarnold 
282237Sarnold 	reg int		i;
292237Sarnold 	reg int		endy, endx;
302237Sarnold 	reg char	*fp, *lp;
312237Sarnold 
322237Sarnold 	endx = win->_maxx;
332237Sarnold 	endy = win->_maxy - 1;
342237Sarnold 	fp = win->_y[0];
352237Sarnold 	lp = win->_y[endy];
362237Sarnold 	for (i = 0; i < endx; i++)
372237Sarnold 		fp[i] = lp[i] = hor;
382237Sarnold 	endx--;
392237Sarnold 	for (i = 0; i <= endy; i++)
402237Sarnold 		win->_y[i][0] = (win->_y[i][endx] = vert);
412237Sarnold 	if (!win->_scroll && (win->_flags&_SCROLLWIN))
422237Sarnold 		fp[0] = fp[endx] = lp[0] = lp[endx] = ' ';
432237Sarnold 	touchwin(win);
442237Sarnold }
45