Data-HexDump-Range

 view release on metacpan or  search on metacpan

lib/Data/HexDump/Range/Format.pm  view on Meta::CPAN

if(defined $self->{COLOR_NAMES} && 'HASH' ne ref $self->{COLOR_NAMES})
        {
        my $colors = do $self->{COLOR_NAMES}
                or $self->{INTERACTION}{DIE}("Error: Can't load color file '$self->{COLOR_NAMES}'.\n") ;

        'HASH' eq ref $colors
                or $self->{INTERACTION}{DIE}("Error: Data not a Hash in '$self->{COLOR_NAMES}'.\n") ;

        $self->{COLOR_NAMES} = $colors ;
        }

for my $definition 
	(
	#aliases looked up by colorizer module
	['ruler', 'lookup:white', 'lookup:white'],
	['offset', 'lookup:white', 'lookup:white'],
	['cumulative_offset', 'lookup:bright_black', 'lookup:bright_black'],
	)
	{
	my ($name, $ansi_color, $html_color) = @{$definition} ;
	$self->{COLOR_NAMES}{ANSI}{$name} //= $ansi_color ;
	$self->{COLOR_NAMES}{HTML}{$name} //= $html_color ;
	}

my $colorizer = Text::Colorizer->new
				(
				COLORS => $self->{COLOR_NAMES},
				FORMAT => $self->{FORMAT},
				) ;

my @colored_lines ;

my @fields = @{$self->{FIELDS_TO_DISPLAY}} ;
unshift @fields, 'INFORMATION', 'RULER' ;

for my $line (@{$line_data})
	{
	for my $field (@fields)
		{
		if(exists $line->{$field})
			{
			for my $range (@{$line->{$field}})
				{
				push @colored_lines, $range->{"${field}_COLOR"}, $range->{$field} ,
				}
				
			push @colored_lines, $EMPTY_STRING, q{ } ;
			}
		}
		
	push @colored_lines, $EMPTY_STRING, "\n" if $line->{NEW_LINE} ;
	}

return $colorizer->color(@colored_lines) ;
}

#-------------------------------------------------------------------------------

1 ;

=head1 BUGS AND LIMITATIONS

None so far.

=head1 AUTHOR

	Nadim ibn hamouda el Khemir
	CPAN ID: NKH
	mailto: nadim@cpan.org

=head1 COPYRIGHT AND LICENSE

Copyright Nadim Khemir 2010-2012.

This program is free software; you can redistribute it and/or
modify it under the terms of either:

=over 4

=item * the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or

=item * the Artistic License version 2.0.

=back

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Data::HexDump::Range

You can also look for information at:

=over 4

=item * AnnoCPAN: Annotated CPAN documentation

L<http://annocpan.org/dist/Data-HexDump-Range>

=item * RT: CPAN's request tracker

Please report any bugs or feature requests to  L <bug-data-hexdump-range@rt.cpan.org>.

We will be notified, and then you'll automatically be notified of progress on
your bug as we make changes.

=item * Search CPAN

L<http://search.cpan.org/dist/Data-HexDump-Range>

=back

=head1 SEE ALSO

L<Data::HexDump::Range>

=cut



( run in 0.996 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )