SHARYANTO::Role::ColorTheme - Role for class wanting to support color themes
This role is for class that wants to support color themes. For description about color themes, currently please refer to Text::ANSITable.
Color theme is a defhash containing
v (float, should be 1.1),
no_color (bool, should be set to 1 if this is a color theme without any colors), and
colors (hash, the colors for items).
A color should be a scalar containing a single color code which is 6-hexdigit RGB color (e.g.
ffc0c0), or a hashref containing multiple color codes, or a coderef which should produce a color code (or a hash of color codes).
Multiple color codes are keyed by:
fg (RGB value for foreground),
bg (RGB value for background),
ansi_fg (ANSI color escape code for foreground),
ansi_bg (ANSI color escape code for background). Future keys like
css will be defined.
Allowing coderef as color allows for flexibility, e.g. for doing gradation border color, random color, etc (see Text::ANSITable::ColorTheme::Demo for an example). Code will be called with
($self, %args) where
%args contains various information, like
name (the item name being requested), etc. In Text::ANSITable, you can get the row position from
Get an item's color from the current color theme.
Get an item's color from the current color theme, converted to ANSI codes.
Convert a color from color theme (which can be a scalar containing color code, or a coderef that generates a color code) to ANSI escape code.
%args will be sent to coderef.
Please visit the project's homepage at https://metacpan.org/release/SHARYANTO-Roles.
Source repository is at https://github.com/sharyanto/perl-SHARYANTO-Roles.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=SHARYANTO-Roles
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Steven Haryanto <email@example.com>
This software is copyright (c) 2014 by Steven Haryanto.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.