Alexandre Salconi-Denis / debug_addon_graphique_ASCII
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers AnsiGraphicalConsole.cpp Source File

AnsiGraphicalConsole.cpp

00001 #include "AnsiGraphicalConsole.h"
00002 //#include "debug.h"
00003 #include <stdarg.h>
00004 #include <stdio.h>
00005 
00006 void createSLbox(int posX, int posY, int height, int width,const char* title)
00007 {
00008     //PATCH
00009     posX++;
00010     posY++;
00011     //
00012     
00013     
00014     debug("\x1B[%i;%iH",posY,posX);
00015     debug("\u00DA");//┌
00016     for(int i=0; i <= (width-2); i++) debug("\u00C4");//─
00017     debug("\u00BF");//┐
00018     
00019     #ifdef CONSOLE_DELAY_TEST
00020     wait(5);
00021     #endif
00022     
00023     if(title != 0)
00024     {
00025         char buffer[10];
00026         int leight=  sprintf(buffer,"%s",title);
00027             
00028         debug("\x1B[%i;%iH",posY+2,posX);
00029             debug("\u00C3");//├
00030         for(int i=0; i <= (leight+2); i++) debug("\u00C4");//─   
00031             debug("\u00D9");//┘
00032             
00033         debug("\x1B[%i;%iH",posY,posX+2+leight+2);
00034             debug("\u00C2");//┬
00035          debug("\x1B[%i;%iH",posY+1,posX+2+leight+2);
00036             debug("\u00B3");//│
00037                 
00038         if(leight < width) // si le nom est plus petit que la box tu lafiche 
00039         {
00040          debug("\x1B[%i;%iH",posY+1,posX+2);
00041          debug("%s",title);//1 est la pour patcher le multiple instance problem 
00042         }
00043     }
00044     
00045     #ifdef CONSOLE_DELAY_TEST
00046     wait(5);
00047     #endif
00048            
00049     for(int i = 1;i <= (height-2);i++){
00050     debug("\x1B[%i;%iH",posY+i,posX);//debug("\x1B[%i;%iH",posX,posY+i);
00051             debug("\u00B3");//│
00052         debug("\x1B[%i;%iH",posY+i,posX+width);//debug("\x1B[%i;%iH",posX+width,posY+i);
00053             debug("\u00B3");//│
00054             
00055     #ifdef CONSOLE_DELAY_TEST
00056     wait(5);
00057     #endif
00058     
00059     }
00060     
00061     if(title != 0)
00062     {        
00063         debug("\x1B[%i;%iH",posY+2,posX);
00064             debug("\u00C3");//├
00065     }
00066     
00067     #ifdef CONSOLE_DELAY_TEST
00068     wait(5);
00069     #endif
00070     
00071     
00072     debug("\x1B[%i;%iH",posY+(height-1),posX);
00073         debug("\u00C0");//└
00074         for(int i=0; i<=width-2; i++)debug("\u00C4");//─
00075         debug("\u00D9");//┘
00076         
00077 }
00078 
00079 void createDLbox(int posX, int posY, int height, int width,const char* title)
00080 {
00081     //PATCH
00082     posX++;
00083     posY++;
00084     //
00085     
00086     
00087     debug("\x1B[%i;%iH",posY,posX);
00088     debug("\u00C9");//╔
00089     for(int i=0; i <= (width-2); i++) debug("\u00CD");//═ 
00090     debug("\u00BB");//╗
00091     
00092     #ifdef CONSOLE_DELAY_TEST
00093     wait(5);
00094     #endif
00095     
00096     if(title != 0)
00097     {
00098         char buffer[10];
00099         int leight=  sprintf(buffer,"%s",title);
00100             
00101         debug("\x1B[%i;%iH",posY+2,posX);
00102             debug("\u00CC");//╠
00103         for(int i=0; i <= (leight+2); i++) debug("\u00CD");//═   
00104             debug("\u00BC");//╝
00105             
00106         debug("\x1B[%i;%iH",posY,posX+2+leight+2);
00107             debug("\u00CB");//╦
00108          debug("\x1B[%i;%iH",posY+1,posX+2+leight+2);
00109             debug("\u00BA");//║
00110                 
00111         if(leight < width) // si le nom est plus petit que la box tu lafiche 
00112         {
00113          debug("\x1B[%i;%iH",posY+1,posX+2);
00114          debug("%s",title);//1 est la pour patcher le multiple instance problem 
00115         }
00116     }
00117     
00118     #ifdef CONSOLE_DELAY_TEST
00119     wait(5);
00120     #endif
00121            
00122     for(int i = 1;i <= (height-2);i++){
00123     debug("\x1B[%i;%iH",posY+i,posX);//debug("\x1B[%i;%iH",posX,posY+i);
00124             debug("\u00BA");//║
00125         debug("\x1B[%i;%iH",posY+i,posX+width);//debug("\x1B[%i;%iH",posX+width,posY+i);
00126             debug("\u00BA");//║
00127             
00128     #ifdef CONSOLE_DELAY_TEST
00129     wait(5);
00130     #endif
00131     
00132     }
00133     
00134     if(title != 0)
00135     {        
00136         debug("\x1B[%i;%iH",posY+2,posX);
00137             debug("\u00CC");//╠
00138     }
00139     
00140     #ifdef CONSOLE_DELAY_TEST
00141     wait(5);
00142     #endif
00143     
00144     
00145     debug("\x1B[%i;%iH",posY+(height-1),posX);
00146         debug("\u00C8");//╚
00147         for(int i=0; i<=width-2; i++)debug("\u00CD");//═ 
00148         debug("\u00BC");//╝
00149         
00150 }
00151 
00152 void clearscreen(void)
00153 {
00154     debug("\x1B[2J"); //clear screen
00155 }
00156 void setText(int posX, int posY,const char* title,...)
00157 {
00158     //PATCH
00159     posX++;
00160     posY++;
00161     //
00162     debug("\x1B[%i;%iH",posY,posX);
00163     
00164     //debug("\x1B[K");// Erase in Line
00165     
00166     va_list args;
00167     va_start(args, title);
00168     //debug(title, args);
00169     vfprintf(stderr,title, args);
00170     va_end(args);
00171     
00172 }