NAME
    "Tickit::Widget::Scroller" - a widget displaying a scrollable collection
    of items

SYNOPSIS
     use Tickit;
     use Tickit::Widget::Scroller;
     use Tickit::Widget::Scroller::Item::Text;
 
     my $tickit = Tickit->new;
 
     my $scroller = Tickit::Widget::Scroller->new;

     $scroller->push(
        Tickit::Widget::Scroller::Item::Text->new( "Hello world" ),
        Tickit::Widget::Scroller::Item::Text->new( "Here are some lines" ),
        map { Tickit::Widget::Scroller::Item::Text->new( "<Line $_>" ) } 1 .. 50,
     );
 
     $tickit->set_root_widget( $scroller );
 
     $tickit->run

DESCRIPTION
    This class provides a widget which displays a scrollable list of items.
    The view of the items is scrollable, able to display only a part of the
    list.

    A Scroller widget stores a list of instances implementing the
    "Tickit::Widget::Scroller::Item" interface.

CONSTRUCTOR
  $scroller = Tickit::Widget::Scroller->new
    Constructs a new "Tickit::Widget::Scroller" object. The new object will
    start with an empty list of items.

METHODS
  $scroller->push( @items )
    Append the given items to the end of the list.

    If the Scroller is already at the tail (that is, the last line of the
    last item is on display), the newly added items will be displayed,
    possibly by scrolling downward if required. While the scroller isn't
    adjusted, by using any of the "scroll" methods, it will remain following
    the tail of the items, scrolling itself upwards as more are added.

  $scroller->scroll( $delta )
    Move the display up or down by the given $delta amount; with positive
    moving down. This will be a physical count of displayed lines; if some
    items occupy multiple lines, then fewer items may be scrolled than
    lines.

  $scroller->scroll_to( $line, $itemidx, $itemline )
    Moves the display up or down so that display line $line contains line
    $itemline of item $itemidx. Any of these counts may be negative to count
    backwards from the display lines, items, or lines within the item.

  $scroller->scroll_to_top( $itemidx, $itemline )
    Shortcut for "scroll_to" to set the top line of display; where $line is
    0. If $itemline is undefined, it will be passed as 0. If $itemidx is
    also undefined, it will be passed as 0. Calling this method with no
    arguments, therefore scrolls to the very top of the display.

  $scroller->scroll_to_bottom( $itemidx, $itemline )
    Shortcut for "scroll_to" to set the bottom line of display; where $line
    is -1. If $itemline is undefined, it will be passed as -1. If $itemidx
    is also undefined, it will be passed as -1. Calling this method with no
    arguments, therefore scrolls to the very bottom of the display.

  $itemidx = $scroller->line2item( $line )
  ( $itemidx, $itemline ) = $scroller->line2item( $line )
    Returns the item index currently on display at the given line of the
    window. In list context, also returns the line number within item. If no
    window has been set, or there is no item on display at that line,
    "undef" or an empty list are returned. $line may be negative to count
    backward from the last line on display; the last line taking -1.

  $firstline = $scroller->item2line( $itemidx )
  ( $firstline, $lastline ) = $scroller->item2line( $itemidx )
    Returns the first display line in the window of the item at the given
    index. In list context also returns the last line. If no window has been
    set, or the item is not visible, "undef" or an empty list are returned.
    If the item is partially on display, then $firstline may be negative, or
    $lastline may be higher than there are lines in the window. $itemidx may
    be given negative, to count backwards from the last item.

TODO
    *   Item::RichText - will depend on String::Tagged

    *   Abstract away the "item storage model" out of the actual widget.
        Implement more storage models, such as database-driven ones.. more
        dynamic.

    *   Keybindings

AUTHOR
    Paul Evans <leonerd@leonerd.org.uk>

