150276Speter/**************************************************************************** 2166124Srafan * Copyright (c) 1998-2002,2005 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 45166124SrafanMODULE_ID("$Id: lib_box.c,v 1.22 2005/11/26 15:39:42 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); 54166124Srafan return CharOf(wch) | AttrOf(wch); 55166124Srafan} 56166124Srafan#define RENDER_WITH_DEFAULT(ch,def) w ## ch = _my_render(win, (ch == 0) ? def : ch) 57166124Srafan#else 58166124Srafan#define RENDER_WITH_DEFAULT(ch,def) w ## ch = _nc_render(win, (ch == 0) ? def : ch) 59166124Srafan#endif 60166124Srafan 6176726SpeterNCURSES_EXPORT(int) 6297049Speterwborder(WINDOW *win, 6397049Speter chtype ls, chtype rs, 6497049Speter chtype ts, chtype bs, 6597049Speter chtype tl, chtype tr, 6697049Speter chtype bl, chtype br) 6750276Speter{ 6862449Speter NCURSES_SIZE_T i; 6962449Speter NCURSES_SIZE_T endx, endy; 7097049Speter chtype wls, wrs, wts, wbs, wtl, wtr, wbl, wbr; 7150276Speter 7250276Speter T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"), 7376726Speter win, 7476726Speter _tracechtype2(1, ls), 7576726Speter _tracechtype2(2, rs), 7676726Speter _tracechtype2(3, ts), 7776726Speter _tracechtype2(4, bs), 7876726Speter _tracechtype2(5, tl), 7976726Speter _tracechtype2(6, tr), 8076726Speter _tracechtype2(7, bl), 8176726Speter _tracechtype2(8, br))); 8250276Speter 8362449Speter if (!win) 8462449Speter returnCode(ERR); 8550276Speter 8697049Speter RENDER_WITH_DEFAULT(ls, ACS_VLINE); 8797049Speter RENDER_WITH_DEFAULT(rs, ACS_VLINE); 8897049Speter RENDER_WITH_DEFAULT(ts, ACS_HLINE); 8997049Speter RENDER_WITH_DEFAULT(bs, ACS_HLINE); 9097049Speter RENDER_WITH_DEFAULT(tl, ACS_ULCORNER); 9197049Speter RENDER_WITH_DEFAULT(tr, ACS_URCORNER); 9297049Speter RENDER_WITH_DEFAULT(bl, ACS_LLCORNER); 9397049Speter RENDER_WITH_DEFAULT(br, ACS_LRCORNER); 9450276Speter 9597049Speter T(("using %s, %s, %s, %s, %s, %s, %s, %s", 9697049Speter _tracechtype2(1, wls), 9797049Speter _tracechtype2(2, wrs), 9897049Speter _tracechtype2(3, wts), 9997049Speter _tracechtype2(4, wbs), 10097049Speter _tracechtype2(5, wtl), 10197049Speter _tracechtype2(6, wtr), 10297049Speter _tracechtype2(7, wbl), 10397049Speter _tracechtype2(8, wbr))); 10450276Speter 10562449Speter endx = win->_maxx; 10662449Speter endy = win->_maxy; 10750276Speter 10862449Speter for (i = 0; i <= endx; i++) { 109166124Srafan SetChar2(win->_line[0].text[i], wts); 110166124Srafan SetChar2(win->_line[endy].text[i], wbs); 11162449Speter } 11262449Speter win->_line[endy].firstchar = win->_line[0].firstchar = 0; 11362449Speter win->_line[endy].lastchar = win->_line[0].lastchar = endx; 11450276Speter 11562449Speter for (i = 0; i <= endy; i++) { 116166124Srafan SetChar2(win->_line[i].text[0], wls); 117166124Srafan SetChar2(win->_line[i].text[endx], wrs); 11862449Speter win->_line[i].firstchar = 0; 11962449Speter win->_line[i].lastchar = endx; 12062449Speter } 121166124Srafan SetChar2(win->_line[0].text[0], wtl); 122166124Srafan SetChar2(win->_line[0].text[endx], wtr); 123166124Srafan SetChar2(win->_line[endy].text[0], wbl); 124166124Srafan SetChar2(win->_line[endy].text[endx], wbr); 12550276Speter 12662449Speter _nc_synchook(win); 12762449Speter returnCode(OK); 12850276Speter} 129