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

Support AutoWidth #27

Open
Barbatruuk opened this issue May 23, 2018 · 5 comments
Open

Support AutoWidth #27

Barbatruuk opened this issue May 23, 2018 · 5 comments

Comments

@Barbatruuk
Copy link

I'd like to have an option to have each cellwidth calculated according to the added values (never wrap), so I'd get for instance;

|subject         |date       |name                                 |
|sbj             |2018-01-01 |a very very very very very long name |
|another subject |2018-01-01 |shortname                            |

Instead of the equal distribution according to the set width.

@dandrei
Copy link

dandrei commented Jun 12, 2018

Excellent idea. The width of a column should depend on the longest string in that column.

@haukee
Copy link

haukee commented Jun 16, 2018

This can be done via
AsciiTable.getRenderer().setCWC(AT_ColumnWidthCalculator)

The Behaviour you want can be achieved by using
CWC_LongestLine
I think.

Note that you seem to have to set the CWC right before rendering (= after adding content).

Also see here:
http://www.vandermeer.de/projects/skb/java/asciitable/examples/AT_07c_LongestLine.html

@zenglian
Copy link

CWC_LongestLine is good, shouldn't it be default behavior?

@javadba
Copy link

javadba commented Jan 24, 2019

This should be default behavior IMO. btw the Link shown by haukee does not include the code shown in the same post.

@javadba
Copy link

javadba commented Jan 24, 2019

The following works:

t.getRenderer().setCWC(new CWC_LongestLine())

This project would benefit from better out-of-the-box functionality like this: I was about to dump it: but with this it is useful.

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

No branches or pull requests

5 participants