1Data::Printer::Theme(3)User Contributed Perl DocumentatioDnata::Printer::Theme(3)
2
3
4
6 Data::Printer::Theme - create your own color themes for DDP!
7
9 package Data::Printer::Theme::MyCustomTheme;
10
11 sub colors {
12 return {
13 array => '#aabbcc', # array index numbers
14 number => '#aabbcc', # numbers
15 string => '#aabbcc', # strings
16 class => '#aabbcc', # class names
17 method => '#aabbcc', # method names
18 undef => '#aabbcc', # the 'undef' value
19 hash => '#aabbcc', # hash keys
20 regex => '#aabbcc', # regular expressions
21 code => '#aabbcc', # code references
22 glob => '#aabbcc', # globs (usually file handles)
23 vstring => '#aabbcc', # version strings (v5.30.1, etc)
24 lvalue => '#aabbcc', # lvalue label
25 format => '#aabbcc', # format type
26 repeated => '#aabbcc', # references to seen values
27 caller_info => '#aabbcc', # details on what's being printed
28 weak => '#aabbcc', # weak references flag
29 tainted => '#aabbcc', # tainted flag
30 unicode => '#aabbcc', # utf8 flag
31 escaped => '#aabbcc', # escaped characters (\t, \n, etc)
32 brackets => '#aabbcc', # (), {}, []
33 separator => '#aabbcc', # the "," between hash pairs, array elements, etc
34 quotes => '#aabbcc', # q(")
35 unknown => '#aabbcc', # any (potential) data type unknown to Data::Printer
36 };
37 }
38 1;
39
40 Then in your ".dataprinter" file:
41
42 theme = MyCustomTheme
43
44 That's it! Alternatively, you can load it at runtime:
45
46 use DDP theme => 'MyCustomTheme';
47
49 Data::Printer colorizes your output by default. Originally, the only
50 way to customize colors was to override the default ones. Data::Printer
51 1.0 introduced themes, and now you can pick a theme or create your own.
52
53 Data::Printer comes with several themes for you to choose from:
54
55 • Material (the default)
56
57 • Monokai
58
59 • Solarized
60
61 • Classic (original pre-1.0 colors)
62
63 Run "examples/try_me.pl" to see them in action on your own terminal!
64
66 A theme is a module in the "Data::Printer::Theme" namespace. It doesn't
67 have to inherit or load any module. All you have to do is implement a
68 single function, "colors", that returns a hash reference where keys are
69 the expected color labels, and values are the colors you want to use.
70
71 Feel free to copy & paste the code from the SYNOPSIS and customize at
72 will :)
73
74 Customizing Colors
75 Setting any color to "undef" means "Don't colorize this". Otherwise,
76 the color is a string which can be one of the following:
77
78 Named colors, Term::ANSIColor style (discouraged)
79
80 Only 8 named colors are supported:
81
82 black, red, green, yellow, blue, magenta, cyan, white
83
84 and their "bright_XXX", "on_XXX" and "on_bright_XXX" variants.
85
86 Those are provided only as backards compatibility with older versions
87 of Data::Printer and, because of their limitation, we encourage you to
88 try and use one of the other representations.
89
90 SGR Escape code (Terminal style)
91
92 You may provide any SGR escape sequence, and they will be honored as
93 long as you use double quotes (e.g. "\e[38;5;196m"). You may use this
94 to achieve extra control like blinking, etc. Note, however, that some
95 terminals may not support them.
96
97 An RGB value in one of those formats (Recommended)
98
99 'rgb(0,255,30)'
100 '#00FF3B'
101
102 NOTE: There may not be a real 1:1 conversion between RGB and terminal
103 colors. In those cases we use approximation to achieve the closest
104 option.
105
107 Data::Printer
108
109
110
111perl v5.36.0 2022-08-01 Data::Printer::Theme(3)