logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Data::Printer::Theme - create your own color themes for DDP!

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 :)

   CustomizingColors
       Setting  any color to "undef" means "Don'tcolorizethis".  Otherwise, the color is a string which can be
       one of the following:

       Namedcolors,Term::ANSIColorstyle(discouraged)

       Only 8 named colors are supported:

       black, red, green, yellow, blue, magenta, cyan, white

       and their "bright_XXX", "on_XXX" and "on_bright_XXX" variants.

       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.

       SGREscapecode(Terminalstyle)

       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.

       AnRGBvalueinoneofthoseformats(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.

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.

       Data::Printer comes with several themes for you to choose from:

       •   Material (thedefault)

       •   Monokai

       •   Solarized

       •   Classic (originalpre-1.0colors)

       Run "examples/try_me.pl" to see them in action on your own terminal!

Name

       Data::Printer::Theme - create your own color themes for DDP!

See Also

       Data::Printer

perl v5.38.2                                       2024-04-27                          Data::Printer::Theme(3pm)

Synopsis

           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';

See Also