150276Speter/**************************************************************************** 2262629Sdelphij * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. * 350276Speter * * 450276Speter * Permission is hereby granted, free of charge, to any person obtaining a * 550276Speter * copy of this software and associated documentation files (the * 650276Speter * "Software"), to deal in the Software without restriction, including * 750276Speter * without limitation the rights to use, copy, modify, merge, publish, * 850276Speter * distribute, distribute with modifications, sublicense, and/or sell * 950276Speter * copies of the Software, and to permit persons to whom the Software is * 1050276Speter * furnished to do so, subject to the following conditions: * 1150276Speter * * 1250276Speter * The above copyright notice and this permission notice shall be included * 1350276Speter * in all copies or substantial portions of the Software. * 1450276Speter * * 1550276Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1650276Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1750276Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 1850276Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 1950276Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2050276Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2150276Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2250276Speter * * 2350276Speter * Except as contained in this notice, the name(s) of the above copyright * 2450276Speter * holders shall not be used in advertising or otherwise to promote the * 2550276Speter * sale, use or other dealings in this Software without prior written * 2650276Speter * authorization. * 2750276Speter ****************************************************************************/ 2850276Speter 2950276Speter/**************************************************************************** 3050276Speter * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * 3150276Speter * and: Eric S. Raymond <esr@snark.thyrsus.com> * 32166124Srafan * and: Thomas E. Dickey 1996-on * 33166124Srafan * and: Sven Verdoolaege 2001 * 3450276Speter ****************************************************************************/ 3550276Speter 3650276Speter/* 3750276Speter** lib_box.c 3850276Speter** 3950276Speter** The routine wborder(). 4050276Speter** 4150276Speter*/ 4250276Speter 4350276Speter#include <curses.priv.h> 4450276Speter 45262629SdelphijMODULE_ID("$Id: lib_box.c,v 1.24 2010/04/24 23:51:57 tom Exp $") 4650276Speter 47166124Srafan#if USE_WIDEC_SUPPORT 48166124Srafanstatic NCURSES_INLINE chtype 49166124Srafan_my_render(WINDOW *win, chtype ch) 50166124Srafan{ 51166124Srafan NCURSES_CH_T wch; 52166124Srafan SetChar2(wch, ch); 53166124Srafan wch = _nc_render(win, wch); 54262629Sdelphij return ((attr_t) CharOf(wch)) | AttrOf(wch); 55166124Srafan} 56262629Sdelphij 57166124Srafan#define RENDER_WITH_DEFAULT(ch,def) w ## ch = _my_render(win, (ch == 0) ? def : ch) 58166124Srafan#else 59166124Srafan#define RENDER_WITH_DEFAULT(ch,def) w ## ch = _nc_render(win, (ch == 0) ? def : ch) 60166124Srafan#endif 61166124Srafan 6276726SpeterNCURSES_EXPORT(int) 6397049Speterwborder(WINDOW *win, 6497049Speter chtype ls, chtype rs, 6597049Speter chtype ts, chtype bs, 6697049Speter chtype tl, chtype tr, 6797049Speter chtype bl, chtype br) 6850276Speter{ 6962449Speter NCURSES_SIZE_T i; 7062449Speter NCURSES_SIZE_T endx, endy; 7197049Speter chtype wls, wrs, wts, wbs, wtl, wtr, wbl, wbr; 7250276Speter 7350276Speter T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"), 74262629Sdelphij (void *) win, 7576726Speter _tracechtype2(1, ls), 7676726Speter _tracechtype2(2, rs), 7776726Speter _tracechtype2(3, ts), 7876726Speter _tracechtype2(4, bs), 7976726Speter _tracechtype2(5, tl), 8076726Speter _tracechtype2(6, tr), 8176726Speter _tracechtype2(7, bl), 8276726Speter _tracechtype2(8, br))); 8350276Speter 8462449Speter if (!win) 8562449Speter returnCode(ERR); 8650276Speter 8797049Speter RENDER_WITH_DEFAULT(ls, ACS_VLINE); 8897049Speter RENDER_WITH_DEFAULT(rs, ACS_VLINE); 8997049Speter RENDER_WITH_DEFAULT(ts, ACS_HLINE); 9097049Speter RENDER_WITH_DEFAULT(bs, ACS_HLINE); 9197049Speter RENDER_WITH_DEFAULT(tl, ACS_ULCORNER); 9297049Speter RENDER_WITH_DEFAULT(tr, ACS_URCORNER); 9397049Speter RENDER_WITH_DEFAULT(bl, ACS_LLCORNER); 9497049Speter RENDER_WITH_DEFAULT(br, ACS_LRCORNER); 9550276Speter 9697049Speter T(("using %s, %s, %s, %s, %s, %s, %s, %s", 9797049Speter _tracechtype2(1, wls), 9897049Speter _tracechtype2(2, wrs), 9997049Speter _tracechtype2(3, wts), 10097049Speter _tracechtype2(4, wbs), 10197049Speter _tracechtype2(5, wtl), 10297049Speter _tracechtype2(6, wtr), 10397049Speter _tracechtype2(7, wbl), 10497049Speter _tracechtype2(8, wbr))); 10550276Speter 10662449Speter endx = win->_maxx; 10762449Speter endy = win->_maxy; 10850276Speter 10962449Speter for (i = 0; i <= endx; i++) { 110166124Srafan SetChar2(win->_line[0].text[i], wts); 111166124Srafan SetChar2(win->_line[endy].text[i], wbs); 11262449Speter } 11362449Speter win->_line[endy].firstchar = win->_line[0].firstchar = 0; 11462449Speter win->_line[endy].lastchar = win->_line[0].lastchar = endx; 11550276Speter 11662449Speter for (i = 0; i <= endy; i++) { 117166124Srafan SetChar2(win->_line[i].text[0], wls); 118166124Srafan SetChar2(win->_line[i].text[endx], wrs); 11962449Speter win->_line[i].firstchar = 0; 12062449Speter win->_line[i].lastchar = endx; 12162449Speter } 122166124Srafan SetChar2(win->_line[0].text[0], wtl); 123166124Srafan SetChar2(win->_line[0].text[endx], wtr); 124166124Srafan SetChar2(win->_line[endy].text[0], wbl); 125166124Srafan SetChar2(win->_line[endy].text[endx], wbr); 12650276Speter 12762449Speter _nc_synchook(win); 12862449Speter returnCode(OK); 12950276Speter} 130