forked from trapd00r/utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/usr/bin/perl | ||
use strict; | ||
use utf8; # ار | ||
use open ':utf8'; | ||
|
||
use Syntax::Highlight::Engine::Kate; | ||
use Term::ExtendedColor qw(:attributes); | ||
use IO::File; | ||
|
||
my $hl = new Syntax::Highlight::Engine::Kate( | ||
language => 'Perl', | ||
substitutions => {}, | ||
format_table => { | ||
Alert => [ fg(148), clear() ], | ||
BaseN => [ fg(196), clear() ], | ||
BString => [ fg(100), clear() ], | ||
Char => [ fg(111), clear() ], | ||
Comment => [ fg(137), clear() ], | ||
DataType => [ fg(166), clear() ], | ||
DecVal => [ fg(240), clear() ], | ||
Error => [ fg(160), clear() ], | ||
Float => [ fg(135), clear() ], | ||
Function => [ fg(118), clear() ], | ||
IString => [ fg(179), clear() ], | ||
Keyword => [ fg(111), clear() ], | ||
Normal => [ "", ""], | ||
Operator => [ fg(148), clear() ], | ||
Others => [ fg(225), clear() ], | ||
RegionMarker => [ fg(246), clear() ], | ||
Reserved => [ fg(178), clear() ], | ||
String => [ fg(179), clear() ], | ||
Variable => [ fg(148), clear() ], | ||
Warning => [ fg(160), clear() ], | ||
}, | ||
); | ||
|
||
my $fh; | ||
my $file = shift @ARGV; | ||
if ( !$file || $file eq '-' ) { | ||
binmode STDIN; | ||
$fh = \*STDIN; | ||
} | ||
else { | ||
$fh = IO::File->new($file) | ||
|| die "Cannot open file: $file: $!"; | ||
} | ||
|
||
while ( my $line = <$fh> ) { | ||
print $hl->highlightText($line); | ||
}; | ||
|
||
|
||
|
||
|
||
__END__ | ||
=pod | ||
=head1 NAME | ||
skat - cat with syntax highlighting | ||
=head1 USAGE | ||
skat [FILE..] | ||
=head1 DESCRIPTION | ||
=head1 OPTIONS | ||
=head1 REPORTING BUGS | ||
Report bugs and/or feature requests on rt.cpan.org, the repository issue tracker | ||
or directly to L<magnus@trapd00r.se> | ||
=head1 AUTHOR | ||
Magnus Woldrich | ||
CPAN ID: WOLDRICH | ||
magnus@trapd00r.se | ||
http://japh.se | ||
=head1 CONTRIBUTORS | ||
None required yet. | ||
=head1 COPYRIGHT | ||
Copyright 2011 B<THIS APPLICATION>s L</AUTHOR> and L</CONTRIBUTORS> as listed | ||
above. | ||
=head1 LICENSE | ||
This program is free software; you can redistribute it and/or modify | ||
it under the same terms as Perl itself. | ||
=head1 SEE ALSO | ||
=cut | ||
# vim: set ts=2 et sw=2: | ||