Reputation: 2934
Ok so I was just wondering how console applications like top(1)
for linux overwrite multiple lines. I want to know how to do it for C++ or C. I know how to overwrite 1 line by just putting a \r but I wanted to know how to do so for multiple lines, again like in top or if its even possible.
Upvotes: 5
Views: 534
Reputation: 7421
This may not directly address the question, but this sort of thing is dependent on the terminal and is commonly done with a curses implementation (ncurses is the most widely used).
Upvotes: 2
Reputation: 283684
They use terminal escape sequences to move the cursor around the screen. A few even use direct framebuffer access, to treat the screen as an array of characters which can be directly indexed.
The curses
(or ncurses
) library is a good abstraction layer.
Upvotes: 3