Open mikkergimenez opened 9 years ago
colors are tricky =\ The problem is, we need to do two things: count the string length, and truncate long strings. The string length calculator is naively counting nonprinting characters, and the truncation naively cuts off any nonprinting characters after the truncation point.
Honestly it's going to be a while before I would get to this, but if you want to poke around here's where to start:
truncation - https://github.com/arches/table_print/blob/master/lib/table_print/formatter.rb#L33-L40 width detection - https://github.com/arches/table_print/blob/master/lib/table_print/column.rb#L36-L48
You'll note in the width detection there's a multibyte approach and a naive approach - multibyte counting is much slower so it's off by default.
👍
👍 #70
It seems whenever I use colors, it truncates the column width and causes weird readability issues:
For the following example I used: https://github.com/janlelis/paint
Example:
As you (might) be able to see, column e and f resized to four characters, they were the ones that I colorized.
When I try to colorize C and D, it gets even weirder, removing some columns and inserting special characters.
I assume it has something to do with the way table_print encodes the special table characters, but not sure.