简介
ncurse 是跨平台字符终端的图形化库, 这次我们使用mingw在两个平台上进行使用
window11 intel芯
debian arm64 树莓派3B+
步骤
CONFIG += c++17
INCLUDEPATH += E:/curse_test/include
LIBS += -LE:/curse_test/lib -llibncursesw.dll -llibpanelw.dll -llibmenuw.dll -llibformw.dll
SOURCES += \
main.cpp
main.cpp
#include <ncursesw/ncurses.h>
int main()
{
int ch;
// 初始化ncurses
initscr();
// 检查是否支持颜色
if(has_colors() == FALSE)
{
endwin();
printf("Your terminal does not support color\n");
return 1;
}
// 启动颜色
start_color();
// 定义一些颜色对
init_pair(1, COLOR_RED, COLOR_BLACK);
// 将标准颜色对设置为我们定义的颜色对
attron(COLOR_PAIR(1));
// 定位光标到窗口的中间
int width = 80;
int height = 24;
int x = (width - 11) / 2; // "Hello, World!" 长度为11
int y = (height - 1) / 2;
mvprintw(y, x, "Hello, World!");
// 刷新屏幕以显示更新
refresh();
// 等待用户按键
ch = getch();
// 结束ncurses会话并恢复终端到原来的状态
endwin();
return 0;
}
-
编译目录添加dll
-
运行结果