Acme-Curses-Marquee-Extensions
view release on metacpan or search on metacpan
fix-up window when font cycling:
resize && mvwin w/ pre-calc'd vals
alternate through a set of dup'd wins
Multiple style "delays"?
cond > 0 ? every(seconds=>cond) : offset = 0
selectively recompile subroutines?
modify $RE{balanced}{-begin=>'sub\s+$NAME.*?{'}{-end=>'}'}
Text::FIGlet features
lib/Acme/Curses/Marquee/EVIL.pm view on Meta::CPAN
#No joy with Filter::Simple, so we'll have to be crafty.
open(BASE, '<', $INC{'Acme/Curses/Marquee.pm'}) || die $!;
$_ = join('', <BASE>);
close(BASE);
my $pp = <<'PPF';
my @fig = $self->{_font}->{$self->{font}}->figify(-A=>$text,-w=>-1);
PPF
s/^[^#]*(?:qx.|`)figlet.*$/$pp/m;
#For some reasons being conservative causes compilation to fail :-(
#s/^(.*use\s+warnings.+)$/\1no warnings 'redefined';/m;
s/^(.*use\s+warnings.+)$//m;
eval;
1;
lib/Acme/Curses/Marquee/Extensions.pm view on Meta::CPAN
my %args = (
active => 0,
winh => 25,
winw => 80,
winx => 0,
winy => 0,
@_ );
$args{srctxt} = delete($args{text});
#Instantiate the font(s)
my $font;
if( ref($args{font}) eq 'ARRAY' ){
local($_);
$args{_fonts} = $args{font};
$args{_fontSec} = pop @{$args{_fonts}} if $args{_fonts}->[-1] =~ /^\d+/;
$font = $args{_font}->{ $args{font}=$_ } = font({}, $_, '-0') for
reverse @{$args{_fonts}};
}
else{
$font = $args{_font}->{$args{font}} = font({}, $args{font}, '-0');
}
#For text's rendering
$args{height} = $font->{_header}->[1];
$args{width} = $args{winw};
#Set up the display
$args{winy} ||= int($args{winh}/2 - $args{height}/2);
$args{win} = new Curses($args{height},$args{winw},$args{winy},$args{winx});
my $self = bless \%args, $class;
$self->text($self->{srctxt}) if (defined $self->{srctxt});
return $self;
}
sub font {
$_[0]->{_font}->{$_[1]} = Text::FIGlet->new(-f=>$_[1]);
delete($_[0]->{_sweep});
return $_[-1] eq '-0' ? $_[0]->{_font}->{$_[1]} : shift->SUPER::font(@_);
}
sub sweep{
my($self, $state) = @_;
if( $state == -1 && $self->{offset} == int($self->{txtlen}/2) ){
$self->{txtlen} = $self->{_sweep};
}
if( $state ){
lib/Acme/Curses/Marquee/Extensions.pm view on Meta::CPAN
# $self->{offset} = 0;
$self->{txtlen} = delete($self->{_sweep});
}
}
{
my $i = 0;
sub scroll{
my $self = shift;
#XXX offset would work if we could account for one wrap-around...
# if( defined($self->{_fonts}) && ($self->{offset} == $self->{txtlen}) ){
if( defined($self->{_fonts}) && every seconds=>$self->{_fontSec}||45 ){
#XXX reposition vertically iff auto-centered
$self->font( $self->{_fonts}->[ ++$i %scalar(@{ $self->{_fonts} }) ]);
}
$self->SUPER::scroll;
}
}
{
my $i = 0;
my $rainbow = [qw/red yellow/,'bold yellow',qw/green cyan blue magenta/];
sub colors{
my($self, %p) = @_;
lib/Acme/Curses/Marquee/Extensions.pm view on Meta::CPAN
=head1 SYNOPSIS
use Package::Alias ACME => 'Acme::Curses::Marquee::Extensions';
use Acme::Curses::Marquee::Extensions;
use Term::ReadKey 'GetTerminalSize';
use Time::HiRes 'usleep';
my ($x, $y) = GetTerminalSize;
my $m = ACME->new(winw => $x, winh => $y,
font => [qw/doh caligraphy fraktur/],
text => 'Hello World!' );
while( 1 ){
$m->scroll( usleep 75_000 );
}
=head1 DESCRIPTION
Inherits all methods of L<Acme::Curses::Marquee>, except for C<new>,
which is among those outlined below.
lib/Acme/Curses/Marquee/Extensions.pm view on Meta::CPAN
=item winh
The height of the window. Defaults to 25.
=item winx
Location of the origin's abscissa. Defaults to 0.
=item winy
Location of the origin's ordinate. Defaults to (winh - fontHeight)/2
i.e; vertically centered.
=item font
Figfont to use, defaults to standard.
This also accepts an arrayref, which can be a list of fonts to rotate through.
If cycling fonts, the last element of the arrayref may be a number indicating
the number of seconds between transitions. Otherwise, this occurs every 45 sec.
For the time being, you probably want to use fonts of the similar heights,
and list the tallest first.
=item text
The text to render.
=back
=head2 colors(delay=>I<seconds>, colors=>I<[colors]>)
( run in 1.407 second using v1.01-cache-2.11-cpan-ceb78f64989 )