#!/usr/bin/perl use strict; use warnings; my $file_in = shift or die "Usage: p4c.pl file.in file.out\n"; my $file_out = shift or die "Usage: p4c.pl file.in file.out\n"; my $fg = 30; my $bg = 40; my %c = ( 'black' => 0, 'red' => 1, 'green' => 2, 'yellow' => 3, 'blue' => 4, 'magenta' => 5, 'cyan' => 6, 'white' => 7 ); my %i = ( 'normal' => 0, 'bold' => 1, 'faint' => 2, 'italic' => 3, 'uline' => 4 ); my %m = ( ## MODE FOREGROUND BACKGROUND 'none' => [ 'normal', 'white', 'black' ], 'action' => [ 'normal', 'cyan', 'black' ], 'how' => [ 'normal', 'cyan', 'black' ], 'depotFile' => [ 'normal', 'green', 'black' ], 'path' => [ 'normal', 'green', 'black' ], 'localPath' => [ 'normal', 'green', 'black' ], 'change' => [ 'normal', 'yellow', 'black' ], 'haveRev' => [ 'normal', 'red', 'black' ], 'workRev' => [ 'normal', 'red', 'black' ], 'fromRev' => [ 'normal', 'red', 'black' ], 'depotRev' => [ 'normal', 'red', 'black' ], 'lbrRev' => [ 'normal', 'red', 'black' ], 'rev' => [ 'normal', 'red', 'black' ], ); # Open a file for READ open (FIN, "<", $file_in) or die $!; open (FOUT, ">", $file_out) or die $!; while (<FIN>) { my $l = $_; if( $l =~ /\[/ ) { } else { foreach my $key ( keys %m ) { my $set = "[" . "\e[" . $i{ $m{$key}[0] } . "\;" . ($fg + $c{ $m{$key}[1] }) . "m"; my $clr = "\e[" . $i{ $m{'none'}[0] } . "m" . "]"; $l =~ s/\%$key\%/$set\%$key\%$clr/; } } $l =~ s/\@en\@/\@enc\@/; # print ("$l"); print FOUT ("$l"); } close( FOUT ); close( FIN );
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 7953 | Sven Erik Knop |
Added the message files for 2010.2 in Englisch as well as Englisch-colour. Also added the perl script that adds colour to journal file for db.message. Remember that you need to import the message file using p4d -jr and set P4LANGUAGE=enc This will not work on Windows that cannot deal with ANSI colours! |