Tickit-Widget-Scroller
view release on metacpan or search on metacpan
lib/Tickit/Widget/Scroller/Item/RichText.pm view on Meta::CPAN
}
method _build_chunks_for ( $str )
{
my @chunks;
$str->iter_substr_nooverlap(
sub {
my ( $substr, %tags ) = @_;
my $pen = $self->pen_for_tags( \%tags );
my @lines = split m/\n/, $substr, -1 or return;
my $lastline = pop @lines;
push @chunks, [ $_, textwidth( $_ ), pen => $pen, linebreak => 1 ] for @lines;
push @chunks, [ $lastline, textwidth( $lastline ), pen => $pen ];
},
);
return @chunks;
}
=head1 AUTHOR
lib/Tickit/Widget/Scroller/Item/Text.pm view on Meta::CPAN
If true, force a linebreak after this chunk; the next one starts on the
following line.
=back
=cut
method _build_chunks_for ( $text )
{
my @lines = split m/\n/, $text, -1;
@lines or @lines = ( "" ); # if blank
my $lastline = pop @lines;
return ( map { [ $_, textwidth( $_ ), linebreak => 1 ] } @lines ),
[ $lastline, textwidth( $lastline ) ];
}
method chunks { @_chunks }
method height_for_width ( $width )
{
( run in 1.528 second using v1.01-cache-2.11-cpan-71847e10f99 )