NCURSES刷新 [英] NCurses Refresh

查看:404
本文介绍了NCURSES刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小ncurse节目我跑,但输出似乎并没有显示出来,除非我坚持了 wrefresh()在一个while循环。

有一些缓冲的事或东西吗?我试过其他刷新中的库函数和 fflush stddout (我不认为是有道理的,但值得一试),但似乎没有任何工作。

一个第二个小问题:使残培()非阻塞我们需要调用 NODELAY(赢,TRUE),对吧?



无效的主要()
{
        initscr的();
        start_color();
        init_pair(1,COLOR_YELLOW,COLOR_CYAN);
        WINDOW *赢=为newwin(10,10,1,1);
        wbkgd(赢,COLOR_PAIR(1));
        wprintw(赢了,你好,世界);
        wrefresh(赢);
        残培();
        公司的尼克戴尔文(胜利);
        endwin();
}


解决方案

您不应该在 stdscr上混合操作和为newwin创建的窗口()残培()运行在 stdscr上,所以这是你的问题。与替换调用

  wgetch(胜利);

残培()引起 stdscr上来倾倒在你的其他窗口的顶部,因为如此之快,它看起来像从未被显示在所有其他窗口)。

I have a small ncurse program I'm running, but the output doesn't seem to show up unless I stick the wrefresh() in a while loop.

Is there some buffering going on or something? I tried other refresh functions in the library and fflush with stddout (which I don't think makes sense, but worth a try), but nothing seems to work.

A second small question: to make getch() non-blocking we need to call nodelay(win,TRUE), right?


void main()
{
        initscr();
        start_color();
        init_pair(1,COLOR_YELLOW,COLOR_CYAN);
        WINDOW *win = newwin(10,10,1,1);
        wbkgd(win,COLOR_PAIR(1));
        wprintw(win,"Hello, World.");
        wrefresh(win);
        getch();
        delwin(win);
        endwin();
}

解决方案

You are not supposed to mix operations on stdscr and windows created with newwin(). getch() operates on stdscr, so that is your problem. Replace that call with

wgetch(win);

(getch() is causing stdscr to be dumped over the top of your other window, and because that happens so quickly it looks like the other window never got displayed at all).

这篇关于NCURSES刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆