Skip to content

Commit

Permalink
winsertln(), wdeleteln(), and winsdelln() all now use the PDC_wscrl()…
Browse files Browse the repository at this point in the history
… 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).
  • Loading branch information
Bill-Gray committed Mar 13, 2024
1 parent 5838be7 commit b02f94f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 66 deletions.
1 change: 1 addition & 0 deletions curspriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
69 changes: 3 additions & 66 deletions pdcurses/deleteln.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit b02f94f

Please sign in to comment.