home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.wwiv.com
/
ftp.wwiv.com.zip
/
ftp.wwiv.com
/
pub
/
BBS
/
SENDCOM_.ZIP
/
PCBCOLOR.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1991-10-14
|
2KB
|
70 lines
#include <string.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include "pcbcolor.h"
int ANSI;
int A_CLR[]={0,4,2,6,1,5,3,7,0,4};
char *make_ansi_str(char *pcbcode){
int fore,back,bmode,fmode;
static char buffer[20];
back=*pcbcode;
pcbcode++;
fore=*pcbcode;
if(back > '9'){ back-=15; bmode=A_BLINK;}
else bmode=A_NORMAL;
if(fore > '9'){ fore-=15; fmode=A_BOLD;}
else fmode=A_NORMAL;
fore-=48;
back-=48;
if(bmode<fmode) /* If background mode is less then its normal */
sprintf(buffer,"\33[%d;%d;3%d;4%dm",bmode,fmode,A_CLR[fore],A_CLR[back]);
else
sprintf(buffer,"\33[%d;%d;3%d;4%dm",fmode,bmode,A_CLR[fore],A_CLR[back]);
return(buffer);
}
char *pcb_printf(char *str){
int i;
static char buffer[255];
char *ptr,*ansi_str;
memset(buffer,'\0',255);
ptr=buffer;
while(*str!='\0'){
if(*str=='@'){
str++;
if(ANSI==YES){
if(*str=='X'){
str++;
ansi_str=make_ansi_str(str);
for(i=0;i<12;i++){
*ptr=*ansi_str;
ansi_str++;
ptr++;}
str++;
str++;
} else {
*ptr='@';
ptr++;
*ptr=*str;}
} else {
if(*str=='X'){
str++;
str++;
str++;
} else {
*ptr='@';
ptr++;
*ptr=*str;}
}
}
*ptr=*str;
ptr++;
str++;}
printf("%s",buffer);
return(buffer);
}