NAME

Tickit::Widget::Breadcrumb - render a breadcrumb trail

VERSION

version 0.003

SYNOPSIS

use Tickit;
use Tickit::Widget::Breadcrumb;
my $bc = Tickit::Widget::Breadcrumb->new;
$bc->adapter->push([
 qw(home perl site-lib)
]);
Tickit->new(root_widget => $bc)->run;

DESCRIPTION

Provides a widget for showing "breadcrumbs".

Accepts focus.

Use left/right to navigate, enter to select.

Render looks something like:

first < second | current | next > last

ITEM TRANSFORMATIONS

See "new".

METHODS

new

Instantiate. The following named parameters may be of use:

  • item_transformations - a coderef or arrayref of transformations to apply to items received from the adapter.

  • skip_first - number of items to skip at the start when rendering, default 0

An example of transformations:

my $bc = Tickit::Widget::Breadcrumb->new(
 item_transformations => sub {
  my $item = shift;
  strftime '%Y-%m-%d %H:%M:%S', localtime $item
 }
);
$bc->push([ time ]);

lines

Returns the number of lines this widget would like.

cols

Returns the number of columns this widget would like.

render_to_rb

Perform rendering.

render_separator

Renders the separator between two items.

Pass the index of the item on the left.

There are 3 cases:

  • inactive to inactive

  • inactive to active

  • active to inactive

transform_item

Applies any transformations to the given item.

Currently these are immediate transformations, i.e. no support for Futures. This may change in a newer versions, but you should be safe as long as you return a string or String::Tagged rather than a Future here.

See "ITEM TRANSFORMATIONS" for details.

adapter

Returns the adapter responsible for dealing with the underlying data.

If called with no parameters, will return the current adapter (creating one if necessary).

If called with a parameter, will set the adapter to that value, assigning a new default adapter if given undef. Will then return $self to allow for method chaining.

SEE ALSO

INHERITED METHODS

Tickit::Widget

get_style_pen, get_style_text, get_style_values, key_focus_next_after, key_focus_next_before, on_pen_changed, parent, pen, redraw, requested_cols, requested_lines, requested_size, reshape, resized, set_parent, set_pen, set_requested_size, set_style, set_style_tag, set_window, style_classes, take_focus, window, window_lost

AUTHOR

Tom Molesworth <cpan@perlsite.co.uk>

LICENSE

Copyright Tom Molesworth 2014-2015. Licensed under the same terms as Perl itself.