Borland TurboBASIC & TurboPASCAL stuff from 1998 when i started with programming...
[mirrors/Programs.git] / bash / bbs / utils / menu.c
1 #include <curses.h>
2 #include <menu.h>
3
4 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
5 #define CTRLD 4
6
7 char *choices[] = {
8 "Choice 1",
9 "Choice 2",
10 "Choice 3",
11 "Choice 4",
12 "Exit",
13 "Choice 1",
14 "Choice 2",
15 "Choice 3",
16 "Choice 4",
17 "Exit",
18 "Choice 1",
19 "Choice 2",
20 "Choice 3",
21 "Choice 4",
22 "Exit",
23 "Choice 1",
24 "Choice 2",
25 "Choice 3",
26 "Choice 4",
27 "Exit",
28 "Choice 1",
29 "Choice 2",
30 "Choice 3",
31 "Choice 4",
32 "Exit",
33 };
34
35 int main()
36 { ITEM **my_items;
37 int c;
38 MENU *my_menu;
39 int n_choices, i;
40 ITEM *cur_item;
41
42
43 initscr();
44 cbreak();
45 noecho();
46 keypad(stdscr, TRUE);
47
48 n_choices = ARRAY_SIZE(choices);
49 my_items = (ITEM **)calloc(n_choices + 1, sizeof(ITEM *));
50
51 for(i = 0; i < n_choices; ++i)
52 my_items[i] = new_item(choices[i], choices[i]);
53 my_items[n_choices] = (ITEM *)NULL;
54
55 my_menu = new_menu((ITEM **)my_items);
56 mvprintw(LINES - 1, 0, "F2 to Exit");
57 post_menu(my_menu);
58 refresh();
59
60 while((c = getch()) != KEY_F(2))
61 { switch(c)
62 { case KEY_DOWN:
63 menu_driver(my_menu, REQ_DOWN_ITEM);
64 break;
65 case KEY_UP:
66 menu_driver(my_menu, REQ_UP_ITEM);
67 break;
68 }
69 }
70
71 free_item(my_items[0]);
72 free_item(my_items[1]);
73 free_menu(my_menu);
74 endwin();
75 }
76
This page took 0.412613 seconds and 4 git commands to generate.