Getting better scrolling from curses?

Eric Lee Green elg at elgamy.RAIDERNET.COM
Thu Jun 13 12:52:45 AEST 1991


>From article <1991Jun11.211657.17798 at jwt.UUCP>, by john at jwt.UUCP (John Temples):
> scrollok(TRUE) and idlok(TRUE) on each window.  The first problem is
> the speed of the scrolling -- it's about 25% of the speed of catting a
> file to the console (if that).  Even with a full screen window, the
> scrolling speed is about the same.  Is it just that curses is slow, or
> is there a better way to do what I want?

Curses is widely regarded as "boy, what a dog." I don't know about the
truth of such allegations, since I have avoided curses since. You might
want to do your own horizontal window management, using the
terminfo/termcap libraries directly. However, even then you'll still
be slower than a "cat", because you'll have to set up the scrolling
regions and re-set the cursor every time you switch to another "window".
These codes take up I/O bandwidth.

> The second problem occurs when scrolling the upper window in one of
> these applications.  With idlok() enabled, the lower window jumps up
> and down a line for every line the upper window scrolls.  The bottom
> window becomes a blur while the top window is scrolling.  If I turn off
> idlok(), the unpleasant artifacts disappear, but scrolling speed falls
> dramatically, while CPU consumption rises.  Is there any way to get
> clean, fast scrolling in two windows like this?

This sounds like a problem with either your terminal or your termcap
entry. Some terminals, such as TVI's or Lear-Siegler, do not have
scrolling-region capability. I.e., the only way they can scroll is
to delete a line at the top of the screen, insert a line at the middle of
the screen (where the new blank line will be), and thus you get that
"jump" effect. Note that this is also slowing down your scrolling
considerably, because terminals take a measurable amount of time to move 4K
of data memory up, then back down (most terminals are still based upon old
8-bit microprocessors, especially the old ones like you're apparently
using). Thus your termcap or terminfo entry will have these commands
heavily padded, thus adding a delay.

There's three solutions here: upgrade to a new terminal (VT100 compatibles
are pretty crufty, but they do have scrolling regions), correct your
termcap or terminfo entry in the event that your terminal DOES have
scrolling regions, or simply don't scroll -- just re-paint the areas of the
screen that have changed. This works okay at 9600 baud or faster speeds,
but your dial-up users at 2400 baud will probably curse you. And of course
spitting all that data out DOES cause lots of CPU usage... you're
re-painting an entire "window" every time you "scroll" a line.

Terminals are persnickety critters. Welcome to The Real World (tm) :-).

Eric Lee Green   (318) 984-1820  P.O. Box 92191  Lafayette, LA 70509
elg at elgamy.RAIDERNET.COM               uunet!mjbtn!raider!elgamy!elg
      Looking for a job... Unix/C... tips, leads appreciated.



More information about the Comp.unix.programmer mailing list