GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libcurses/base/lib_box.c Lines: 0 32 0.0 %
Date: 2017-11-07 Branches: 0 22 0.0 %

Line Branch Exec Source
1
/* $OpenBSD: lib_box.c,v 1.4 2010/01/12 23:22:05 nicm Exp $ */
2
3
/****************************************************************************
4
 * Copyright (c) 1998-2002,2005 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
 *     and: Thomas E. Dickey                        1996-on                 *
35
 *     and: Sven Verdoolaege                        2001                    *
36
 ****************************************************************************/
37
38
/*
39
**	lib_box.c
40
**
41
**	The routine wborder().
42
**
43
*/
44
45
#include <curses.priv.h>
46
47
MODULE_ID("$Id: lib_box.c,v 1.4 2010/01/12 23:22:05 nicm Exp $")
48
49
#if USE_WIDEC_SUPPORT
50
static NCURSES_INLINE chtype
51
_my_render(WINDOW *win, chtype ch)
52
{
53
    NCURSES_CH_T wch;
54
    SetChar2(wch, ch);
55
    wch = _nc_render(win, wch);
56
    return CharOf(wch) | AttrOf(wch);
57
}
58
#define RENDER_WITH_DEFAULT(ch,def) w ## ch = _my_render(win, (ch == 0) ? def : ch)
59
#else
60
#define RENDER_WITH_DEFAULT(ch,def) w ## ch = _nc_render(win, (ch == 0) ? def : ch)
61
#endif
62
63
NCURSES_EXPORT(int)
64
wborder(WINDOW *win,
65
	chtype ls, chtype rs,
66
	chtype ts, chtype bs,
67
	chtype tl, chtype tr,
68
	chtype bl, chtype br)
69
{
70
    NCURSES_SIZE_T i;
71
    NCURSES_SIZE_T endx, endy;
72
    chtype wls, wrs, wts, wbs, wtl, wtr, wbl, wbr;
73
74
    T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"),
75
       win,
76
       _tracechtype2(1, ls),
77
       _tracechtype2(2, rs),
78
       _tracechtype2(3, ts),
79
       _tracechtype2(4, bs),
80
       _tracechtype2(5, tl),
81
       _tracechtype2(6, tr),
82
       _tracechtype2(7, bl),
83
       _tracechtype2(8, br)));
84
85
    if (!win)
86
	returnCode(ERR);
87
88
    RENDER_WITH_DEFAULT(ls, ACS_VLINE);
89
    RENDER_WITH_DEFAULT(rs, ACS_VLINE);
90
    RENDER_WITH_DEFAULT(ts, ACS_HLINE);
91
    RENDER_WITH_DEFAULT(bs, ACS_HLINE);
92
    RENDER_WITH_DEFAULT(tl, ACS_ULCORNER);
93
    RENDER_WITH_DEFAULT(tr, ACS_URCORNER);
94
    RENDER_WITH_DEFAULT(bl, ACS_LLCORNER);
95
    RENDER_WITH_DEFAULT(br, ACS_LRCORNER);
96
97
    T(("using %s, %s, %s, %s, %s, %s, %s, %s",
98
       _tracechtype2(1, wls),
99
       _tracechtype2(2, wrs),
100
       _tracechtype2(3, wts),
101
       _tracechtype2(4, wbs),
102
       _tracechtype2(5, wtl),
103
       _tracechtype2(6, wtr),
104
       _tracechtype2(7, wbl),
105
       _tracechtype2(8, wbr)));
106
107
    endx = win->_maxx;
108
    endy = win->_maxy;
109
110
    for (i = 0; i <= endx; i++) {
111
	SetChar2(win->_line[0].text[i], wts);
112
	SetChar2(win->_line[endy].text[i], wbs);
113
    }
114
    win->_line[endy].firstchar = win->_line[0].firstchar = 0;
115
    win->_line[endy].lastchar = win->_line[0].lastchar = endx;
116
117
    for (i = 0; i <= endy; i++) {
118
	SetChar2(win->_line[i].text[0], wls);
119
	SetChar2(win->_line[i].text[endx], wrs);
120
	win->_line[i].firstchar = 0;
121
	win->_line[i].lastchar = endx;
122
    }
123
    SetChar2(win->_line[0].text[0], wtl);
124
    SetChar2(win->_line[0].text[endx], wtr);
125
    SetChar2(win->_line[endy].text[0], wbl);
126
    SetChar2(win->_line[endy].text[endx], wbr);
127
128
    _nc_synchook(win);
129
    returnCode(OK);
130
}