Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Console overwriting like top

Tags:

c++

c

linux

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.

like image 637
csteifel Avatar asked Jan 18 '12 02:01

csteifel


1 Answers

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.

like image 76
Ben Voigt Avatar answered Sep 30 '22 09:09

Ben Voigt