1、初始化颜色
//init_pair(short index,short foreground,short background)初始化颜色索引
//attron(COLOR_PAIR(索引号)|属性)
属性如下:
A_NORMAL Normal display (no highlight)
A_STANDOUT Best highlighting mode of the terminal.亮色
A_UNDERLINE Underlining
A_REVERSE Reverse video
A_BLINK Blinking闪烁
A_DIM Half bright半亮度
A_BOLD Extra bright or bold高亮度
A_PROTECT Protected mode
A_INVIS Invisible or blank mode
A_ALTCHARSET Alternate character set另类字符集
A_CHARTEXT Bit-mask to extract a character
2、编译:
1)必须安装cursesew库
sudo apt-get install libncursesw5-dbg libncursesw5-dev
mysea@mysea-desktop:~/test$ gcc -lncursesw -std=c99 -o cursestest cursestest.c
cursestest.c: In function ‘main’:
cursestest.c:12: warning: implicit declaration of function ‘exit’
cursestest.c:12: warning: incompatible implicit declaration of built-in function ‘exit’
mysea@mysea-desktop:~/test$ ./cursestest

3、代码
本文介绍使用C语言和NCurses库进行文本界面颜色及显示属性设置的方法。通过实例演示了如何初始化颜色对、设置文本属性如高亮度、下划线等,并展示了完整的代码实现过程。
3673

被折叠的 条评论
为什么被折叠?



