.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Data::Printer::Theme 3pm" .TH Data::Printer::Theme 3pm 2024-04-27 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Data::Printer::Theme \- create your own color themes for DDP! .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& package Data::Printer::Theme::MyCustomTheme; \& \& sub colors { \& return { \& array => \*(Aq#aabbcc\*(Aq, # array index numbers \& number => \*(Aq#aabbcc\*(Aq, # numbers \& string => \*(Aq#aabbcc\*(Aq, # strings \& class => \*(Aq#aabbcc\*(Aq, # class names \& method => \*(Aq#aabbcc\*(Aq, # method names \& undef => \*(Aq#aabbcc\*(Aq, # the \*(Aqundef\*(Aq value \& hash => \*(Aq#aabbcc\*(Aq, # hash keys \& regex => \*(Aq#aabbcc\*(Aq, # regular expressions \& code => \*(Aq#aabbcc\*(Aq, # code references \& glob => \*(Aq#aabbcc\*(Aq, # globs (usually file handles) \& vstring => \*(Aq#aabbcc\*(Aq, # version strings (v5.30.1, etc) \& lvalue => \*(Aq#aabbcc\*(Aq, # lvalue label \& format => \*(Aq#aabbcc\*(Aq, # format type \& true => \*(Aq#aabbcc\*(Aq, # boolean type (true) \& false => \*(Aq#aabbcc\*(Aq, # boolean type (false) \& repeated => \*(Aq#aabbcc\*(Aq, # references to seen values \& caller_info => \*(Aq#aabbcc\*(Aq, # details on what\*(Aqs being printed \& weak => \*(Aq#aabbcc\*(Aq, # weak references flag \& tainted => \*(Aq#aabbcc\*(Aq, # tainted flag \& unicode => \*(Aq#aabbcc\*(Aq, # utf8 flag \& escaped => \*(Aq#aabbcc\*(Aq, # escaped characters (\et, \en, etc) \& brackets => \*(Aq#aabbcc\*(Aq, # (), {}, [] \& separator => \*(Aq#aabbcc\*(Aq, # the "," between hash pairs, array elements, etc \& quotes => \*(Aq#aabbcc\*(Aq, # q(") \& unknown => \*(Aq#aabbcc\*(Aq, # any (potential) data type unknown to Data::Printer \& }; \& } \& 1; .Ve .PP Then in your \f(CW\*(C`.dataprinter\*(C'\fR file: .PP .Vb 1 \& theme = MyCustomTheme .Ve .PP That's it! Alternatively, you can load it at runtime: .PP .Vb 1 \& use DDP theme => \*(AqMyCustomTheme\*(Aq; .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" Data::Printer colorizes your output by default. Originally, the only way to customize colors was to override the default ones. Data::Printer 1.0 introduced themes, and now you can pick a theme or create your own. .PP Data::Printer comes with several themes for you to choose from: .IP \(bu 4 Material \fI(the default)\fR .IP \(bu 4 Monokai .IP \(bu 4 Solarized .IP \(bu 4 Classic \fI(original pre\-1.0 colors)\fR .PP Run \f(CW\*(C`examples/try_me.pl\*(C'\fR to see them in action on your own terminal! .SH "CREATING YOUR THEMES" .IX Header "CREATING YOUR THEMES" A theme is a module in the \f(CW\*(C`Data::Printer::Theme\*(C'\fR namespace. It doesn't have to inherit or load any module. All you have to do is implement a single function, \f(CW\*(C`colors\*(C'\fR, that returns a hash reference where keys are the expected color labels, and values are the colors you want to use. .PP Feel free to copy & paste the code from the SYNOPSIS and customize at will :) .SS "Customizing Colors" .IX Subsection "Customizing Colors" Setting any color to \f(CW\*(C`undef\*(C'\fR means \fI"Don't colorize this"\fR. Otherwise, the color is a string which can be one of the following: .PP \fINamed colors, Term::ANSIColor style (discouraged)\fR .IX Subsection "Named colors, Term::ANSIColor style (discouraged)" .PP Only 8 named colors are supported: .PP black, red, green, yellow, blue, magenta, cyan, white .PP and their \f(CW\*(C`bright_XXX\*(C'\fR, \f(CW\*(C`on_XXX\*(C'\fR and \f(CW\*(C`on_bright_XXX\*(C'\fR variants. .PP Those are provided only as backards compatibility with older versions of Data::Printer and, because of their limitation, we encourage you to try and use one of the other representations. .PP \fISGR Escape code (Terminal style)\fR .IX Subsection "SGR Escape code (Terminal style)" .PP You may provide any SGR escape sequence, and they will be honored as long as you use double quotes (e.g. \f(CW"\ee[38;5;196m"\fR). You may use this to achieve extra control like blinking, etc. Note, however, that some terminals may not support them. .PP \fIAn RGB value in one of those formats (Recommended)\fR .IX Subsection "An RGB value in one of those formats (Recommended)" .PP .Vb 2 \& \*(Aqrgb(0,255,30)\*(Aq \& \*(Aq#00FF3B\*(Aq .Ve .PP \&\fBNOTE:\fR 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. .SH "SEE ALSO" .IX Header "SEE ALSO" Data::Printer