1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
use Term::ANSIColor;
use strict;
=pod
run it with:
./dmrg input507-45a.inp 2>&1 | perl ~/programs/github/PsimagLite/scripts/colorOutput.pl >& out &
tail out
reset the screen with:
perl colorOutput.pl reset
See available colors here: http://en.wikipedia.org/wiki/ANSI_escape_code
=cut
my ($needReset)=@ARGV;
if (defined($needReset)) {
print color 'reset';
exit(0);
}
my %colors;
$colors{"WaveFunctionTransf"}='yellow';
$colors{"Truncation"}='green';
$colors{"DmrgSolver"}='red';
$colors{"LeftRightSuper"}='magenta';
$colors{"Diag."}='cyan';
$colors{"LanczosSolver"}='bold white';
#$colors{"DensityMatrixLocal"}='darkgray';
$SIG{INT}=\&myhandler;
while(<STDIN>) {
chomp;
procLine($_);
print "\n";
}
sub procLine
{
my ($t)=@_;
print color 'reset';
if (!/\:/) {
print "$t";
return;
}
my @temp = split/\:/,$t;
#print STDERR "--$temp[0]--\n";
my $c = $colors{$temp[0]};
if (!defined($c)) {
print color 'reset';
print "$t";
return;
}
#print STDERR " c = $c----\n";
print color "$c";
print "$t";
print color 'reset';
}
sub myhandler
{
print color 'reset';
}
|