Subject: curses: gratuitous scroll down on repaint
To: None <tech-userlevel@netbsd.org>
From: Jun-ichiro itojun Hagino <itojun@itojun.org>
List: tech-userlevel
Date: 08/01/2000 14:07:00
	about curses.

	under certain application that involves wrefresh() with child window +
	many wmove() and wgetyx(), window repaint causes gratuitous scroll
	down and screen crashes.

	this happens if cursor is the very last line of the screen, and we
	are trying to paint something to line upwards.
>  		domvcur(ly, lx, ly + 1, 0);
	in this situation,
	- ly == LINES - 1,
	- wy < LINES - 1 (we are trying to move cursor upwards)
	but we cause an unnecessary scroll down by "ly + 1", and screen crashes.

	does this look correct?  i'm using vi and other application and having
	no problem.

	"certain application" is mchat(1) comes with KAME kit.  it works
	just fine with freebsd curses.

itojun


Index: refresh.c
===================================================================
RCS file: /cvsroot/basesrc/lib/libcurses/refresh.c,v
retrieving revision 1.39
diff -c -r1.39 refresh.c
*** refresh.c	2000/08/01 04:17:09	1.39
--- refresh.c	2000/08/01 04:59:44
***************
*** 385,392 ****
--- 385,397 ----
  		win = __virtscr;
  	/* Is the cursor still on the end of the last line? */
  	if (wy > 0 && win->lines[wy - 1]->flags & __ISPASTEOL) {
+ #if 0
+ 		/* gratiutous scroll down if ly == LINES - 1 */
  		domvcur(ly, lx, ly + 1, 0);
  		ly++;
+ #else
+ 		domvcur(ly, lx, ly, 0);
+ #endif
  		lx = 0;
  	}
  	wx = *win->lines[wy]->firstchp;