xref: /original-bsd/lib/libcurses/box.c (revision be1f24e8)
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.6 (Berkeley) 09/14/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->topline->line;
30 	lp = win->lines[endy]->line;
31 	for (i = 0; i < endx; i++)
32 		fp[i] = lp[i] = hor;
33 	endx--;
34 	for (i = 0; i <= endy; i++)
35 		win->lines[i]->line[0] = (win->lines[i]->line[endx] = vert);
36 	if (!(win->flags & __SCROLLOK) && (win->flags & __SCROLLWIN))
37 		fp[0] = fp[endx] = lp[0] = lp[endx] = ' ';
38 	touchwin(win);
39 	return (OK);
40 }
41