ascii-table
ascii-table copied to clipboard
Support question, handling spillover
With a table like so:

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!
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
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
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 :/
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.
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.
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?
You know what would be really useful, is row color alternation, using ansi control chars
any word on this bird? still looking for this feature