1*c7ef0cfcSnicm /* $OpenBSD: lib_hline_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-2010,2016 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 * Author: Thomas Dickey 2002 *
346bc6570dSnicm ****************************************************************************/
356bc6570dSnicm
366bc6570dSnicm /*
376bc6570dSnicm ** lib_hline_set.c
386bc6570dSnicm **
396bc6570dSnicm ** The routine whline_set().
406bc6570dSnicm **
416bc6570dSnicm */
426bc6570dSnicm
436bc6570dSnicm #include <curses.priv.h>
446bc6570dSnicm
45*c7ef0cfcSnicm MODULE_ID("$Id: lib_hline_set.c,v 1.2 2023/10/17 09:52:09 nicm Exp $")
466bc6570dSnicm
NCURSES_EXPORT(int)476bc6570dSnicm NCURSES_EXPORT(int)
486bc6570dSnicm whline_set(WINDOW *win, const cchar_t *ch, int n)
496bc6570dSnicm {
506bc6570dSnicm int code = ERR;
516bc6570dSnicm
52*c7ef0cfcSnicm T((T_CALLED("whline_set(%p,%s,%d)"), (void *) win, _tracecchar_t(ch), n));
536bc6570dSnicm
546bc6570dSnicm if (win) {
556bc6570dSnicm struct ldat *line = &(win->_line[win->_cury]);
566bc6570dSnicm NCURSES_CH_T wch;
57*c7ef0cfcSnicm int start = win->_curx;
58*c7ef0cfcSnicm int end = start + n - 1;
596bc6570dSnicm
606bc6570dSnicm if (end > win->_maxx)
616bc6570dSnicm end = win->_maxx;
626bc6570dSnicm
636bc6570dSnicm CHANGED_RANGE(line, start, end);
646bc6570dSnicm
656bc6570dSnicm if (ch == 0)
666bc6570dSnicm wch = *WACS_HLINE;
676bc6570dSnicm else
686bc6570dSnicm wch = *ch;
696bc6570dSnicm wch = _nc_render(win, wch);
706bc6570dSnicm
716bc6570dSnicm while (end >= start) {
726bc6570dSnicm line->text[end] = wch;
736bc6570dSnicm end--;
746bc6570dSnicm }
756bc6570dSnicm
766bc6570dSnicm _nc_synchook(win);
776bc6570dSnicm code = OK;
786bc6570dSnicm }
796bc6570dSnicm returnCode(code);
806bc6570dSnicm }
81