1*c7ef0cfcSnicm /* $OpenBSD: lib_redrawln.c,v 1.5 2023/10/17 09:52:08 nicm Exp $ */
292dd1ec0Smillert
392dd1ec0Smillert /****************************************************************************
4*c7ef0cfcSnicm * Copyright 2020 Thomas E. Dickey *
5*c7ef0cfcSnicm * Copyright 1998-2009,2010 Free Software Foundation, Inc. *
692dd1ec0Smillert * *
792dd1ec0Smillert * Permission is hereby granted, free of charge, to any person obtaining a *
892dd1ec0Smillert * copy of this software and associated documentation files (the *
992dd1ec0Smillert * "Software"), to deal in the Software without restriction, including *
1092dd1ec0Smillert * without limitation the rights to use, copy, modify, merge, publish, *
1192dd1ec0Smillert * distribute, distribute with modifications, sublicense, and/or sell *
1292dd1ec0Smillert * copies of the Software, and to permit persons to whom the Software is *
1392dd1ec0Smillert * furnished to do so, subject to the following conditions: *
1492dd1ec0Smillert * *
1592dd1ec0Smillert * The above copyright notice and this permission notice shall be included *
1692dd1ec0Smillert * in all copies or substantial portions of the Software. *
1792dd1ec0Smillert * *
1892dd1ec0Smillert * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
1992dd1ec0Smillert * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
2092dd1ec0Smillert * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
2192dd1ec0Smillert * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
2292dd1ec0Smillert * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
2392dd1ec0Smillert * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
2492dd1ec0Smillert * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
2592dd1ec0Smillert * *
2692dd1ec0Smillert * Except as contained in this notice, the name(s) of the above copyright *
2792dd1ec0Smillert * holders shall not be used in advertising or otherwise to promote the *
2892dd1ec0Smillert * sale, use or other dealings in this Software without prior written *
2992dd1ec0Smillert * authorization. *
3092dd1ec0Smillert ****************************************************************************/
3192dd1ec0Smillert
3292dd1ec0Smillert /****************************************************************************
3392dd1ec0Smillert * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
3492dd1ec0Smillert ****************************************************************************/
3592dd1ec0Smillert
3692dd1ec0Smillert /*
3792dd1ec0Smillert * lib_redrawln.c
3892dd1ec0Smillert *
3992dd1ec0Smillert * The routine wredrawln().
4092dd1ec0Smillert *
4192dd1ec0Smillert */
4292dd1ec0Smillert
4392dd1ec0Smillert #include <curses.priv.h>
4492dd1ec0Smillert
45*c7ef0cfcSnicm MODULE_ID("$Id: lib_redrawln.c,v 1.5 2023/10/17 09:52:08 nicm Exp $")
4692dd1ec0Smillert
NCURSES_EXPORT(int)4784af20ceSmillert NCURSES_EXPORT(int)
4884af20ceSmillert wredrawln(WINDOW *win, int beg, int num)
4992dd1ec0Smillert {
5092dd1ec0Smillert int i;
5192dd1ec0Smillert int end;
5281d8c4e1Snicm size_t len;
53*c7ef0cfcSnicm SCREEN *sp;
5492dd1ec0Smillert
55*c7ef0cfcSnicm T((T_CALLED("wredrawln(%p,%d,%d)"), (void *) win, beg, num));
5692dd1ec0Smillert
5781d8c4e1Snicm if (win == 0)
5881d8c4e1Snicm returnCode(ERR);
5981d8c4e1Snicm
60*c7ef0cfcSnicm sp = _nc_screen_of(win);
61*c7ef0cfcSnicm
6292dd1ec0Smillert if (beg < 0)
6392dd1ec0Smillert beg = 0;
6492dd1ec0Smillert
6592dd1ec0Smillert if (touchline(win, beg, num) == ERR)
6692dd1ec0Smillert returnCode(ERR);
6792dd1ec0Smillert
68*c7ef0cfcSnicm if (touchline(CurScreen(sp), beg + win->_begy, num) == ERR)
6981d8c4e1Snicm returnCode(ERR);
7081d8c4e1Snicm
7192dd1ec0Smillert end = beg + num;
72*c7ef0cfcSnicm if (end > CurScreen(sp)->_maxy + 1 - win->_begy)
73*c7ef0cfcSnicm end = CurScreen(sp)->_maxy + 1 - win->_begy;
7492dd1ec0Smillert if (end > win->_maxy + 1)
7592dd1ec0Smillert end = win->_maxy + 1;
7692dd1ec0Smillert
77*c7ef0cfcSnicm len = (size_t) (win->_maxx + 1);
78*c7ef0cfcSnicm if (len > (size_t) (CurScreen(sp)->_maxx + 1 - win->_begx))
79*c7ef0cfcSnicm len = (size_t) (CurScreen(sp)->_maxx + 1 - win->_begx);
80*c7ef0cfcSnicm len *= sizeof(CurScreen(sp)->_line[0].text[0]);
8181d8c4e1Snicm
8284af20ceSmillert for (i = beg; i < end; i++) {
8381d8c4e1Snicm int crow = i + win->_begy;
8481d8c4e1Snicm
85*c7ef0cfcSnicm memset(CurScreen(sp)->_line[crow].text + win->_begx, 0, len);
86*c7ef0cfcSnicm NCURSES_SP_NAME(_nc_make_oldhash) (NCURSES_SP_ARGx crow);
8792dd1ec0Smillert }
8892dd1ec0Smillert
8992dd1ec0Smillert returnCode(OK);
9092dd1ec0Smillert }
91