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