p-ranav / tabulate

Table Maker for Modern C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question - Dynamically Change the tables Content

mohsenomidi opened this issue · comments

Dear Contributors,

Thanks for your useful library, I am trying to use this table objects in real-time terminal application and show the columns contents dynamically, when they changed, for example during the execution the contents of tables needs to change (like top command it refreshed the generated output), is it possible to do it ?

Thanks :)

You can certainly change the contents of individual cells in the table.

To refresh the generated output, you would need to do the following:

  1. Go up one line in the terminal and clear the line (you can do this with ANSI escape sequences)
  2. Repeat 1 for the height of the table.
  3. Print the table again.

Do the above steps to "refresh" the output.

tabulate provides an API to get the width and height of the table. You can use this in combination with ANSI escape sequences to achieve this effect.

Related to #27

Thank you so much, will try and share the example as a PR for other people if you interested in 🙏

Definitely would be interested in a sample that can demonstrate refreshing a table. Thanks!

Done with PR #54