Tickit::Widget::Table - tabular widget support for Tickit
version 0.003
use Tickit::Widget::HBox; use Tickit::Widget::Table; # Create the widget my $table = Tickit::Widget::Table->new( padding => 1, columns => [ { label => 'First column', align => 'center', width => 'auto' }, { label => 'Second column', align => 'right', width => 'auto' }, ], ); $table->add_row( 'First entry', 'Second column', ); $table->add_row( 'Second entry', 'More data', ); # Put it in something my $container = Tickit::Widget::HBox->new; $container->add($table, expand => 1);
Basic support for table widgets. See examples/ in the main distribution for usage instructions.
Create a new table widget.
Takes the following named parameters:
columns - column definition arrayref, see "add_column" for the details
padding - amount of padding (in chars) to apply between columns
default_action - coderef to execute when a cell/row/column is activated, unless there is an action defined on that item already
header - flag to select whether a header is shown. If not provided it is assumed that a header is wanted.
highlight_mode - one of row (default), column, cell, defines how navigation and selection work
Adds a header row to the top of the table. Takes no parameters.
Populates initial columns from the given arrayref. Generally handled internally when passing columns in the constructor.
columns
Returns amount of padding between cells
Number of rows.
Number of screen columns.
'rows' are the number of data rows we have in the table. That's one less than the total number of rows if we have a header row
Number of columns in the table.
Returns the rows containing data - this excludes the header row if there is one.
Put the cursor in the right place. Possibly used internally, probably of dubious utility.
Returns the header row if there is one.
Highlight a row in the table. Only one row can be highlighted at a time, as opposed to selected rows.
Returns currently-highlighted row, if we have one. In cell mode, returns the row corresponding to current cell highlight.
Returns currently-highlighted column, if we have one. In cell mode, returns the column corresponding to current cell highlight.
Index of the currently-highlighted row.
Index of the currently-highlighted column.
Check current widths and apply width on columns we already have sufficient information for.
Try to shrink columns down to minimum possible width if they're flexible. Typically used by "add_column" to allow the new column to fit properly.
Return the width for the given column, or undef if this column should be autosized.
Returns all columns for this table as a list.
Add a new column to the table, returning a Tickit::Widget::Table::Column instance.
Adds a new row of data to the table. This will instantiate a new Tickit::Widget::Table::Row and return it.
Remove the given row.
Clears any data for this table, leaving structure including header row intact.
Once we have a window, we want to refit to ensure that all the child elements are given subwindows with appropriate geometry.
When the main window is lost, we also clear all the subwindows that were created for children.
Key handling: convert some common key requests to events.
Handle a quit request. This is clearly not the place to have code like this.
uh, no. you didn't see this.
Select everything, unless everything is already selected in which case select nothing instead.
Toggle selection for this row.
Should not be here.
Move to the row above.
Move to the top of the table.
Move to the end of the table.
Move several lines up.
Move one line down.
Move several lines down.
Move to the item on the left.
Move to the item on the right.
Accessor/mutator for the on_key callback.
on_key
Returns $self when used as a mutator, or the current on_key value when called with no parameters.
Accessor/mutator for the on_highlight_changed callback.
on_highlight_changed
Returns $self when used as a mutator, or the current on_highlight_changed value when called with no parameters.
Accessor for pen attributes to use for highlighted cells, as a hashref.
Accessor for pen attributes to use for unhighlighted cells, as a hashref.
Called when the window has been resized. Recalculates layout.
Tom Molesworth <cpan@entitymodel.com>
Copyright Tom Molesworth 2011. Licensed under the same terms as Perl itself.
To install Tickit::Widget::Table, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tickit::Widget::Table
CPAN shell
perl -MCPAN -e shell install Tickit::Widget::Table
For more information on module installation, please visit the detailed CPAN module installation guide.