在 ncurses 上重绘
我正在尝试重绘一个简单循环的内容。到目前为止,它打印到 stdscr
100 行,然后使用 scrl
滚动 n 行,我得到 n 空白行。
我想要的是保持顺序。但是,我不确定如何用 n 条额外的行重新绘制 stdscr
。任何想法将不胜感激!
#include <ncurses.h>
int main(void)
{
initscr();
int maxy,maxx,y;
getmaxyx(stdscr,maxy,maxx);
scrollok(stdscr,TRUE);
for(y=0;y<=100;y++)
mvprintw(y,0,"This is some text written to line %d.",y);
refresh();
getch();
scrl(5);
refresh();
getch();
endwin();
return(0);
}
I'm trying to redraw the content of a simple loop. So far it prints out to the stdscr
100 lines, and then by using scrl
to scroll n lines I get n blank rows.
What I want is to keep with the sequence. However, I'm not sure how to redraw the stdscr
with the n extra lines. Any ideas will be appreciate it!
#include <ncurses.h>
int main(void)
{
initscr();
int maxy,maxx,y;
getmaxyx(stdscr,maxy,maxx);
scrollok(stdscr,TRUE);
for(y=0;y<=100;y++)
mvprintw(y,0,"This is some text written to line %d.",y);
refresh();
getch();
scrl(5);
refresh();
getch();
endwin();
return(0);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据推测,在
scrl()
之后的refresh()
之后,添加以下行:当然,我正在使用幻数。你应该使用类似的东西:
那么循环是:
如果你需要一遍又一遍地重复这个过程,那么计算就变成:
等等......
(代码未经测试 - 当心错误。)
Presumably, after the
refresh()
afterscrl()
, add the lines:I'm using magic numbers, of course. You should use something like:
Then the loop is:
And if you need to repeat the process over, and over, then the calculation becomes:
Etcetera...
(Code untested - beware bugs.)