1 /* $OpenBSD: lib_box.c,v 1.3 2001/01/22 18:01:37 millert Exp $ */ 2 3 /**************************************************************************** 4 * Copyright (c) 1998,2000 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 ** lib_box.c 38 ** 39 ** The routine wborder(). 40 ** 41 */ 42 43 #include <curses.priv.h> 44 45 MODULE_ID("$From: lib_box.c,v 1.13 2000/12/10 02:43:26 tom Exp $") 46 47 NCURSES_EXPORT(int) 48 wborder 49 (WINDOW *win, 50 chtype ls, chtype rs, chtype ts, chtype bs, 51 chtype tl, chtype tr, chtype bl, chtype br) 52 { 53 NCURSES_SIZE_T i; 54 NCURSES_SIZE_T endx, endy; 55 56 T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"), 57 win, 58 _tracechtype2(1, ls), 59 _tracechtype2(2, rs), 60 _tracechtype2(3, ts), 61 _tracechtype2(4, bs), 62 _tracechtype2(5, tl), 63 _tracechtype2(6, tr), 64 _tracechtype2(7, bl), 65 _tracechtype2(8, br))); 66 67 if (!win) 68 returnCode(ERR); 69 70 if (ls == 0) 71 ls = ACS_VLINE; 72 if (rs == 0) 73 rs = ACS_VLINE; 74 if (ts == 0) 75 ts = ACS_HLINE; 76 if (bs == 0) 77 bs = ACS_HLINE; 78 if (tl == 0) 79 tl = ACS_ULCORNER; 80 if (tr == 0) 81 tr = ACS_URCORNER; 82 if (bl == 0) 83 bl = ACS_LLCORNER; 84 if (br == 0) 85 br = ACS_LRCORNER; 86 87 ls = _nc_render(win, ls); 88 rs = _nc_render(win, rs); 89 ts = _nc_render(win, ts); 90 bs = _nc_render(win, bs); 91 tl = _nc_render(win, tl); 92 tr = _nc_render(win, tr); 93 bl = _nc_render(win, bl); 94 br = _nc_render(win, br); 95 96 T(("using %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx", 97 ls, rs, ts, bs, tl, tr, bl, br)); 98 99 endx = win->_maxx; 100 endy = win->_maxy; 101 102 for (i = 0; i <= endx; i++) { 103 win->_line[0].text[i] = ts; 104 win->_line[endy].text[i] = bs; 105 } 106 win->_line[endy].firstchar = win->_line[0].firstchar = 0; 107 win->_line[endy].lastchar = win->_line[0].lastchar = endx; 108 109 for (i = 0; i <= endy; i++) { 110 win->_line[i].text[0] = ls; 111 win->_line[i].text[endx] = rs; 112 win->_line[i].firstchar = 0; 113 win->_line[i].lastchar = endx; 114 } 115 win->_line[0].text[0] = tl; 116 win->_line[0].text[endx] = tr; 117 win->_line[endy].text[0] = bl; 118 win->_line[endy].text[endx] = br; 119 120 _nc_synchook(win); 121 returnCode(OK); 122 } 123