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