1

如何使用 curses 库清除屏幕的前两行?我看到有一个deleteln()命令,但是它只清除光标下的行。

另外,第二个问题,该命令是否clear()清除整个屏幕?

4

2 回答 2

1

parkydr说:“clrtoeol()清除到当前行的末尾。”

这几乎是正确的。clrtoeol()从光标处清除到当前行的末尾。因此,如果您的光标不在行首,则不会清除整行。

这是一个例子:

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
于 2013-12-04T06:12:52.513 回答
1

deleteln()删除该行并将其余文本向上移动。clrtoeol()清除到当前行的末尾。

您需要使用int move(int y, int x)将光标定位在 2 个顶行中的每一行的开头,然后调用clrtoeol().

clear()清除整个窗口

于 2013-05-29T08:54:52.530 回答