|
|
@ -1,13 +1,16 @@
|
|
|
|
#include <ncurses.h>
|
|
|
|
#include <ncurses.h>
|
|
|
|
#include <menu.h>
|
|
|
|
#include <menu.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int curs_init();
|
|
|
|
|
|
|
|
int curs_end(ITEM* item);
|
|
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
int main() {
|
|
|
|
initscr();
|
|
|
|
|
|
|
|
cbreak();
|
|
|
|
curs_init();
|
|
|
|
noecho();
|
|
|
|
|
|
|
|
curs_set(0);
|
|
|
|
init_color();
|
|
|
|
keypad(stdscr,TRUE);
|
|
|
|
mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED,NULL);
|
|
|
|
mousemask(BUTTON1_PRESSED | BUTTON1_RELEASED | BUTTON1_CLICKED,NULL);
|
|
|
|
|
|
|
|
MEVENT event;
|
|
|
|
MEVENT event;
|
|
|
|
int c;
|
|
|
|
int c;
|
|
|
|
ITEM* cur_item;
|
|
|
|
ITEM* cur_item;
|
|
|
@ -30,7 +33,9 @@ int main() {
|
|
|
|
|
|
|
|
|
|
|
|
getmaxyx(stdscr,maxy,maxx);
|
|
|
|
getmaxyx(stdscr,maxy,maxx);
|
|
|
|
|
|
|
|
|
|
|
|
WINDOW* subwindow = derwin(stdscr,1,maxx-1,1,1);
|
|
|
|
WINDOW* subwindow = derwin(stdscr,1,maxx-1,0,0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
keypad(subwindow,TRUE);
|
|
|
|
|
|
|
|
|
|
|
|
set_menu_sub(menu,subwindow);
|
|
|
|
set_menu_sub(menu,subwindow);
|
|
|
|
|
|
|
|
|
|
|
@ -52,13 +57,22 @@ int main() {
|
|
|
|
menu_driver(menu,REQ_RIGHT_ITEM);
|
|
|
|
menu_driver(menu,REQ_RIGHT_ITEM);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEY_MOUSE:
|
|
|
|
case KEY_MOUSE:
|
|
|
|
|
|
|
|
if (getmouse(&event) == OK) {
|
|
|
|
|
|
|
|
if (event.bstate & BUTTON1_DOUBLE_CLICKED) {
|
|
|
|
|
|
|
|
cur_item = current_item(menu);
|
|
|
|
|
|
|
|
curs_end(cur_item);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
ungetmouse(&event);
|
|
|
|
menu_driver(menu,c);
|
|
|
|
menu_driver(menu,c);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 10:
|
|
|
|
case 10:
|
|
|
|
cur_item = current_item(menu);
|
|
|
|
cur_item = current_item(menu);
|
|
|
|
endwin();
|
|
|
|
curs_end(cur_item);
|
|
|
|
printf("You selected %s\n",item_name(cur_item));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -69,3 +83,19 @@ int main() {
|
|
|
|
|
|
|
|
|
|
|
|
endwin();
|
|
|
|
endwin();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int curs_init() {
|
|
|
|
|
|
|
|
initscr();
|
|
|
|
|
|
|
|
cbreak();
|
|
|
|
|
|
|
|
noecho();
|
|
|
|
|
|
|
|
curs_set(0);
|
|
|
|
|
|
|
|
keypad(stdscr,TRUE);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int curs_end(ITEM* item) {
|
|
|
|
|
|
|
|
endwin();
|
|
|
|
|
|
|
|
printf("You selected %s\n",item_name(item));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|