1*c7ef0cfcSnicm /* $OpenBSD: lib_box_set.c,v 1.2 2023/10/17 09:52:09 nicm Exp $ */
26bc6570dSnicm
36bc6570dSnicm /****************************************************************************
4*c7ef0cfcSnicm * Copyright 2020 Thomas E. Dickey *
5*c7ef0cfcSnicm * Copyright 2002-2009,2011 Free Software Foundation, Inc. *
66bc6570dSnicm * *
76bc6570dSnicm * Permission is hereby granted, free of charge, to any person obtaining a *
86bc6570dSnicm * copy of this software and associated documentation files (the *
96bc6570dSnicm * "Software"), to deal in the Software without restriction, including *
106bc6570dSnicm * without limitation the rights to use, copy, modify, merge, publish, *
116bc6570dSnicm * distribute, distribute with modifications, sublicense, and/or sell *
126bc6570dSnicm * copies of the Software, and to permit persons to whom the Software is *
136bc6570dSnicm * furnished to do so, subject to the following conditions: *
146bc6570dSnicm * *
156bc6570dSnicm * The above copyright notice and this permission notice shall be included *
166bc6570dSnicm * in all copies or substantial portions of the Software. *
176bc6570dSnicm * *
186bc6570dSnicm * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
196bc6570dSnicm * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
206bc6570dSnicm * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
216bc6570dSnicm * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
226bc6570dSnicm * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
236bc6570dSnicm * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
246bc6570dSnicm * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
256bc6570dSnicm * *
266bc6570dSnicm * Except as contained in this notice, the name(s) of the above copyright *
276bc6570dSnicm * holders shall not be used in advertising or otherwise to promote the *
286bc6570dSnicm * sale, use or other dealings in this Software without prior written *
296bc6570dSnicm * authorization. *
306bc6570dSnicm ****************************************************************************/
316bc6570dSnicm
326bc6570dSnicm /****************************************************************************
336bc6570dSnicm * Authors: Sven Verdoolaege and Thomas Dickey 2001,2002 *
346bc6570dSnicm ****************************************************************************/
356bc6570dSnicm
366bc6570dSnicm /*
376bc6570dSnicm ** lib_box_set.c
386bc6570dSnicm **
396bc6570dSnicm ** The routine wborder_set().
406bc6570dSnicm **
416bc6570dSnicm */
426bc6570dSnicm
436bc6570dSnicm #include <curses.priv.h>
446bc6570dSnicm
45*c7ef0cfcSnicm MODULE_ID("$Id: lib_box_set.c,v 1.2 2023/10/17 09:52:09 nicm Exp $")
466bc6570dSnicm
NCURSES_EXPORT(int)476bc6570dSnicm NCURSES_EXPORT(int)
486bc6570dSnicm wborder_set(WINDOW *win,
496bc6570dSnicm const ARG_CH_T ls, const ARG_CH_T rs,
506bc6570dSnicm const ARG_CH_T ts, const ARG_CH_T bs,
516bc6570dSnicm const ARG_CH_T tl, const ARG_CH_T tr,
526bc6570dSnicm const ARG_CH_T bl, const ARG_CH_T br)
536bc6570dSnicm {
546bc6570dSnicm NCURSES_SIZE_T i;
556bc6570dSnicm NCURSES_SIZE_T endx, endy;
566bc6570dSnicm NCURSES_CH_T wls, wrs, wts, wbs, wtl, wtr, wbl, wbr;
576bc6570dSnicm
58*c7ef0cfcSnicm T((T_CALLED("wborder_set(%p,%s,%s,%s,%s,%s,%s,%s,%s)"),
59*c7ef0cfcSnicm (void *) win,
606bc6570dSnicm _tracech_t2(1, ls),
616bc6570dSnicm _tracech_t2(2, rs),
626bc6570dSnicm _tracech_t2(3, ts),
636bc6570dSnicm _tracech_t2(4, bs),
646bc6570dSnicm _tracech_t2(5, tl),
656bc6570dSnicm _tracech_t2(6, tr),
666bc6570dSnicm _tracech_t2(7, bl),
676bc6570dSnicm _tracech_t2(8, br)));
686bc6570dSnicm
696bc6570dSnicm if (!win)
706bc6570dSnicm returnCode(ERR);
716bc6570dSnicm
726bc6570dSnicm #define RENDER_WITH_DEFAULT(ch,def) w ##ch = _nc_render(win, (ch == 0) ? *(const ARG_CH_T)def : *ch)
736bc6570dSnicm
746bc6570dSnicm RENDER_WITH_DEFAULT(ls, WACS_VLINE);
756bc6570dSnicm RENDER_WITH_DEFAULT(rs, WACS_VLINE);
766bc6570dSnicm RENDER_WITH_DEFAULT(ts, WACS_HLINE);
776bc6570dSnicm RENDER_WITH_DEFAULT(bs, WACS_HLINE);
786bc6570dSnicm RENDER_WITH_DEFAULT(tl, WACS_ULCORNER);
796bc6570dSnicm RENDER_WITH_DEFAULT(tr, WACS_URCORNER);
806bc6570dSnicm RENDER_WITH_DEFAULT(bl, WACS_LLCORNER);
816bc6570dSnicm RENDER_WITH_DEFAULT(br, WACS_LRCORNER);
826bc6570dSnicm
836bc6570dSnicm T(("using %s, %s, %s, %s, %s, %s, %s, %s",
846bc6570dSnicm _tracech_t2(1, CHREF(wls)),
856bc6570dSnicm _tracech_t2(2, CHREF(wrs)),
866bc6570dSnicm _tracech_t2(3, CHREF(wts)),
876bc6570dSnicm _tracech_t2(4, CHREF(wbs)),
886bc6570dSnicm _tracech_t2(5, CHREF(wtl)),
896bc6570dSnicm _tracech_t2(6, CHREF(wtr)),
906bc6570dSnicm _tracech_t2(7, CHREF(wbl)),
916bc6570dSnicm _tracech_t2(8, CHREF(wbr))));
926bc6570dSnicm
936bc6570dSnicm endx = win->_maxx;
946bc6570dSnicm endy = win->_maxy;
956bc6570dSnicm
966bc6570dSnicm for (i = 0; i <= endx; i++) {
976bc6570dSnicm win->_line[0].text[i] = wts;
986bc6570dSnicm win->_line[endy].text[i] = wbs;
996bc6570dSnicm }
1006bc6570dSnicm win->_line[endy].firstchar = win->_line[0].firstchar = 0;
1016bc6570dSnicm win->_line[endy].lastchar = win->_line[0].lastchar = endx;
1026bc6570dSnicm
1036bc6570dSnicm for (i = 0; i <= endy; i++) {
1046bc6570dSnicm win->_line[i].text[0] = wls;
1056bc6570dSnicm win->_line[i].text[endx] = wrs;
1066bc6570dSnicm win->_line[i].firstchar = 0;
1076bc6570dSnicm win->_line[i].lastchar = endx;
1086bc6570dSnicm }
1096bc6570dSnicm win->_line[0].text[0] = wtl;
1106bc6570dSnicm win->_line[0].text[endx] = wtr;
1116bc6570dSnicm win->_line[endy].text[0] = wbl;
1126bc6570dSnicm win->_line[endy].text[endx] = wbr;
1136bc6570dSnicm
1146bc6570dSnicm _nc_synchook(win);
1156bc6570dSnicm returnCode(OK);
1166bc6570dSnicm }
117