Skip to content
Snippets Groups Projects
Commit 01d486b5 authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

mas colores

parent 12b11101
No related branches found
No related tags found
No related merge requests found
......@@ -193,6 +193,12 @@ sub number
return hex( $_[0]->result->{'number'} );
}
sub difficulty
{
return if not exists $_[0]->result->{'difficulty'};
return hex( $_[0]->result->{'difficulty'} );
}
sub td
{
return if not exists $_[0]->result->{'totalDifficulty'};
......@@ -339,25 +345,41 @@ sub determine_colour
if $diff == 0;
return ansi::green()
if $diff < scalar ( keys %signers );
return ansi::bgyellow() . ansi::black
return ansi::bgyellow() . ansi::black()
if $diff < 720; # one hour
return ansi::red();
}
sub colour_split
{
my ($name, $diff, $col) = @_;
my ($name, $diff, $col, $difficulty)
= @_;
return $name
if $diff == 0;
my $len = length $name;
return
substr( $name, 0, $len-$diff) .
(( $col eq '' ) ? ansi::green() : $col) .
substr( $name, $len-$diff ) .
ansi::normal()
if $diff <= $len;
if ( $diff <= $len )
{
my $part1 = substr $name, 0,$len-$diff;
my $part2 = substr $name, $len-$diff,1;
my $part3 = substr $name, $len-$diff+1;
if ( $difficulty == 2 )
{
$part3 = $part2 . $part3;
$part2 = '';
}
$part2 = ansi::bgyellow() . ansi::black() . $part2 . ansi::normal()
if $part2 ne '';
return
$part1 .
$part2 .
(( $col eq '' ) ? ansi::green() : $col) .
$part3 .
ansi::normal();
}
# diff > len
return $col . $name . ansi::normal();
return
ansi::red() . substr( $name, 0, 1 ) . ansi::normal() .
$col . substr( $name, 1 ) . ansi::normal();
}
sub presentation_top
......@@ -436,7 +458,10 @@ while ( defined $block || sleep 1 )
my $lastnum = exists $signers{$this} ? $signers{$this} : -12345;
my $diff = $number - $lastnum;
my $col = determine_colour( $diff );
my $id = colour_split( $this, $diff, $col );
my $difficulty = ( exists $signers{$this} and exists $cache{$signers{$this}}{'block'} )
? $cache{$signers{$this}}{'block'}->difficulty
: 0;
my $id = colour_split( $this, $diff, $col, $difficulty );
my $flags = $diff == 0 ? '*' : '';
my $alias = alias::translate( $this );
my $numtxt = (not defined $lastnum or $lastnum < 0) ? 'n/a' : $lastnum;
......@@ -448,4 +473,5 @@ while ( defined $block || sleep 1 )
print ansi::ED(0);
#
$number = $block->number + 1;
select( undef, undef,undef, 0.2 );
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment