Steven Haryanto

NAME

SHARYANTO::Role::ColorTheme - Role for class wanting to support color themes

VERSION

version 0.72

DESCRIPTION

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), name (str), summary (str), 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 $self->{_draw}{y}.

ATTRIBUTES

color_theme => HASH

color_theme_args => HASH

color_theme_class_prefix => STR (default: CLASS + "::ColorTheme")

METHODS

$cl->list_color_themes($detail) => ARRAY

$cl->get_color_theme($name) => HASH

$cl->get_theme_color($item_name, \%args) => STR

Get an item's color from the current color theme.

$cl->get_theme_color_as_ansi($item_name, \%args) => STR

Get an item's color from the current color theme, converted to ANSI codes.

$cl->themecol2ansi($col_code, \%args) => STR

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.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/SHARYANTO-Roles.

SOURCE

Source repository is at https://github.com/sharyanto/perl-SHARYANTO-Roles.

BUGS

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.

AUTHOR

Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE

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.




Hosting generously
sponsored by Bytemark