App-Colorist
view release on metacpan or search on metacpan
lib/App/Colorist/Colorizer.pm view on Meta::CPAN
my $color;
if ($d eq 'X') {
if (defined $n) {
$color = $self->c($names->[$n]);
}
else {
$color = $self->c('DEFAULT');
}
push @stack, $color;
}
else {
pop @stack;
if (@stack) {
$color = $stack[-1];
}
else {
$color = $self->c('DEFAULT');
}
}
if (defined $color) {
substr($_, $i + $offset, 0) = $color;
$offset += length $color;
}
}
last RULE;
}
}
$fh->print($_);
$self->print_reset_line;
}
__PACKAGE__->meta->make_immutable;
__END__
=pod
=encoding UTF-8
=head1 NAME
App::Colorist::Colorizer - the brain behind App::Colorist
=head1 VERSION
version 0.150460
=head1 SYNOPSIS
my $colorizer = App::Colorist::Colorizer->enw(
commandset => 'mycommand',
);
$colorizer->run;
=head1 DESCRIPTION
This is primarily engineered as a separate module to make testing easier. However, if you want to embed a colorizer in some other program for some reason or you want to extend colorizer, this provides the tools for that as well. This is why I decided...
If you do provide extensions, I would love to see them. Patches are welcome.
=head1 ATTRIBUTES
=head2 configuration
This is the name of the master configuration to use. This is usually the name of the command whose output you are colorizing. Each configuration must contain at least one ruleset and one colorset configuration. See L<App::Colorist/CONFIGURATION> for ...
=head2 ruleset
This is the name of the rule set to use. See L<App::Colorist/CONFIGURATION> for how rule sets are defined and located.
=head2 colorset
This is the name of the color set to use. See L<App::Colorist/CONFIGURATION> for how color sets are defined and located.
=head2 include
This is an array of extra include paths to search when looking for colorist configuration files.
=head2 debug
This is mostly useful for testing the app itself. When set to a true value, the colors are not output but a numeric representation like "{12}" is output instead.
=head2 inputs
This is an array of file handles to use for input. A builder lazily sets this to an array containing only the C<ARGV> file handle by default. If more than one file handle is passed, this will capture output of all file handles and display from each a...
=head2 selected_inputs
This is an L<IO::Select> built from the list of input file handles in L</inputs>.
=head2 input_buffers
This is an array of strings used as input buffers. This is used with the non-blocking I/O code to store any partially read lines encountered.
=head2 output
This is the fil ehandle to use for output. A builder lazily sets this to C<STDOUT> by default.
=head2 search_path
This contains the full search path. You do not normally want to set this yourself, but use L</include> instead. It is lazily instantiated to includ the values set in L</include>, the value of the C<COLORIST_CONFIG> environment variable, followed by F...
=head2 ruleset_file
This is set to the name of the actual ruleset file found by searching L</search_paths> and L</ruleset>.
=head2 colorset_file
This is the actual colorset file found by searching L</search_paths> for C<colorset>.
=head2 colors_mtime
When the colorset file is loaded, this mtime is set to the current mtime of the file. Every time a line is colored it checks to see if the colorset file has changed and will reload it automatically if it has.
=head2 colors
This is the actual colorset configuration. It's a set of keys naming the various color names defined in the ruleset and the values are the color definitions. See L<App::Colorist/CONFIGURATION> for details.
( run in 1.162 second using v1.01-cache-2.11-cpan-39bf76dae61 )