+ if ($y >= @sh) {
+ $inscroll = 0;
+ $spos = @sh;
+ }
+ } elsif ($spos < @sh || $spos < $pagel) {
+ # if we really are scrolling thru at the end of the history
+ while ($spos < @sh) {
+ my $line = $sh[$spos];
+ my $y = $spos;
+ if ($y >= $pagel) {
+ $top->scrollok(1);
+ $top->scrl(1);
+ $top->scrollok(0);
+ $y = $pagel-1;
+ }
+ $top->move($y, 0);
+ dbg("A: s:$spos sh:" . scalar @sh . " y:$y l:" . length($line) . " '$line'") if isdbg('console');
+ $top->refresh;
+ setattr($line);
+ $line =~ s/\n//s;
+ $top->addstr($line);
+ $top->attrset(COLOR_PAIR(0)) if $has_colors;
+ ++$spos;
+ }
+ shift @sh while @sh > $maxshist;
+ $spos = @sh;