nim-terminaltables icon indicating copy to clipboard operation
nim-terminaltables copied to clipboard

Custom style is defined with strings, but expects fields to be 1 character long

Open PMunch opened this issue 6 years ago • 4 comments

I wanted to create a style without any lines, to simply pad the data to a tabular form. When I set all the elements of a Style to be empty strings, it still occupies space. And when trying to add two characters for one of the styles it did weird things with the table.

PMunch avatar Jun 03 '19 12:06 PMunch

Hi @PMunch. the problem is the padding in defined in the column


  let testStyleEmpty = Style(rowSeparator:"", colSeparator:"", cellEdgeLeft:"", cellEdgeRight:"", topLeft:"", topRight:"", bottomLeft:"", bottomRight:"", topRowSeparator:"", bottomRowSeparator:"", dashLineLeft:"", dashLineRight:"", dashLineColSeparatorLastRow:"", dashLineColSeparatorTopRow:"", dashLineColSeparator:"")
  t2.style = testStyleEmpty
  printTable(t2)
  
  t2.setHeaders(@[newCell("ID", pad=0), newCell("Name", pad=0), newCell("Fav animal", pad=0), newCell("Date", 0)])

  printTable(t2)

Here's an example of the output Screenshot from 2019-06-03 14-33-37

And when trying to add two characters for one of the styles it did weird things with the table.

I'm not sure that I understand this one. Would you be so kind to add an example?

xmonader avatar Jun 03 '19 12:06 xmonader

Aha, I see. For the two characters thing I just took the style example and put two characters in for colSeparator like this: http://ix.io/1KO5

PMunch avatar Jun 03 '19 12:06 PMunch

I see the problem now, It used to be char when it was ascii type only. I clearly need to think about the representation maybe Rune would be a better choice.

xmonader avatar Jun 03 '19 13:06 xmonader

Hmm, that's a good point. Didn't think of the UTF-8 issues with that. Well Rune is certainly an option, but they're a bit clumsy to work with aren't they? If you do go with Rune please add a convenience proc to create a style.

PMunch avatar Jun 03 '19 13:06 PMunch