日期:2014-05-16  浏览次数:20683 次

linux-c-curses(1)-颜色+中文

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

2)编译

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、代码

#include <ncursesw/ncurses.h>
#include <locale.h>
int main(void){
//init_pair(short index,short foreground,short background)