#include <ncurses.h>
#include "menu.h"

#define ctrl(x) (x & 0x1F) // Detection of ctrl+x presses please do not forget that in unix ctrl+c and ctrl+z are special commands. 

// INFO: wgetch(win); or getch();  // getch will make a refresh for us.  

int main(int argv, char ** argc)
{
	//Variables
	int xMax, yMax = 0; 
	char pressed; 

	j
	//Init Ncurses
	initscr(); 
	
	if(has_colors() == false) // If the terminal does have colors
	{
		printf("This menu is not supported by terminals without colors\n"); 
		return -1; 
	}	

	start_color(); 

	noecho(); 
	curs_set(0); // Cursor won't show up 
	getmaxyx(stdscr, yMax, xMax);
	//			  		 size y  size x  pos y   pos x
	WINDOW *win = newwin(yMax/2, xMax/2, yMax/4, xMax/4); 
	box(win,0,0);
	
	//Setc colors
	init_pair(1, COLOR_WHITE, COLOR_BLUE); 

	std::string menu1[4]={"New","Open","Save","Exit"}; 
	std::string menu2[3]={"Copy","Cut","Paste"}; 
	std::string menu3[5]={"Terminal","Help","Info","Update","Manual"};

	// Second stage declarations
	Menu menus[3]={				// init the menus
		Menu("File", 'f', menu1, 4), 
		Menu("Edit", 'e', menu2, 3), 
		Menu("Options", 'o', menu3, 5), 
	};

	MenuBar menuBar = MenuBar(win, menus, 3); // init the menu bar 
	menuBar.draw();

	while(pressed = wgetch(win))
	{
		menuBar.handleTrigger(pressed); 
		menuBar.draw();
	}
	
	endwin();	
	return 0;
}
