Data::P...::Theme(3)
π NAME π
okay so bestie, you're on the page for Data::P...::Theme(3) from the User Contributed Perl Documentation, and it's literally all about Data::Printer::Theme: create your own color themes for DDP! πβ¨
β¨ SYNOPSIS β¨
here's the whole lil module skeleton β copy-paste it, customize it, make it yours π«Ά
package Data::Printer::Theme::MyCustomTheme;
sub colors {
return {
array => '#aabbcc', # array index numbers
number => '#aabbcc', # numbers
string => '#aabbcc', # strings
class => '#aabbcc', # class names
method => '#aabbcc', # method names
undef => '#aabbcc', # the 'undef' value
hash => '#aabbcc', # hash keys
regex => '#aabbcc', # regular expressions
code => '#aabbcc', # code references
glob => '#aabbcc', # globs (usually file handles)
vstring => '#aabbcc', # version strings (v5.30.1, etc)
lvalue => '#aabbcc', # lvalue label
format => '#aabbcc', # format type
true => '#aabbcc', # boolean type (true)
false => '#aabbcc', # boolean type (false)
repeated => '#aabbcc', # references to seen values
caller_info => '#aabbcc', # details on what's being printed
weak => '#aabbcc', # weak references flag
tainted => '#aabbcc', # tainted flag
unicode => '#aabbcc', # utf8 flag
escaped => '#aabbcc', # escaped characters (\t, \n, etc)
brackets => '#aabbcc', # (), {}, []
separator => '#aabbcc', # the "," between hash pairs, array elements, etc
quotes => '#aabbcc', # q(")
unknown => '#aabbcc', # any (potential) data type unknown to Data::Printer
};
}
1;
Then in your .dataprinter file:
theme = MyCustomTheme
That's it! Alternatively, you can load it at runtime:
use DDP theme => 'MyCustomTheme';
π DESCRIPTION π
okay so Data::Printer colorizes your output by default. Originally, the only way to customize colors was to override the default ones π. Then Data::Printer 1.0 introduced themes, and now you can pick a theme or create your own. main character energy, fr fr π
Data::Printer comes with several themes for you to choose from:
- Material (the default) β iconic, obviously π
- Monokai β a whole vibe πΈ
- Solarized β yes bestie, that one βοΈ
- Classic (original pre-1.0 colors) β vintage era π
Run examples/try_me.pl to see them in action on your own terminal! π»β¨
π¨ CREATING YOUR THEMES π¨
A theme is a module in the Data::Printer::Theme namespace. It doesn't have to inherit or load any module. All you have to do is implement a single function, colors, that returns a hash reference where keys are the expected color labels, and values are the colors you want to use.
Feel free to copy & paste the code from the SYNOPSIS and customize at will :) π«Ά
π Customizing Colors π
Setting any color to undef means "Don't colorize this". Otherwise, the color is a string which can be one of the following:
π Named colors, Term::ANSIColor style (discouraged)
Only 8 named colors are supported:
blackredgreenyellowbluemagentacyanwhite
and their bright_XXX, on_XXX and on_bright_XXX variants.
Those are provided only as backwards compatibility with older versions of Data::Printer and, because of their limitation, we encourage you to try and use one of the other representations.
π SGR Escape code (Terminal style)
You may provide any SGR escape sequence, and they will be honored as long as you use double quotes (e.g. "\e[38;5;196m"). You may use this to achieve extra control like blinking, etc. Note, however, that some terminals may not support them.
π₯ An RGB value in one of those formats (Recommended)
'rgb(0,255,30)'
'#00FF3B'
NOTE: There may not be a real 1:1 conversion between RGB and terminal colors. In those cases we use approximation to achieve the closest option.
π SEE ALSO π
Data::Printer
mwah π this page comes from perl v5.42.0, dated 2024-01-23, and it's literally Data::P...::Theme(3). byeee bestie, go make something iconic π«Άβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Data-Printer 1.002001-bp160.1.11 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms