GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Data::Printer::Theme(3) User Contributed Perl Documentation Data::Printer::Theme(3)

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

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

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 (the default)
  • Monokai
  • Solarized
  • Classic (original pre-1.0 colors)

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

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

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:

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.

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.

Data::Printer
2021-02-24 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.