olekukonko / tablewriter

ASCII table in golang
MIT License
4.29k stars 367 forks source link

How to get the table rows? #191

Open WestleyK opened 3 years ago

WestleyK commented 3 years ago

It would be nice to have a function like:

rows := table.Rows()
fmt.Printf("ROWS=%d\n", rows) // prints the number of rows in the table (including any newlines that the table adds)

I need this function because I have my table rewrite itself, and I need to set the cursor to the correct height, otherwise it wont update correctly.

I can manually count the rows when I append data, but this will only work if the table does not automatically add newlines (and I want the newlines).

EDIT: I see that there is NumLines(), but that does not account for the newlines that the table automatically puts there.

olekukonko commented 1 year ago

are you saying the number of new lines is not predictable?