First commit

master
Aadhavan Srinivasan 2 years ago
commit e35c11c968

@ -0,0 +1,71 @@
#include <ncurses.h>
#include <menu.h>
#include <stdlib.h>
int main() {
initscr();
cbreak();
noecho();
curs_set(0);
keypad(stdscr,TRUE);
mousemask(BUTTON1_PRESSED | BUTTON1_RELEASED | BUTTON1_CLICKED,NULL);
MEVENT event;
int c;
ITEM* cur_item;
ITEM* items[] = {
new_item("File",""),
new_item("Edit",""),
new_item("Compile",""),
new_item("Help",""),
new_item("Quit",""),
NULL
};
MENU* menu = new_menu(items);
set_menu_win(menu,stdscr);
int maxx;
int maxy;
getmaxyx(stdscr,maxy,maxx);
WINDOW* subwindow = derwin(stdscr,1,maxx-1,1,1);
set_menu_sub(menu,subwindow);
set_menu_format(menu,1,maxx);
set_menu_mark(menu,"");
post_menu(menu);
refresh();
while (true) {
c = getch();
switch(c) {
case KEY_LEFT:
menu_driver(menu,REQ_LEFT_ITEM);
break;
case KEY_RIGHT:
menu_driver(menu,REQ_RIGHT_ITEM);
break;
case KEY_MOUSE:
menu_driver(menu,c);
break;
case 10:
cur_item = current_item(menu);
endwin();
printf("You selected %s\n",item_name(cur_item));
return 0;
}
}
endwin();
}
Loading…
Cancel
Save