无法用NCurses更改终端背景
Unable to change terminal background with NCurses
好的,所以我试图用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;
}
相关文章:
- 如何在linux终端中同时编译和运行c++代码
- 如何在全屏模式下(在OpenGL中)使背景透明
- 终端不会为C++文件创建.exe文件吗
- 如何处理linux终端中带有负号(-)的C++中的命令行参数
- VS Code "command":"make"与终端窗口中的命令行"make"不同
- 使用窗口中的QSlider更改背景音量
- 使用 cmake 的 Linux 终端上的"Conversion to non-scalar type is requested"错误
- 用于窗口的 HID 终端
- 使用 ubuntu 终端在 c++ 上运行线程类的问题
- SDL2 透明背景
- 写入文件 a.txt,而终端重定向到文件 b.txt
- VSCode C++终端进程已终止,退出代码为:1
- 终端如何在 shell 提示符下以编程方式阻止退格,以便您无法在其上退格,例如 $ 表示 bash 或 C:\blah\>
- Mac os x app bundle 在下载并运行时崩溃,但在终端或更改 Info.plist 时运行良好
- C printf 无法从终端按预期工作
- 如何在不丢失输出的情况下杀死/停止终端中正在运行的进程?
- 在 OSX 上打开 SDL 窗口时不要打开终端窗口
- 在终端中运行可执行文件与在Mac查找器中打开
- 从 GUI 文件资源管理器执行程序,并且不生成终端
- 无法用NCurses更改终端背景