[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Corrections for 20021019
From: |
Philippe Blain |
Subject: |
Corrections for 20021019 |
Date: |
Mon, 21 Oct 2002 06:47:29 +0200 |
>From Philippe Blain, Bordeaux, FRANCE.
My old computer: P133 - 8,4 Go - 32 Mo Red Hat Linux 7.0
To maintainers of 'ncurses'.(and to Mr Dickey)
Subject: Corrections for ncurses-5.3-20021019+
Here are some problems I found :
----------------------------------------------------------------------------
File : ncurses/base/lib_screen.c
Function : scr_dump(const char *file)
If file does not exist, _nc_access fails and return -1, preventing from
dumping to a new file.
..................
if (_nc_access(file, W_OK) < 0 || (fp = fopen(file, "wb")) == 0) {
returnCode(ERR);
..................
----------------------------------------------------------------------------
File : ncurses/tty/lib_mvcur.c
Macro definition :
#define NOT_LOCAL(fy, fx, ty, tx) ((tx > LONG_DIST) &&\
(tx < screen_lines - 1 - LONG_DIST) && (abs(ty-fy) + abs(tx-fx) >
LONG_DIST)
should be 'screen_columns' instead of 'screen_lines', I think (x-axis).
----------------------------------------------------------------------------
File : ncurses/base/lib_scroll.c
Function : _nc_scroll_window()
Function is not good since introduction of 'limit'.
NEWS - 20011020
+ rewrote limit-checks in wscrl() and associated _nc_scroll_window(),
to ensure that if the parameter of wscrl() is larger than the size of
the scrolling region, then the scrolling region will be cleared
(report by Ben Kohlen <address@hidden>).
EXAMPLES :
I suppose a 24 * 80 window (full screen)
Take for scrolling region : top = 10, bottom = 20
1) n = -12 (n larger than scrolling region)
This gives limit = 10 - (-12) = 22
and then function blanks lines 10 to 22 (==> OUT OF REGION)
2) n = +12
This gives limit = 20 - 12 = 8
and then function blanks lines 8 to 20 (==> OUT OF REGION)
3) n = -6 (normal case)
Gives limit = 10 - (-6) = 16
Algorithm :
for (line = 20; line >= 16; line--)
if (line - 6 >= 0) /* always true because of the loop interval */
copy (line - 6) in line;
else
blank line; /* never executed */
for (line = 10; line <= 16; line++)
blank line;
4) n = +6
Gives limit = 20 - 6 = 14
Algorithm :
for (line = 10; line <= 14; line++)
if (line + 6 < 23) /* always true because of the loop interval */
copy (line + 6) in line;
else
blank line; /* never executed */
for (line = 20; line > 14; line--)
blank line;
#####> Propose to simplify code in 2 cases:
abs(n) < scrolling region abs(n) >= scrolling region
NCURSES_EXPORT (void)
_nc_scroll_window (WINDOW * win, int const n, NCURSES_SIZE_T const top,
NCURSES_SIZE_T const bottom, NCURSES_CH_T blank)
{
int line;
int j;
size_t to_copy = (size_t) (sizeof (NCURSES_CH_T) * (win->_maxx + 1));
TR (TRACE_MOVE,
("_nc_scroll_window(%p, %d, %d, %d)", win, n, top, bottom));
==> if (n == 0 || top < 0 || bottom < top || bottom > win->_maxy) {
TR (TRACE_MOVE, ("nothing to scroll"));
return;
}
==> if (abs (n) < bottom - top + 1) {
/* shift n lines downwards */
if (n < 0) {
for (line = bottom; line >= top - n; line--) {
TR (TRACE_MOVE, ("...copying %d to %d", line + n, line));
memcpy (win->_line[line].text,
win->_line[line + n].text, to_copy);
if_USE_SCROLL_HINTS (win->_line[line].oldindex =
win->_line[line + n].oldindex);
}
for (line = top; line < top - n; line++) {
TR (TRACE_MOVE, ("...filling %d", line));
for (j = 0; j <= win->_maxx; j++)
win->_line[line].text[j] = blank;
if_USE_SCROLL_HINTS (win->_line[line].oldindex = _NEWINDEX);
}
}
/* shift n lines upwards */
if (n > 0) {
for (line = top; line <= bottom - n; line++) {
TR (TRACE_MOVE, ("...copying %d to %d", line + n, line));
memcpy (win->_line[line].text,
win->_line[line + n].text, to_copy);
if_USE_SCROLL_HINTS (win->_line[line].oldindex =
win->_line[line + n].oldindex);
}
for (line = bottom; line > bottom - n; line--) {
TR (TRACE_MOVE, ("...filling %d", line));
for (j = 0; j <= win->_maxx; j++)
win->_line[line].text[j] = blank;
if_USE_SCROLL_HINTS (win->_line[line].oldindex = _NEWINDEX);
}
}
}
==> /* Blanking the whole window */
else {
for (line = top; line <= bottom; line++) {
TR (TRACE_MOVE, ("...filling %d", line));
for (j = 0; j <= win->_maxx; j++)
win->_line[line].text[j] = blank;
if_USE_SCROLL_HINTS (win->_line[line].oldindex = _NEWINDEX);
}
}
touchline (win, top, bottom - top + 1);
}
#####> As I write this, I think to another (bad) idea :
And what about scrolling a pad, huh ???
----------------------------------------------------------------------------
- Philippe - ncurses-6.0 will be the good one ! :-))
- Corrections for 20021019,
Philippe Blain <=