Skip to content

Commit

Permalink
skat: cat with syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
trapd00r committed Jan 30, 2011
1 parent d26a21b commit 2bba57e
Showing 1 changed file with 103 additions and 0 deletions.
103 changes: 103 additions & 0 deletions skat
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:

0 comments on commit 2bba57e

Please sign in to comment.