]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/lib_box.c
ncurses 4.2
[ncurses.git] / ncurses / lib_box.c
1 /****************************************************************************
2  * Copyright (c) 1998 Free Software Foundation, Inc.                        *
3  *                                                                          *
4  * Permission is hereby granted, free of charge, to any person obtaining a  *
5  * copy of this software and associated documentation files (the            *
6  * "Software"), to deal in the Software without restriction, including      *
7  * without limitation the rights to use, copy, modify, merge, publish,      *
8  * distribute, distribute with modifications, sublicense, and/or sell       *
9  * copies of the Software, and to permit persons to whom the Software is    *
10  * furnished to do so, subject to the following conditions:                 *
11  *                                                                          *
12  * The above copyright notice and this permission notice shall be included  *
13  * in all copies or substantial portions of the Software.                   *
14  *                                                                          *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22  *                                                                          *
23  * Except as contained in this notice, the name(s) of the above copyright   *
24  * holders shall not be used in advertising or otherwise to promote the     *
25  * sale, use or other dealings in this Software without prior written       *
26  * authorization.                                                           *
27  ****************************************************************************/
28
29 /****************************************************************************
30  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
31  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
32  ****************************************************************************/
33
34
35
36 /*
37 **      lib_box.c
38 **
39 **      The routine wborder().
40 **
41 */
42
43 #include <curses.priv.h>
44
45 MODULE_ID("$Id: lib_box.c,v 1.10 1998/02/11 12:13:56 tom Exp $")
46
47 int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts,
48         chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
49 {
50 short i;
51 short endx, endy;
52
53     T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"),
54         win,
55         _tracechtype2(1,ls),
56         _tracechtype2(2,rs),
57         _tracechtype2(3,ts),
58         _tracechtype2(4,bs),
59         _tracechtype2(5,tl),
60         _tracechtype2(6,tr),
61         _tracechtype2(7,bl),
62         _tracechtype2(8,br)));
63
64         if (!win)
65           returnCode(ERR);
66
67         if (ls == 0) ls = ACS_VLINE;
68         if (rs == 0) rs = ACS_VLINE;
69         if (ts == 0) ts = ACS_HLINE;
70         if (bs == 0) bs = ACS_HLINE;
71         if (tl == 0) tl = ACS_ULCORNER;
72         if (tr == 0) tr = ACS_URCORNER;
73         if (bl == 0) bl = ACS_LLCORNER;
74         if (br == 0) br = ACS_LRCORNER;
75
76         ls = _nc_render(win, ls);
77         rs = _nc_render(win, rs);
78         ts = _nc_render(win, ts);
79         bs = _nc_render(win, bs);
80         tl = _nc_render(win, tl);
81         tr = _nc_render(win, tr);
82         bl = _nc_render(win, bl);
83         br = _nc_render(win, br);
84
85         T(("using %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx", ls, rs, ts, bs, tl, tr, bl, br));
86
87         endx = win->_maxx;
88         endy = win->_maxy;
89
90         for (i = 0; i <= endx; i++) {
91                 win->_line[0].text[i] = ts;
92                 win->_line[endy].text[i] = bs;
93         }
94         win->_line[endy].firstchar = win->_line[0].firstchar = 0;
95         win->_line[endy].lastchar = win->_line[0].lastchar = endx;
96
97         for (i = 0; i <= endy; i++) {
98                 win->_line[i].text[0] =  ls;
99                 win->_line[i].text[endx] =  rs;
100                 win->_line[i].firstchar = 0;
101                 win->_line[i].lastchar = endx;
102         }
103         win->_line[0].text[0] = tl;
104         win->_line[0].text[endx] = tr;
105         win->_line[endy].text[0] = bl;
106         win->_line[endy].text[endx] = br;
107
108         _nc_synchook(win);
109         returnCode(OK);
110 }