int main(void)
    {
    char message[1621]="";
    initscr();
    noecho();
    cbreak();
    keypad(stdscr,TRUE);

    move(20,0);
    hline(ACS_CKBOARD,80);
    mvaddstr(21,0,"Press F1 to Exit Editor");
    mvaddstr(21,39,"Press F3 to Clear Message");
    mvaddstr(22,0,"Press CTRL-Y to Delete Current Line");

    texteditor(message);

    clear();
    addstr("Exited text editor");
    getch();
    endwin();
    printf("%s",message);
    return 0;
    }
int main(int argc, char* argv[])
{
  /* This is the porition we ask user to run program with file path and mode to open*/
	FILE* fp;	//declare a file pointer to open file
	int  file_size;	//a variable to know file size, but it is useless so you may remove it (I have declared various such variables during program typing)
	int maxchars=size/*number of characters allowed to be opened*/,startrow=0/*cursor start row*/,startcol=0/*cursor start column*/;
	int maxrows=10000/*maximum number of rows allowed calculated by (maxchars/maxcols)*/,maxcols=60/*maximum number of rows allowed calculated by (maxchars/maxrows)*/;
	int displayrows=20/*number of rows displayed in text box(scroll added too)*/,returnhandler=1/*select behaviour for enter key press*/;
        char *message=malloc(maxchars*sizeof(char));  //allocate memory for our message string
        bool ins=false/*insert mode is initially false means text will be replaced in beginning*/,allowcr=true;
	if(argc<3)/*in case program is not given the necessary arguments*/
	{
		printf("usage: %s filename mode | modes can be \nopen new file with [w] open existing file with [r]\n\n",argv[0]);/* generate an error */
		return 0;/*and exit*/
	}
	if(strcmp(argv[2],"w")==0)/*if user asked toopen a new file*/
	{
		if(file_exist(argv[1]))/*check if file exist?*/
		{
			printf("file already exist : \n");/*in case file already exist, tell user about it*/
			return 0;/*and exit*/
		}
		else /*in case file didn't exist already*/
			fp=fopen(argv[1],"w+");/*create the file and assign it's address to fp*/
	}
	else if(strcmp(argv[2],"r")==0)/*in case user want to open an existing file*/
	{
		if(!file_exist(argv[1]))/*check if file exist*/
		{
			printf("file does not exist : \n");/*in case file didn't exist display the error*/
			return 0;/*and exit*/
		}
		else/*in case file exist*/
			fp=fopen(argv[1],"r+");/*open it*/
	}
	else/**in case user specified a mode other than r or w to open a file*/
	{
		printf("wrong mode specified\n");/*dsiplay error*/
		return 0;/*exit*/
	}
 /////////// WE checked above if user has done everythign right while runing the program
////////////////file work above

// if user did everythign right then we read the data from openend file here
	int i=0;/*just to count*/
	char c;/*just to read a character from file */
	if(fp!=NULL)/*if fp is pointing to a file*/
	{
		while((c=fgetc(fp))!=EOF)/*keep getting a charcetr from file unless it reaches end of file*/
			{message[i]=(char)c;i++;}/*add the charcetr to data structure message*/
		fclose(fp);/*close file when done traversing*/
	}
// read all the text from file in variable message
///////////////////////////////////reading
//// doing our text screen initialization
        initscr();    //initialize screen for text box
        noecho();	//disable echo so whatever we press shouldn't be randomly displayed on textbox
        cbreak();   //get all the key presses in our program except few specific signals
        keypad(stdscr,TRUE);//initialize our screen for keypad for example arrow keys and num keys
////////////////////////menu down
        move(20,0);      // down menu starts from y=20
        hline(ACS_CKBOARD,80);  // placing a horizontal line to separate menu from text area here
///////////////Now we print menu here
	mvaddstr(21,0,"Home = goto first character on current row");
	mvaddstr(21,50,"F3 to search and remove Text");
	mvaddstr(22,50,"F2 to delete all text");
	mvaddstr(22,0,"PgDn = goto last character in text string");
	mvaddstr(23,50,"F4 to replace Text");
	mvaddstr(23,0,"INS = insert mode on/off");
	mvaddstr(24,0,"PgUp = goto first character in text string");
        mvaddstr(24,50,"Press ESCAPE to quit");
	mvaddstr(25,0,"End = goto last character on current row");
        mvaddstr(25,50,"CTRL-Y to Delete Current Line");
        mvaddstr(26,0,"F6 to see number of words and characters");
	mvaddstr(26,50,"F5 = to save file");
	mvaddstr(27,0,"F7 to remove search marks");

///****************MENU above*/
////////////menu printed now call the most important function the text editor
        texteditor(message,maxchars,startrow,startcol,maxrows,maxcols,displayrows,returnhandler,NULL,ins,allowcr);
		/*with variables as explained above*/
// user exited text editor? clear and restrore original console windwo
        clear();//once returned from texteditor clear the screen and buffer
        endwin();//end window
//        printf("Message\n-------\n\"%s\"",message);
        free(message);    // free memory allocated for message
        return 0;//and exit
}