ANSI, and my Graphics.cpp problem

First with ANSI codes I know how to do most of the stuff, but i want to be able to change the key codes e.g.
user types 3 and program recieves 1
basically the program thinks its getting a one then i change it back for normal console use
i know the basic syntax for it...
\033[string;code;...p
i know that but could someone give me an example or explain what is string and what is code...
Secondly can i get the current time using the c library time.h?
Thirdly I'm having a problem with this code...
it gives me an error about an exponent...
at first i thought it was the E but it wasnt...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <stdio.h>
#define CLEAR "\033[2J"
enum colors{BLACK,RED,GREEN,BROWN,BLUE,MAGENTA,CYAN,LIGHTGREY};
enum {NONE,BOLD,DARK};
enum {UNDERLINE=4,BLINK};
enum {REVERSE=7,CONCEALED,STRIKE};
void display(bool isClear,int vpos,int hpos,int background,int text,int special,int height,int width,char* message,bool isBox);
int main()
{
     char welcome[]={"Welcome to a semi-graphical program!\n"};
     char newline[]={"\n"};
     char exit1[]={"1) "};
     char exit2[]={"E"};
     char exit3[]={"xit"};
     display(1,0,0,GREEN,RED,REVERSE,1,50,welcome,0);
     display(0,1,0,GREEN,RED,NONE,1,50,newline,0);
     display(0,2,0,BLUE,GREEN,NONE,1,50,exit1,0);
     display(0,2,3,BLUE,GREEN,UNDERLINE,1,50,exit2,0);
     display(0,2,4,BLUE,GREEN,NONE,1,50,exit3,0);
     return 0;
}
void display(bool isClear,int vpos,int hpos,int background,int text,int special,int height,int width,char* message,bool isBox)
{
     if(isClear)
     {
          printf(CLEAR "\033[0;0H");
          printf("\033[7;4%im\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",background);
     }
     printf("\033[%i;%iH",vpos,hpos);
     if(!isBox)
     {
          printf("\033[%i;4%i;3%im%s",special,background,text,message);
          printf("\033[B");
          printf("\033[50D");
     }
}

Also I'd like to know if I,can run a program within my program
like my program is still running and is in control gives input to the other program
Last edited on
Topic archived. No new replies allowed.