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

Displaying LONG lists of items

    Date: Wed, 16 Dec 87 14:12:45 pst
    From: Douglas Schuler <douglas@boeing.com>

    Here is how I (naively?) think the problem could be avoided.

    Initializing the window:

    1.  Tell the window how many elements it will be displaying.  (the size)
    2.  Fill the viewport with the first N elements (of a list) that fit.
    3.  Update the scroll bar

    Telling the window a priori how many elements it would contain would allow
    the scroll bar and elevator to accurately reflect the contents of the list.

    Updating the display:

    1.  Find location of the mouse click
    2.  Find the N objects in the list that correspond to the location of the
    mouse click.  (i.e. index into the list)
    3.  Display those N objects in the viewport.

    This approach would allow a window (containing potentially huge number
    of elements) to only deal with a small number of objects at a time, yet
    still have a properly reflective scroll bar.

This all assumes that each item has the same height.  If you want to see
this type of approach fail, do the following:

Go into a new Zmacs buffer and enter about 100 short lines (one
character each works fine.  Then go to the end of the first line and
type "Meta-6200 a", so that the first line of the buffer will completely
fill the screen, and then Meta-> to get back to the beginning.  Then
move the mouse into the scroll bar, and it will claim that you are
seeing about half the buffer.  The scroll bar code is assuming that
since the window is around 50 lines high, and the buffer is 100 lines
long, that you must be seeing the first fifty lines, even though you are
only seeing one line.

In your application, perhaps each item is guaranteed to have the same
height, or maybe you're willing to live with this kind of inaccuracy,
too.  I just thought I'd point out why the default behavior of dynamic
windows is the most correct way.