Question

How do I clear the first two lines of the screen by using the curses library? I see that there is a deleteln() command, however it only clears the line under the cursor.

Also, a second question, does the command clear() clear the whole screen?

Was it helpful?

Solution

deleteln() deletes the line and moves the rest of the text up. clrtoeol() clears to the end of the current line.

You need to use int move(int y, int x) to position the cursor at the start of each of the 2 top lines and then call clrtoeol().

clear() clears the whole window

OTHER TIPS

parkydr Said: "clrtoeol() clears to the end of the current line."

That's almost correct. clrtoeol() clears to the end of the current line from you cursor. So if your cursor isn't at the beginning of the line then it won't clear the entire line.

Here is an example:

int y, x;            // to store where you are
getyx(stdscr, y, x); // save current pos
move(0, 0);          // go to the beginning of the first line
clrtoeol();          // clear the line
move(1, 0);          // go to the beginning of the second line
clrtoeol();          // clear the line
move(y, x);          // move back to where you were
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top