| 1 | package Text::ANSI::Highlight::IO; | ||
| 2 | |||
| 3 | use v5.16; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use IO::Factotum; | ||
| 7 | use Text::ANSI::Highlight; | ||
| 8 | |||
| 9 | # Give a highlighter to IO::Factotum: the files which are opened by it | ||
| 10 | # are read in the colors of the highlighter. The arguments are those | ||
| 11 | # of Text::ANSI::Highlight->new. | ||
| 12 | sub setup { | ||
| 13 | my $class = shift; | ||
| 14 | IO::Factotum::register(with => Text::ANSI::Highlight->new(@_)); | ||
| 15 | return; | ||
| 16 | } | ||
| 17 | |||
| 18 | # use Text::ANSI::Highlight::IO: the files which are read by <> are | ||
| 19 | # read by IO::Factotum | ||
| 20 | sub import { | ||
| 21 | my $class = shift; | ||
| 22 | $class->setup(@_); | ||
| 23 | IO::Factotum::tie_argv(); | ||
| 24 | } | ||
| 25 | |||
| 26 | 1; | ||
| 27 | |||
| 28 | __END__ |