Demo我正在试用 ncurses-5.9 附带的 c++ 绑定(bind)。似乎不容易在屏幕上轻松显示带有窗口的面板。这是我的代码
class SpiderApplication : NCursesApplication
{
protected:
int titlesize() const { return 2; };
void title();
public:
SpiderApplication() : NCursesApplication(TRUE) {}
int run();
};
void SpiderApplication::title()
{
const char * const titleText = "Demo";
const int len = ::strlen(titleText);
titleWindow->bkgd(screen_titles());
titleWindow->addstr(0, (titleWindow->cols() - len) / 2, titleText);
titleWindow->noutrefresh();
}
int SpiderApplication::run()
{
NCursesPanel mystd;
NCursesPanel P(mystd.lines() - titlesize(), mystd.cols(), titlesize() - 1, 0);
P.label("Demo", NULL);
P.show();
::getch();
P.clear();
return 0;
}
我想应该有一个面板显示在这个应用程序的标题行下。然而,事实并非如此。我在这里错过了重要的事情吗?有没有关于如何使用 ncurses 的 c++ 绑定(bind)的示例?
谢谢。
最佳答案
我找到了我自己问题的答案。
要使面板显示在屏幕上,不能省略 refresh()
调用。这是工作代码:
NCursesPanel mystd;
NCursesPanel P(mystd.lines() - titlesize(), mystd.cols(), titlesize() - 1, 0);
P.label("Demo", NULL);
P.show();
mystd.refresh();
::getch();
P.clear();
关于c++ - 如何通过 NCurses 的 C++ 绑定(bind)在屏幕上显示 NCursesPanel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25112116/