Sign in to PrePAN

Text::ANSI::Printf printf function for string with ANSI sequence



use Text::ANSI::Printf;
Text::ANSI::Printf::printf FORMAT, LIST
Text::ANSI::Printf::sprintf FORMAT, LIST

use Text::ANSI::Printf qw(ansi_printf ansi_sprintf);
ansi_printf FORMAT, LIST
ansi_sprintf FORMAT, LIST


Text::ANSI::Printf is a almost-printf-compatible library with a capability of handling string with ANSI terminal sequences, as well as multi-byte wide characters.

This is just a quick hack using existing modules, Text::VisualPrintf and Text::ANSI::Fold::Util. Not tuned for performance. Most of complicated work is done in Text::ANSI::Fold module.

INSTALL: cpanm


Can you give some examples? Even looking at the unit tests didn't help much.
How about to see what happens if you use normal sprintf instead of ansi_printf.

> perl -pe 's/ansi_// if /^is/' t/02_export.t | perl -Ilib -
Another good example is App::ansicolumn (
Try something like this:
$ ls -1 | column
$ ls -1 --color=always | column
$ ls -1 --color=always | ansicolumn
Need to install another prepan module just to see how this one works? Giving up.
Running test code with normal `sprintf' didn't work for you?
I think it explains the function well.
It is better to get similar output for succeeded code, but I don't know the way.

Also, you don't have to run 'ansicolumn' to know how it works because it works just as you expect.

Please sign up to post a review.