piotrmurach / tty

Toolkit for developing sleek command line apps.
https://ttytoolkit.org
MIT License
2.51k stars 79 forks source link

tables do not handle colored strings #16

Closed wwboynton closed 9 years ago

wwboynton commented 9 years ago

When printing a table, the ANSI escape sequences factor into the column width detection, so columns with colored fields are significantly wider than they appear to need to be.

I tried patching the length function in TTY::Table::Field to strip color codes before length detection, which corrected the top borders. However, the rows including coloring still wouldn't pad correctly. screen shot 2015-01-30 at 4 30 54 pm

Is there some other way to do this? If not, I'll keep poking through for the function which pads the fields and submit a pull request if I fix it.

piotrmurach commented 9 years ago

Hi Wesley,

The colouring of content and borders is something I was meant to do but have never added. I remember I had discussion with yourself about tables rendering some time ago and I still intend to deliver on the promises and extract the library. I had a bad patch of bronchitis that kind of sapped my energy levels(excuses :smile: )

I would really appreciate your help figuring out the code needed to get this done and submitting PR.

piotrmurach commented 9 years ago

@wwboynton I've released tty-table which has been revamped - removed some code bloat and dependencies. Going forward I will work on and would encourage you to fork the https://github.com/peter-murach/tty-table if you wish to submit PRs. Next step is to fix all the issues from the tty repository including colouring of content and borders.

piotrmurach commented 9 years ago

Finally fixed and released as tty-table v0.2.0! see