1/* $OpenBSD: lib_redrawln.c,v 1.5 2023/10/17 09:52:08 nicm Exp $ */ 2 3/**************************************************************************** 4 * Copyright 2020 Thomas E. Dickey * 5 * Copyright 1998-2009,2010 Free Software Foundation, Inc. * 6 * * 7 * Permission is hereby granted, free of charge, to any person obtaining a * 8 * copy of this software and associated documentation files (the * 9 * "Software"), to deal in the Software without restriction, including * 10 * without limitation the rights to use, copy, modify, merge, publish, * 11 * distribute, distribute with modifications, sublicense, and/or sell * 12 * copies of the Software, and to permit persons to whom the Software is * 13 * furnished to do so, subject to the following conditions: * 14 * * 15 * The above copyright notice and this permission notice shall be included * 16 * in all copies or substantial portions of the Software. * 17 * * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 21 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 24 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 25 * * 26 * Except as contained in this notice, the name(s) of the above copyright * 27 * holders shall not be used in advertising or otherwise to promote the * 28 * sale, use or other dealings in this Software without prior written * 29 * authorization. * 30 ****************************************************************************/ 31 32/**************************************************************************** 33 * Author: Thomas E. Dickey <dickey@clark.net> 1997 * 34 ****************************************************************************/ 35 36/* 37 * lib_redrawln.c 38 * 39 * The routine wredrawln(). 40 * 41 */ 42 43#include <curses.priv.h> 44 45MODULE_ID("$Id: lib_redrawln.c,v 1.5 2023/10/17 09:52:08 nicm Exp $") 46 47NCURSES_EXPORT(int) 48wredrawln(WINDOW *win, int beg, int num) 49{ 50 int i; 51 int end; 52 size_t len; 53 SCREEN *sp; 54 55 T((T_CALLED("wredrawln(%p,%d,%d)"), (void *) win, beg, num)); 56 57 if (win == 0) 58 returnCode(ERR); 59 60 sp = _nc_screen_of(win); 61 62 if (beg < 0) 63 beg = 0; 64 65 if (touchline(win, beg, num) == ERR) 66 returnCode(ERR); 67 68 if (touchline(CurScreen(sp), beg + win->_begy, num) == ERR) 69 returnCode(ERR); 70 71 end = beg + num; 72 if (end > CurScreen(sp)->_maxy + 1 - win->_begy) 73 end = CurScreen(sp)->_maxy + 1 - win->_begy; 74 if (end > win->_maxy + 1) 75 end = win->_maxy + 1; 76 77 len = (size_t) (win->_maxx + 1); 78 if (len > (size_t) (CurScreen(sp)->_maxx + 1 - win->_begx)) 79 len = (size_t) (CurScreen(sp)->_maxx + 1 - win->_begx); 80 len *= sizeof(CurScreen(sp)->_line[0].text[0]); 81 82 for (i = beg; i < end; i++) { 83 int crow = i + win->_begy; 84 85 memset(CurScreen(sp)->_line[crow].text + win->_begx, 0, len); 86 NCURSES_SP_NAME(_nc_make_oldhash) (NCURSES_SP_ARGx crow); 87 } 88 89 returnCode(OK); 90} 91