Back to index

tetex-bin  3.0
lib_box.c
Go to the documentation of this file.
00001 /****************************************************************************
00002  * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
00003  *                                                                          *
00004  * Permission is hereby granted, free of charge, to any person obtaining a  *
00005  * copy of this software and associated documentation files (the            *
00006  * "Software"), to deal in the Software without restriction, including      *
00007  * without limitation the rights to use, copy, modify, merge, publish,      *
00008  * distribute, distribute with modifications, sublicense, and/or sell       *
00009  * copies of the Software, and to permit persons to whom the Software is    *
00010  * furnished to do so, subject to the following conditions:                 *
00011  *                                                                          *
00012  * The above copyright notice and this permission notice shall be included  *
00013  * in all copies or substantial portions of the Software.                   *
00014  *                                                                          *
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
00016  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
00017  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
00018  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
00019  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
00020  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
00021  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
00022  *                                                                          *
00023  * Except as contained in this notice, the name(s) of the above copyright   *
00024  * holders shall not be used in advertising or otherwise to promote the     *
00025  * sale, use or other dealings in this Software without prior written       *
00026  * authorization.                                                           *
00027  ****************************************************************************/
00028 
00029 /****************************************************************************
00030  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
00031  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
00032  ****************************************************************************/
00033 
00034 /*
00035 **     lib_box.c
00036 **
00037 **     The routine wborder().
00038 **
00039 */
00040 
00041 #include <curses.priv.h>
00042 
00043 MODULE_ID("$Id: lib_box.c,v 1.21 2002/09/15 01:04:27 tom Exp $")
00044 
00045 #if USE_WIDEC_SUPPORT
00046 static inline chtype
00047 _my_render(WINDOW *win, chtype ch)
00048 {
00049     NCURSES_CH_T wch;
00050     SetChar2(wch, ch);
00051     wch = _nc_render(win, wch);
00052     return CharOf(wch) | AttrOf(wch);
00053 }
00054 #define RENDER_WITH_DEFAULT(ch,def) w ## ch = _my_render(win, (ch == 0) ? def : ch)
00055 #else
00056 #define RENDER_WITH_DEFAULT(ch,def) w ## ch = _nc_render(win, (ch == 0) ? def : ch)
00057 #endif
00058 
00059 NCURSES_EXPORT(int)
00060 wborder(WINDOW *win,
00061        chtype ls, chtype rs,
00062        chtype ts, chtype bs,
00063        chtype tl, chtype tr,
00064        chtype bl, chtype br)
00065 {
00066     NCURSES_SIZE_T i;
00067     NCURSES_SIZE_T endx, endy;
00068     chtype wls, wrs, wts, wbs, wtl, wtr, wbl, wbr;
00069 
00070     T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"),
00071        win,
00072        _tracechtype2(1, ls),
00073        _tracechtype2(2, rs),
00074        _tracechtype2(3, ts),
00075        _tracechtype2(4, bs),
00076        _tracechtype2(5, tl),
00077        _tracechtype2(6, tr),
00078        _tracechtype2(7, bl),
00079        _tracechtype2(8, br)));
00080 
00081     if (!win)
00082        returnCode(ERR);
00083 
00084     RENDER_WITH_DEFAULT(ls, ACS_VLINE);
00085     RENDER_WITH_DEFAULT(rs, ACS_VLINE);
00086     RENDER_WITH_DEFAULT(ts, ACS_HLINE);
00087     RENDER_WITH_DEFAULT(bs, ACS_HLINE);
00088     RENDER_WITH_DEFAULT(tl, ACS_ULCORNER);
00089     RENDER_WITH_DEFAULT(tr, ACS_URCORNER);
00090     RENDER_WITH_DEFAULT(bl, ACS_LLCORNER);
00091     RENDER_WITH_DEFAULT(br, ACS_LRCORNER);
00092 
00093     T(("using %s, %s, %s, %s, %s, %s, %s, %s",
00094        _tracechtype2(1, wls),
00095        _tracechtype2(2, wrs),
00096        _tracechtype2(3, wts),
00097        _tracechtype2(4, wbs),
00098        _tracechtype2(5, wtl),
00099        _tracechtype2(6, wtr),
00100        _tracechtype2(7, wbl),
00101        _tracechtype2(8, wbr)));
00102 
00103     endx = win->_maxx;
00104     endy = win->_maxy;
00105 
00106     for (i = 0; i <= endx; i++) {
00107        SetChar2(win->_line[0].text[i], wts);
00108        SetChar2(win->_line[endy].text[i], wbs);
00109     }
00110     win->_line[endy].firstchar = win->_line[0].firstchar = 0;
00111     win->_line[endy].lastchar = win->_line[0].lastchar = endx;
00112 
00113     for (i = 0; i <= endy; i++) {
00114        SetChar2(win->_line[i].text[0], wls);
00115        SetChar2(win->_line[i].text[endx], wrs);
00116        win->_line[i].firstchar = 0;
00117        win->_line[i].lastchar = endx;
00118     }
00119     SetChar2(win->_line[0].text[0], wtl);
00120     SetChar2(win->_line[0].text[endx], wtr);
00121     SetChar2(win->_line[endy].text[0], wbl);
00122     SetChar2(win->_line[endy].text[endx], wbr);
00123 
00124     _nc_synchook(win);
00125     returnCode(OK);
00126 }