5 * Copyright (C) 2008 Pawel Dziepak
7 * This is a tool that generate configuration file before compilation of Quarn
8 * OS. Possible configuration options are read from external file and parsed.
9 * Then there are shown menus in which user can adjust his own compilation of
10 * the system. This tool uses ncurses, for computers without this library, there
11 * is a less user-friendly shell script.
17 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
38 /* Initialize curses */
45 /* Initialize and set colors */
46 init_pair(1, COLOR_RED
, COLOR_WHITE
);
47 init_pair(2, COLOR_GREEN
, COLOR_WHITE
);
48 init_pair(3, COLOR_YELLOW
, COLOR_WHITE
);
49 attron(COLOR_PAIR(3));
51 /* Initialize items */
52 n_descrs
= ARRAY_SIZE(descrs
);
53 config_items
= (ITEM
**)calloc(n_descrs
+ 1, sizeof(ITEM
*));
54 for(i
= 0; i
< n_descrs
; ++i
)
55 config_items
[i
] = new_item(descrs
[i
],"");
56 config_items
[n_descrs
] = (ITEM
*)NULL
;
59 main_menu
= new_menu((ITEM
**)config_items
);
61 /* Set foreground and background */
62 set_menu_fore(main_menu
, COLOR_PAIR(1) | A_REVERSE
);
63 set_menu_back(main_menu
, COLOR_PAIR(1));
64 set_menu_grey(main_menu
, COLOR_PAIR(2));
71 while((c
= getch()) != 'q') {
74 menu_driver(main_menu
, REQ_DOWN_ITEM
);
77 menu_driver(main_menu
, REQ_UP_ITEM
);
80 cur_item
= current_item(main_menu
);
81 if (item_opts(cur_item
) & O_SELECTABLE
== O_SELECTABLE
) {
82 item_opts_off(cur_item
, O_SELECTABLE
);
84 item_opts_on(cur_item
, O_SELECTABLE
);
90 /* Clean everything */
91 unpost_menu(main_menu
);
92 for(i
= 0; i
< n_descrs
; ++i
)
93 free_item(config_items
[i
]);