Tickit::Widget::Scroller - a widget displaying a scrollable collection of items
Tickit::Widget::Scroller
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
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.
Tickit::Widget::Scroller::Item
Constructs a new Tickit::Widget::Scroller object. The new object will start with an empty list of 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.
scroll
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.
$delta
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.
$line
$itemline
$itemidx
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.
scroll_to
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.
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.
undef
-1
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.
$firstline
$lastline
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
Paul Evans <leonerd@leonerd.org.uk>
To install Tickit::Widget::Scroller, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tickit::Widget::Scroller
CPAN shell
perl -MCPAN -e shell install Tickit::Widget::Scroller
For more information on module installation, please visit the detailed CPAN module installation guide.