无法用NCurses更改终端背景

  • 本文关键字:终端 背景 NCurses c++
  • 更新时间 :
  • 英文 :


好的,所以我试图用c++的NCurses库改变终端背景。

下面是我的代码:
int ncurses_test()
{
     initscr();
     start_color();
     init_pair(1, COLOR_GREEN, COLOR_BLACK);
     init_pair(2, COLOR_GREEN, COLOR_BLACK);
     init_pair(3,COLOR_BLUE, COLOR_RED);
     wbkgd(WINDOW,COLOR_PAIR(3))
     noecho();
     raw();
     int c;
     attron(COLOR_PAIR(1));
     printw("Write something [ESC to escape]: ");
     while((c=getch())!=27)
     {
            move(10,0);
            attron(COLOR_PAIR(1));
            printw("Keycode: %d, and the chracter: %c",c,c);
            move(0,0);
            attron(COLOR_PAIR(1));
            printw("Write something [ESC to escape]: ");
            refresh();
     }
     endwin();
     return 0;
}

我在编译文件时得到一个错误。下面是错误:

main.cpp: In function 'int ncurses_test()':
main.cpp:27:18: error: expected primary-expression before ',' token
      wbkgd(WINDOW,COLOR_PAIR(3))

有人有什么想法吗?

好的,我设法让我的代码工作:

int ncurses_test()
{
     initscr();
     start_color();
     init_pair(1, COLOR_GREEN, COLOR_BLACK);
     init_pair(2, COLOR_GREEN, COLOR_BLACK);
     init_pair(3, COLOR_BLACK, COLOR_BLUE);
     init_pair(4, COLOR_BLACK, COLOR_WHITE);
     noecho();
     WINDOW *win = newwin(10, 10, 10, 10);
     wbkgd(stdscr, COLOR_PAIR(3));
     wbkgd(win, COLOR_PAIR(4));
     refresh();
     wrefresh(win);
     raw();
     int c;
     attron(COLOR_PAIR(1));
     printw("Write something [ESC to escape]: ");
     while((c=getch())!=27)
     {
            move(10,0);
            attron(COLOR_PAIR(1));
            printw("Keycode: %d, and the chracter: %c",c,c);
            move(0,0);
            attron(COLOR_PAIR(1));
            printw("Write something [ESC to escape]: ");
            refresh();
     }
     endwin();
     return 0;
}

最新更新