|
楼主 |
发表于 2003-5-26 20:29:49
|
显示全部楼层
写个程序验证一下:- #include <stdio.h>
- #include "ansi.h"
- int
- main(void)
- {
- char *fg[] = {BLK, RED, GRN, YEL, BLU, MAG, CYN, WHT,
- HIR, HIG, HIY, HIB, HIM, HIC, HIW};
- char *bg[] = {HBRED, HBGRN, HBYEL, HBBLU, HBMAG, HBCYN, HBWHT,
- BBLK, BRED, BGRN, BYEL, BBLU, BMAG, BCYN};
- const int nfg = 15, nbg = 14;
- int i, j;
- for(i = 0; i < nfg; i++){
- printf(fg[i]);
- for(j = 0; j < nbg; j++){
- printf(bg[j]);
- printf(" xxx ");
- }
- printf(NOR"\n");
- }
- printf(NOR);
- exit(0);
- }
复制代码 那个运行后显示终端只支持一半的颜色(看看效果就知道了),上网搜了一下,说支持前景编号 (30-37) 和背景编号 (40-47),其他资料还没找到,我大概看了一下ls的代码,它的颜色显示也是用这种方法,大家可以看看printenv里显示的LS_COLORS环境变量。 |
|