18

How to clear a specific line with NCurses?

I need to wipe a line on the screen without redrawing the whole thing. How do I do that?

Kristina Brooks
  • 15,329
  • 28
  • 106
  • 178

4 Answers4

25

You can position on the line you want to clear and then call clrtoeol function.

Pablo Santa Cruz
  • 170,119
  • 31
  • 233
  • 283
22

This is how I ended up doing it for my purposes.

int y, x;            // to store where you are
getyx(stdscr, y, x); // save current pos
move(y, 0);          // move to begining of line
clrtoeol();          // clear line
move(y, x);          // move back to where you were
BReynolds
  • 332
  • 2
  • 8
  • any chance you know how to do this in vertical scope? meaning clear all lines until last line – serup Sep 28 '16 at 09:52
3

maybe crltoeol would do the trick

Pierre Lacave
  • 2,500
  • 2
  • 18
  • 28
0

If you want to clear all lines from the cursor until the last line, you can call clrtobot()

adiga
  • 31,610
  • 8
  • 53
  • 74
Scienziatogm
  • 53
  • 1
  • 6