Category : C Source Code
Archive   : ANSITC.ZIP
Filename : ANSI.C

 
Output of file : ANSI.C contained in archive : ANSITC.ZIP
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* ANSI Generator Function - This function will return the ANSI */
/* color codes for the foreground and background colors passed as */
/* paramaters. The forground and background colors are in the */
/* range of: */
/* FOREGROUND BACKGROUND */
/* 0 = black 0 = black */
/* 1 = blue 1 = blue */
/* 2 = green 2 = green */
/* 3 = cyan 3 = cyan */
/* 4 = red 4 = red */
/* 5 = magenta 5 = magenta */
/* 6 = brown 6 = brown */
/* 7 = grey 7 = grey */
/* 8 = light grey */
/* 9 = light blue */
/* 10 = light green */
/* 11 = light cyan */
/* 12 = light red */
/* 13 = light magenta */
/* 14 = yellow */
/* 15 = white */
/* 16 = blink on */
/* 17 = blink off */

void SET_COLOR(int foreground,int background, char string[])
{
switch(background)
{
case 0:
strcpy(string,"\x1b[40m");
break;
case 1:
strcpy(string,"\x1b[44m");
break;
case 2:
strcpy(string,"\x1b[42m");
break;
case 3:
strcpy(string,"\x1b[46m");
break;
case 4:
strcpy(string,"\x1b[41m");
break;
case 5:
strcpy(string,"\x1b[45m");
break;
case 6:
strcpy(string,"\x1b[43m");
break;
case 7:
strcpy(string,"\x1b[47m");
break;
default:break;
}

switch(foreground)
{
case 0:
strcat(string,"\x1b[30m");
break;
case 1:
strcat(string,"\x1b[34m");
break;
case 2:
strcat(string,"\x1b[32m");
break;
case 3:
strcat(string,"\x1b[36m");
break;
case 4:
strcat(string,"\x1b[31m");
break;
case 5:
strcat(string,"\x1b[35m");
break;
case 6:
strcat(string,"\x1b[33m");
break;
case 7:
strcat(string,"\x1b[37m");
break;
case 8:
strcat(string,"\x1b[1;30m");
break;
case 9:
strcat(string,"\x1b[1;34m");
break;
case 10:
strcat(string,"\x1b[1;32m");
break;
case 11:
strcat(string,"\x1b[1;36m");
break;
case 12:
strcat(string,"\x1b[1;31m");
break;
case 13:
strcat(string,"\x1b[1;35m");
break;
case 14:
strcat(string,"\x1b[1;33m");
break;
case 15:
strcat(string,"\x1b[1;37m");
break;
case 16:
strcat(string,"\x1b[5");
break;
case 17:
strcat(string,"\x1b[0");
break;
default:break;
}
}


  3 Responses to “Category : C Source Code
Archive   : ANSITC.ZIP
Filename : ANSI.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/