Skip to content

Commit

Permalink
Made a separate PDC_wscrl() function to scroll a window by 'n' lines …
Browse files Browse the repository at this point in the history
…between rows 'top' and 'bottom'. This can be used by wscrl(), wdeleteln(), winsertln(), and winsdelln(), avoiding some redundant code. See preceding commit for the test program and following commit for the use of this function elsewhere.
  • Loading branch information
Bill-Gray committed Mar 13, 2024
1 parent 98c7405 commit 5838be7
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions pdcurses/scroll.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ scroll
**man-end****************************************************************/

int wscrl(WINDOW *win, int n)
int PDC_wscrl(WINDOW *win, const int top, const int bottom, int n)
{
int start, end, n_lines;
chtype blank, *tptr, *endptr;

/* Check if window scrolls. Valid for window AND pad */

assert( win);
if (!win || !win->_scroll || !n)
if (!win || !n)
return ERR;

blank = win->_bkgd;
start = win->_tmarg;
end = win->_bmarg + 1;
start = top;
end = bottom + 1;
n_lines = end - start;

if (n > 0) /* scroll up */
Expand All @@ -71,7 +71,7 @@ int wscrl(WINDOW *win, int n)
n = n_lines;
memmove( win->_y[start + n], win->_y[start],
(n_lines - n) * win->_maxx * sizeof( chtype));
tptr = win->_y[win->_tmarg];
tptr = win->_y[top];
}

/* make blank lines */
Expand All @@ -81,11 +81,23 @@ int wscrl(WINDOW *win, int n)
*tptr++ = blank;

touchline(win, start, n_lines);

PDC_sync(win);
return OK;
}

int wscrl(WINDOW *win, int n)
{
int rval;

assert( win);
if (!win || !win->_scroll || !n)
rval = ERR;
else
rval = PDC_wscrl( win, win->_tmarg, win->_bmarg, n);
if( OK == rval)
PDC_sync( win);
return( rval);
}

int scrl(int n)
{
PDC_LOG(("scrl() - called\n"));
Expand Down

0 comments on commit 5838be7

Please sign in to comment.