From b02f94fd3d7f8858eb5f62df8f168a75941d2dad Mon Sep 17 00:00:00 2001 From: Bill-Gray Date: Wed, 13 Mar 2024 13:37:27 -0400 Subject: [PATCH] winsertln(), wdeleteln(), and winsdelln() all now use the PDC_wscrl() code from the preceding commit. This also fixes a bug wherein wdeleteln() went to the bottom of the scroll region (win->_bmarg) instead of the bottom of the window (win->_maxy - 1). --- curspriv.h | 1 + pdcurses/deleteln.c | 69 ++------------------------------------------- 2 files changed, 4 insertions(+), 66 deletions(-) diff --git a/curspriv.h b/curspriv.h index ca2c1878..bf85d18e 100644 --- a/curspriv.h +++ b/curspriv.h @@ -112,6 +112,7 @@ void PDC_mark_line_as_changed( WINDOW *win, const int y); void PDC_mark_cells_as_changed( WINDOW *, const int y, const int start, const int end); void PDC_mark_cell_as_changed( WINDOW *, const int y, const int x); bool PDC_touched_range( const WINDOW *win, const int y, int *firstch, int *lastch); +int PDC_wscrl(WINDOW *win, const int top, const int bottom, int n); #ifdef PDC_WIDE int PDC_mbtowc(wchar_t *, const char *, size_t); diff --git a/pdcurses/deleteln.c b/pdcurses/deleteln.c index 3c373755..9dbe4b87 100644 --- a/pdcurses/deleteln.c +++ b/pdcurses/deleteln.c @@ -56,37 +56,13 @@ deleteln int wdeleteln(WINDOW *win) { - chtype blank, *temp, *ptr; - int y; - PDC_LOG(("wdeleteln() - called\n")); assert( win); if (!win) return ERR; - /* wrs (4/10/93) account for window background */ - - blank = win->_bkgd; - - temp = win->_y[win->_cury]; - - for (y = win->_cury; y < win->_bmarg; y++) - { - win->_y[y] = win->_y[y + 1]; - PDC_mark_line_as_changed( win, y); - } - - for (ptr = temp; (ptr - temp < win->_maxx); ptr++) - *ptr = blank; /* make a blank line */ - - if (win->_cury <= win->_bmarg) - { - PDC_mark_line_as_changed( win, win->_bmarg); - win->_y[win->_bmarg] = temp; - } - - return OK; + return( PDC_wscrl( win, win->_cury, win->_maxy - 1, 1)); } int deleteln(void) @@ -118,29 +94,12 @@ int mvwdeleteln(WINDOW *win, int y, int x) int winsdelln(WINDOW *win, int n) { - int i; - PDC_LOG(("winsdelln() - called\n")); assert( win); if (!win) return ERR; - - if (n > 0) - { - for (i = 0; i < n; i++) - if (winsertln(win) == ERR) - return ERR; - } - else if (n < 0) - { - n = -n; - for (i = 0; i < n; i++) - if (wdeleteln(win) == ERR) - return ERR; - } - - return OK; + return( PDC_wscrl( win, win->_cury, win->_maxy - 1, -n)); } int insdelln(int n) @@ -152,35 +111,13 @@ int insdelln(int n) int winsertln(WINDOW *win) { - chtype blank, *temp, *end; - int y; - PDC_LOG(("winsertln() - called\n")); assert( win); if (!win) return ERR; - /* wrs (4/10/93) account for window background */ - - blank = win->_bkgd; - - temp = win->_y[win->_maxy - 1]; - - for (y = win->_maxy - 1; y > win->_cury; y--) - { - win->_y[y] = win->_y[y - 1]; - PDC_mark_line_as_changed( win, y); - } - - win->_y[win->_cury] = temp; - - for (end = &temp[win->_maxx - 1]; temp <= end; temp++) - *temp = blank; - - PDC_mark_line_as_changed( win, win->_cury); - - return OK; + return( PDC_wscrl( win, win->_cury, win->_maxy - 1, -1)); } int insertln(void)