I am writing application in C programming language that enables to monitor remote computers system information, number of logged users, free memory and so on.
I will write gathered info to standard output. But usually there will be more information then one single window of terminal, so I will need to implement some sort of ‘scrolling’ through results.
The easiest solution is I think to print for example first 25 rows, and then wait for user to push up or down and rewrite all rows accordingly.
Is there some easier/more elegant way to handle such output on terminal?
EDIT: forgot to mention, I would like to refresh the data if some new input comes from some remote computer, for example: number of processes changes.
Sounds like you need curses.
Here’s a guide to the
ncurseslibrary.It’s an old school GUI library for terminals. Things like
topandmake menuconfiguse it, so it’s on every system. It allows you to stop thinking in terms of “print 25 lines and refresh” and more in terms of “put data in the text area which is scrollable”.