ascii-table icon indicating copy to clipboard operation
ascii-table copied to clipboard

Support question, handling spillover

Open ORESoftware opened this issue 8 years ago • 8 comments

With a table like so:

screenshot 2016-04-09 17 46 44

How can I handle spillover in the "Notes" column. Can this lib handle when a row is more than 1 line? I just tried some newline chars and yeah it doesn't work. Any advice on how to handle rows that have multiple lines of text? Thanks for your help!

ORESoftware avatar Apr 10 '16 00:04 ORESoftware

Just to illustrate, the notes column code be arbitrarily wide, depending on user input

https://www.dropbox.com/s/n109kz2v2frhpfu/Screenshot%202016-04-09%2017.50.31.png?dl=0

ORESoftware avatar Apr 10 '16 00:04 ORESoftware

I am not sure how to handle this, the library does not have any notion of character width. You can pre-format the inputted string to be word-wrapped, but otherwise, this library cannot do this for you.

This has been suggested by others as well, I just have not implemented such feature. I would likely implement this using https://www.npmjs.com/package/wordwrap

sorensen avatar Apr 10 '16 01:04 sorensen

yeah, I was looking at gajus/table and he seems to have implemented using wordwrap. But the one thing is that his project does not have table titles

https://github.com/gajus/table/issues/12

which is unfortunate :/

ORESoftware avatar Apr 10 '16 03:04 ORESoftware

What would you envision the configuration of column width to be? Are you wanting to set an overall width of the table, or a per-column width? I am am looking at adding support for this, would like some input on how you would like to use this.

sorensen avatar Apr 11 '16 20:04 sorensen

Hmmm, here's how I would do it, to keep it simple, but this might not be feasible as I don't really know how you have implemented the code.

For each column the user decides whether to allow spillover (multi-line) or not, so this is a boolean value for each column which defaults to "no-spillover".

If the user sets spillover to true for a particular column, the user probably needs to also select a fixed width in the form of string length.

A nice to have would be to have all columns auto-spill IFF the table width is greater than the max width of the table which the user provides.

ORESoftware avatar Apr 11 '16 20:04 ORESoftware

I'm going to think about this for a bit, I think a width would imply a word-wrap, but it could be that you want the string truncated? Not sure what the best approach would be for this library, I am in favor of defaulting to word-wrap if any kind of fixed-width is given, what do you think?

sorensen avatar Apr 11 '16 21:04 sorensen

You know what would be really useful, is row color alternation, using ansi control chars

ORESoftware avatar Apr 14 '16 07:04 ORESoftware

any word on this bird? still looking for this feature

ORESoftware avatar Sep 05 '18 23:09 ORESoftware