Acme-Curses-Marquee

 view release on metacpan or  search on metacpan

lib/Acme/Curses/Marquee.pm  view on Meta::CPAN

    refresh($w);
}

=head2 text

Take a new line of text for the marquee...

   $m->text("New line of text");

...render it via figlet, split it into an array, and perform width
adjustments as neccessary. Store the new text, figleted text, length
of figleted text lines, and set marquee state to active.

=cut

sub text {
    my ($self,$text) = @_;
    my $font  = $self->{font};
    my $width = length($text) * 12;
    my $line  = 0;

    # render text via figlet
    my @fig = split(/\n/,`figlet -f $font -w $width '$text'`);

    # find longest line length
    foreach my $i (0..(@fig - 1)) {
        $line = length($fig[$i]) if (length($fig[$i]) > $line);
    }

    # set line length to window width if shorter than that
    $line = $self->{width} if ($line < $self->{width});

    # pad all lines window width or longest length + 5
    foreach my $i (0..(@fig - 1)) {
        my $len = length($fig[$i]);
        my $pad = $line - $len;
        $pad += 25 if ($len > ($self->{width} - 6));
        $fig[$i] = join('',$fig[$i],(' 'x $pad));
    }
    
    $self->{active} = 1;
    $self->{offset} = 0;
    $self->{srctxt} = $text;
    $self->{txtlen} = length($fig[0]);
    $self->{figtxt} = \@fig;
}

=head2 font

Sets the font of the marquee object and then calls C<text> to make the
display change.

    $m->font('univers')



( run in 0.729 second using v1.01-cache-2.11-cpan-65fba6d93b7 )