I need to create a text editor using C++. Here's the code I have
developed till now. Let me know more about handling ASCII values during
input. Specifically here's what I want to do:-

Pressing ...

ESCAPE-->Quits the program

ENTER-->Cursor moves to next line

BACKSPACE-->deletes the character to the left of the cursor.

Make the left and right arrow keys functional.





#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<math.h>
#include<stdlib.h>
mainscreen();
miniwindow(char *name);
blackbox(int x,int y);
initmouse();
showmouse();
hidemouse();
getmouse(int *button,int *x,int * y);
moveonly(int x1,int y1,int x2,int y2);
closebutton();
void main()
{
int gd=DETECT,gm;
char type;
initgraph(&gd,&gm,"");
mainscreen();
miniwindow("  Shashank's Text Editor v2.0");
blackbox(160,138);
showmouse();

closebutton();
gotoxy(22,10);
cin>>type;
getch();
}
//CREATE THE PURPLE GREEN SCREEN ON BACK SIDE OF WINDOW
mainscreen()
{
int x,y;
x=getmaxx();
y=getmaxy();
setfillstyle(1,3);
bar(0,0,x,y);
setcolor(DARKGRAY);
setlinestyle(0,1,0);
line(0,y-29,x,y-29);
setcolor(4);
settextstyle(2,0,7);
outtextxy(200,455,"CREATED BY SHASHANK");
outtextxy(202,455,"CREATED BY SHASHANK");
settextstyle(0,0,1);
return(0);
}

//CREATE MINI WINDOW ON THE MAIN SCREEN
miniwindow(char *name)
{
int x,y,a,b,button;
x=getmaxx();
y=getmaxy();
setfillstyle(SOLID_FILL,LIGHTGRAY);
bar(((x/2)-170),((y/2)-136),((x/2)+170),((y/2)+70));
setlinestyle(0,1,0);
setcolor(DARKGRAY);
rectangle(((x/2)-168),((y/2)-137),((x/2)+170),((y/2)+70));
setcolor(WHITE);
rectangle(((x/2)-170),((y/2)-136),((x/2)+168),((y/2)+70));
setfillstyle(SOLID_FILL,BLUE);
bar(((x/2)-170),((y/2)-111),((x/2)+167),((y/2)-133));
setcolor(WHITE);
setlinestyle(0,2,2);
rectangle(((x/2)-170),((y/2)-111),((x/2)+168),((y/2)-135));
setcolor(DARKGRAY);
line(150,308,486,308);
line(150,307,486,307);
setcolor(WHITE);
line(150,308,486,308);
setcolor(YELLOW);
outtextxy(160,112,name);
setcolor(15);
rectangle(((x/2)-148),((y/2)-130),((x/2)+163),((y/2)-116));
setcolor(DARKGRAY);
rectangle(((x/2)+149),((y/2)-129),((x/2)+162),((y/2)-117));
setcolor(0);
outtextxy(((x/2)+153),((y/2)-127),"x");
return(0);
}

//WRITING OF BLACK BOX FOR TEXT AREA
blackbox(int x,int y)
{
setfillstyle(SOLID_FILL,BLACK);
bar(x,y-1,x+317,y+103);
setlinestyle(0,2,2);
setcolor(WHITE);
rectangle(x,y-1,x+317,y+103);
setcolor(DARKGRAY);
rectangle(x+1,y,x+319,y+105);
setcolor(WHITE);
rectangle(x,y-1,x+318,y+104);
return(0);
}

//MOUSE INITIALISATION
initmouse()
{
union REGS i,o;
i.x.ax=0;
int86(0x33,&i,&o);
return(o.x.ax);
}

//MOUSE POINTER IS DISPLAYED IN THE SCREEN
showmouse()
{
union REGS i,o;
i.x.ax=1;
int86(0x33,&i,&o);
return(0);
}

//mouse pointer is hided in the screen
hidemouse()
{
union REGS i,o;
i.x.ax=2;
int86(0x33,&i,&o);
return(0);
}

//GET THE STATUS OF BUTTON & POSITION OF MOUSE POINTER
getmouse(int *button,int *x,int *y)
{
union REGS i,o;
i.x.ax=3;
int86(0x333,&i,&o);
*button=o.x.bx;
*x=o.x.cx;
*y=o.x.dx;
return(0);
}

//RESTRICT THE MOVEMENT ONLY IN SPECIFIED AREA
moveonly(int x1,int y1,int x2,int y2)
{
union REGS i,o;
i.x.ax=7;
i.x.cx=x1;
i.x.dx=x2;
int86(0x33,&i,&o);
i.x.ax=8;
i.x.cx=y1;
i.x.dx=y2;
int86(0x33,&i,&o);
return(0);
}

//CLOSE BUTTON
closebutton()
{
int x,y,a,b,button;
x=getmaxx();
y=getmaxy();
getmouse(&button,&a,&b);
if((button&=1)==1)
{
if((a>=(x/2)+148)&&((a<=(x/2)+162))&&((b>=(y/2)-129))&&(b<=(y/2)-116))
{
delay(10000);
setcolor(DARKGRAY);
rectangle(((x/2)+1488),((y/2)-130),((x/2)+163),((y/2)-116));
setcolor(15);
rectangle(((x/2)+149),((y/2)-129),((x/2)+163),((y/2)-116));
setfillstyle(SOLID_FILL,LIGHTGRAY);
bar(((x/2)+149),((y/2)-129),((x/2)+162),((y/2)-117));
setcolor(0);
outtextxy(((x/2)+154),((y/2)-126),"x");
delay(15000);
closegraph();
restorecrtmode();
exit(0);
}
}
return(0);
}







To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/c-prog/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to