如何通过NCurses的c ++绑定在屏幕上显示NCursesPanel

时间:2014-08-04 05:12:45

标签: c++ ncurses

Demo我正在尝试ncurses-5.9附带的c ++绑定。看起来很容易在屏幕上显示带有窗口的面板。这是我的代码

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 ++绑定的例子?

感谢。

1 个答案:

答案 0 :(得分:0)

我找到了自己问题的答案。

要在屏幕上显示面板,refresh()来电不能省略。这是工作代码:

NCursesPanel mystd;
NCursesPanel P(mystd.lines() - titlesize(), mystd.cols(), titlesize() - 1, 0);
P.label("Demo", NULL);
P.show();
mystd.refresh();
::getch();
P.clear();