Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colors truncate column width #69

Open
mikkergimenez opened this issue Aug 4, 2015 · 3 comments · May be fixed by #70
Open

Colors truncate column width #69

mikkergimenez opened this issue Aug 4, 2015 · 3 comments · May be fixed by #70

Comments

@mikkergimenez
Copy link

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:

AAAAAAA                     | BBBBBBBBBBBB          | CCCCCC                 | DDDDDD                         | EEEEEEE        | FFFFFFFF
----------------------------|-----------------------|-----------------------|--------------------------------|----------------|---------------
aaaaaaaa_aaaaaaa_aaaaaaaaaa | b/b                   | c/c                   | d/d                            | eeee  | ffff
aaaaa_aaaaaaa-aaaaaaaaaa-aa | b                     | c                     | ddd                            | eeee | ffff

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.

@arches
Copy link
Owner

arches commented Aug 6, 2015

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.

ghost pushed a commit to Altiscale/table_print that referenced this issue Oct 1, 2015
@ghost ghost linked a pull request Oct 2, 2015 that will close this issue
@pablofullana
Copy link

👍

@k-ta-yamada
Copy link

k-ta-yamada commented Jan 27, 2018

👍 #70

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants