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 >
C/C++ Source or Header  |  1991-10-14  |  2KB  |  70 lines

  1. #include <string.h>
  2. #include <conio.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. #include "pcbcolor.h"
  7.  
  8. int ANSI;
  9. int    A_CLR[]={0,4,2,6,1,5,3,7,0,4};
  10.  
  11. char *make_ansi_str(char *pcbcode){
  12.         int fore,back,bmode,fmode;
  13.         static char buffer[20];
  14.         back=*pcbcode;
  15.         pcbcode++;
  16.         fore=*pcbcode;
  17.         if(back > '9'){ back-=15; bmode=A_BLINK;}
  18.         else bmode=A_NORMAL;
  19.         if(fore > '9'){ fore-=15; fmode=A_BOLD;}
  20.         else fmode=A_NORMAL;
  21.         fore-=48;
  22.         back-=48;
  23.         if(bmode<fmode) /* If background mode is less then its normal */
  24.                 sprintf(buffer,"\33[%d;%d;3%d;4%dm",bmode,fmode,A_CLR[fore],A_CLR[back]);
  25.         else
  26.                 sprintf(buffer,"\33[%d;%d;3%d;4%dm",fmode,bmode,A_CLR[fore],A_CLR[back]);
  27.         return(buffer);
  28. }
  29.  
  30. char *pcb_printf(char *str){
  31.         int i;
  32.         static char buffer[255];
  33.         char *ptr,*ansi_str;
  34.         memset(buffer,'\0',255);
  35.         ptr=buffer;
  36.         while(*str!='\0'){
  37.                 if(*str=='@'){
  38.                         str++;
  39.                         if(ANSI==YES){
  40.                                 if(*str=='X'){
  41.                                         str++;
  42.                                         ansi_str=make_ansi_str(str);
  43.                                         for(i=0;i<12;i++){
  44.                                                 *ptr=*ansi_str;
  45.                                                 ansi_str++;
  46.                                                 ptr++;}
  47.                                         str++;
  48.                                         str++;
  49.                                 } else {
  50.                                         *ptr='@';
  51.                                         ptr++;
  52.                                         *ptr=*str;}
  53.                         } else {
  54.                                 if(*str=='X'){
  55.                                         str++;
  56.                                         str++;
  57.                                         str++;
  58.                                 } else {
  59.                                         *ptr='@';
  60.                                         ptr++;
  61.                                         *ptr=*str;}
  62.                         }
  63.                 }
  64.                 *ptr=*str;
  65.                 ptr++;
  66.                 str++;}
  67.         printf("%s",buffer);
  68.         return(buffer);
  69. }
  70.