NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/55728: bug in curses_pad: shows incorrect part of the pad



>Number:         55728
>Category:       lib
>Synopsis:       bug in curses_pad: shows incorrect part of the pad
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 14 19:05:00 +0000 2020
>Originator:     Rhialto
>Release:        NetBSD 9.0
>Organization:
>Environment:
System: NetBSD murthe.falu.nl 9.0 NetBSD 9.0 (GENERIC) #0: Fri Feb 14 00:06:28 UTC 2020 mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
	The curses_pad(3) manual page describes a "pad", which is some
	text area larger than your window. A rectangular fragment from the pad
	may be copied to the screen:

     int
     prefresh(WINDOW *pad, int pbeg_y, int pbeg_x, int sbeg_y, int sbeg_x,
         int smax_y, int smax_x);

     The prefresh() function causes curses to propagate changes made to the
     pad specified by pad to the terminal display.  A rectangular area of the
     pad starting at column and row pbeg_y, pbeg_x is copied to the
     corresponding rectangular area of the terminal starting at column and row
     sbeg_y, sbeg_x and extending to smax_y, smax_x.

	The program below creates such a pad, 1000 lines long, and attempts
	to show line 100ff on the screen.

	What happens in reality is that line 100ff are briefly displayed
	(if you can see it that quickly) but are immediately overwritten
	with line 0ff.

	Each time the enter key is pressed, it tries to go ahead 10 lines.
	The flashing is sometimes visible.

	Expected behaviour: the program shows Line 100 and further.

>How-To-Repeat:
	Using this program (curs.c) which you can run as a shell script
	to compile it.
# /*
cc curs.c -lcurses -o curs
exit $?
*/

#include <curses.h>

int main(int argc, char **argv)
{
    initscr();
    keypad(stdscr, TRUE);
    clearok(stdscr, TRUE);
    noecho();

    int maxx = getmaxx(stdscr);
    int maxy = getmaxy(stdscr);

    mvwaddstr(stdscr, maxy-1, 0, "Loading...");
    wrefresh(stdscr);

    int rows = 1000;
    int width = maxx - 4;

    WINDOW *pad = newpad(rows, width + 2);
    int i;
    for (i = 0; i < rows; i++) {
	char tmp[80];
	sprintf(tmp, "Line %d", i);
	mvwaddstr(pad, i, 0, tmp);
    }

    int y = 100;
    int x = (maxx - width) / 2;

    while (y < rows) {
	/*
	 * According to curses_pad(3), this should show  Line 100, Line 101,
	 * etc.  It does even print that, briefly (if you can see it), but it
	 * is overwritten immediately with Line 0, Line 1, Line 2, etc.
	 */
	prefresh(pad, y,0,  0,x,  maxy-1,x+width);

	int k = wgetch(pad);

	y += 10;
    }

    endwin();
}
>Fix:
	None known.

-Olaf.
-- 
Olaf 'Rhialto' Seibert -- rhialto at falu dot nl
___  Anyone who is capable of getting themselves made President should on
\X/  no account be allowed to do the job.       --Douglas Adams, "THGTTG"



Home | Main Index | Thread Index | Old Index