Subject: Bug#3207: strange screen update choices from ncurses

From: Ian Jackson <[email-masked]>
Date: Tue, 4 Jun 96 15:00 BST

Package: ncurses3.0
Version: 1.9.9e-1

To reproduce: install dpkg 1.2.3elf and ncurses 1.9.9e-1.  Run dselect
(as non-root will do) with TERM=vt220 (using vt100 doesn't show the
problem) and go into the selection list.  Using `n' repeatedly move
the highlight onto the first actual package.  Then use ^N and ^P
alternately to scroll the display up and down.

You'll see that when ncurses needs to scroll the list area it does it
by redrawing it.  I don't know why it doesn't choose to change the
scrolling region instead, but this is liveable with.

The bug I'm reporting here is that when it needs to redraw some of the
package list lines (particularly All packages) it tries to reuse small
bits of parts of the lines that were there before, by using many
insert/delete character sequences.  This is *very* slow indeed.

lynx has the same problem.

This bug has existed in ncurses for a long time.

Below is a transcript of what I see when I do what I describe above,
and a script (I call it `slowprint') to output things slowly.  Try:
  slowprint <typescript 0.003

#!/usr/bin/perl
$|=1;
$overhead= 0.0125;
$delay= @ARGV ? $ARGV[0]+0 : 0.025;
$onclear= @ARGV>1 ? $ARGV[1]+0 : 0.0;
$per=1;
while ($delay < $overhead) { $per*=2; $delay*=2; }
$delay -= $overhead;
while (sysread(STDIN,$v,$per)) {
    if ($onclear) {
        $add.= $v;
        if (length($add)>$per+6) { $add= substr($add,length($add)-$per-6); }
        if (($z= index($add,'[H[J',0)) >= 0) {
            $remain= length($add)-$z-5;
            print substr($v,0,length($v)-$remain);
            select("","","",$onclear);
            $v= substr($v,length($v)-$remain);
            $add='';
        }
    }
    print $v;
    select("","","",$delay);
}