App-Colorist
view release on metacpan or search on metacpan
lib/App/Colorist.pm view on Meta::CPAN
=back
If you have complex rules or need something more complicated, the important thing about these files to know is that the very last line of the file must return an array reference containing alternating regular expressions and names. For example, the f...
[
qr{Starting (\S+)\.\.\.}, [ qw( message program ) ],
qr{Finished processing (http://([\w.]+)/) \.\.\.}, [ qw(
message url hostname
) ],
]
For more information about the rule syntax. You may read the documentation at L<App::Colorist::Ruleset> for details.
A named configuration may contain more than one ruleset. This might be used to parse different variations of the command (such as colorizing git output for various sub-commands) or just provide alternate ways of parsing the command in case you need t...
=head2 Colorsets
The colorset configuration gives each color named in the ruleset an actual color. It is defined using YAML (which is a superset of JSON, so you may use JSON if you prefer). The file should be built as a single section that contains a hash at the root...
There is also a special color, named "DEFAULT". You can use this to assign a color to any unmatched line. (If default is set to the "No color" option described below then it will be set to whatever color uncolored text is given in the user's terminal...
Here is an example colorset file to go with the ruleset example defined in the L</Ruleset> section:
---
message: ~
program: white
url: { fg: blue, bg: gray }
hostname: [ 2, 2, 0 ]
DEFAULT: [ 10 ]
Each color declaration may be defined in one of the following ways:
=over
=item *
B<No color.> To use no color for a section, you may either omit the color name entirely from the colorset or set it to C<null> (which can be written as C<~> in YAML). This does not necessarily mean the section will be uncolored, but that it will get ...
=item *
B<Named color.> As of this writing the following color names are permitted (with the ANSI color code in parenthesis):
black (0) gray (8)
maroon (1) red (9)
green (2) lime (10)
olive (3) yellow (11)
navy (4) blue (12)
purple (5) fuschia (13)
teal (6) aqua (14)
silver (7) white (15)
These are the most common ways to color text. If just a single name is given this way, it is the color of the foreground or text itself.
=item *
B<Numeric color.> Another option is to assign each a color. For most terminals, this can be any integer in the 0-15 range with the colors usually being like those named above. If you use a terminal that supports it, you may use numbers in the 0-255 r...
=item *
B<Color pair.> If you would like to set the background color, you may do so by setting the color to a hash (or object, if you prefer). The keys in the hash are "fg" for setting the foreground color and "bg" for setting the background. The color itsel...
=item *
B<Gray scale.> For terminals supporting 256 colors, you may use the gray scale by setting the color name to a 1-tuple (single element array) containing the numeric index of the shade of gray you want to use. In these scheme, C<[0]> is black and C<[23...
=item *
B<RGB color.> The final option is to use a 3-tuple (an array with 3 elements) to use one of the 216 colors available on 256 color terminals. As with most representations of the sort, the first index is red, the second is green, and the third is blue....
=back
There can be multiple colorsets for each named configuration. This allows for different themes to be used for different circumstances or different preferences.
=for Pod::Coverage BUILD
=head1 AUTHOR
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2015 by Qubling Software LLC.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
( run in 1.694 second using v1.01-cache-2.11-cpan-d8267643d1d )