1 /*
2 * Copyright (c) 1981, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8 #ifndef lint
9 static char sccsid[] = "@(#)box.c 8.2 (Berkeley) 05/04/94";
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
box(win,vert,hor)20 box(win, vert, hor)
21 register WINDOW *win;
22 int vert, hor;
23 {
24 register int endy, endx, i;
25 register __LDATA *fp, *lp;
26
27 endx = win->maxx;
28 endy = win->maxy - 1;
29 fp = win->lines[0]->line;
30 lp = win->lines[endy]->line;
31 for (i = 0; i < endx; i++) {
32 fp[i].ch = lp[i].ch = hor;
33 fp[i].attr &= ~__STANDOUT;
34 lp[i].attr &= ~__STANDOUT;
35 }
36 endx--;
37 for (i = 0; i <= endy; i++) {
38 win->lines[i]->line[0].ch = vert;
39 win->lines[i]->line[endx].ch = vert;
40 win->lines[i]->line[0].attr &= ~__STANDOUT;
41 win->lines[i]->line[endx].attr &= ~__STANDOUT;
42 }
43 if (!(win->flags & __SCROLLOK) && (win->flags & __SCROLLWIN)) {
44 fp[0].ch = fp[endx].ch = lp[0].ch = lp[endx].ch = ' ';
45 fp[0].attr &= ~__STANDOUT;
46 fp[endx].attr &= ~__STANDOUT;
47 lp[0].attr &= ~__STANDOUT;
48 lp[endx].attr &= ~__STANDOUT;
49 }
50 __touchwin(win);
51 return (OK);
52 }
53