Introducing Text::ANSITable

Even in the good old days of DOS, we already had color tables and extended ASCII characters to draw various border styles. So why limit ourselves with something like Text::ASCIITable? Introducing Text::ANSITable to make your text tables look pretty in terminals. See pictures for some examples:

Features:

  • Drawing borders with box-drawing and Unicode characters.
  • Border styles. You can select and even create your own border styles. Border styles support things like custom characters, etc.
  • Full color support (256 on any xterm-256color terminal emulators, and true color on Konsole/Yakuake). Graceful degradation (autoreduce colors) on terminals that do not support higher color depth.
  • Color themes. You can select and even create your own color themes. Color themes support things like random/custom/gradation colors, etc.
  • Wide character support. Your tables will still be aligned even if your text contains wide characters.
  • ANSI support. Your tables will still be aligned even if your text contains ANSI escape codes.
  • Modular and flexible formatting system for things like text wrapping, highlighting, number formatting (thousands, scientific, kilo/kibi formatting), sprintf-style formatting, etc).
  • Per-column/per-row/per-cell styling
  • Row/column filtering
  • Column reordering.

Compared to Text::ASCIITable, Text::ANSITable uses lowercase_with_underscore for method names instead of CamelCase. I know a lot of Perl programmers, me included, prefer the former.

It's an early release so there are bound to be some quirks and bugs, but the basic features are already there. Enjoy!

11 Comments

I love people who love terminals :)

nice work! it seems to be helpful for my some CLI tools.

Hi, how do I get this installed in my current version of ActivePerl? It does not seem to be included and I am unable to install it by the "ppm" method either. Thanks

Hi again. I can install Unixish in ActivePerl but "ppm install Text-ANSITable" still doesn't work....any workarounds? Thanks

Thanks Steven. The tarball compile ok in ActivePerl. I have issues in my perl console that keep saying it cannot find Log/Any.pm in @Inc and compilation aborted at the line when I load the Ansitable via "use Text::ANSITable;".

In c:\Perl64\lib\Text folder I have "ANSITable.pm".

In the c:\Perl64\lib\Text\ANSITable folder I have
"BorderStyle", "ColorTheme" and "StyleSet" folder and each of these folders contain their respective *.pm libraries.

Any ideas why Perl is making this complain?

Thanks again

It would appear Log::Any is already installed in ActivePerl but I run the ppm install method again....but I am unable to get pass the compilation error when Perl tries to load the ANSITable library....anymore suggestions?

Leave a comment

About Steven Haryanto

user-pic A programmer (mostly Perl 5 nowadays). My CPAN ID: SHARYANTO. I'm sedusedan on perlmonks. My twitter is stevenharyanto (but I don't tweet much). Follow me on github: sharyanto.