Started working on color support

master
Aadhavan Srinivasan 2 years ago
parent 02f41a62fc
commit b0a440deae

@ -3,13 +3,21 @@
#include <stdlib.h> #include <stdlib.h>
int curs_init(); int curs_init();
void color_init();
int curs_end(ITEM* item); int curs_end(ITEM* item);
int main() { int main() {
curs_init(); curs_init();
init_color(); color_init(); /* If the program doesn't exit after this function call, it is
assumed that the terminal supports colors */
init_pair(1,COLOR_BLACK,COLOR_WHITE);
mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED,NULL); mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED,NULL);
MEVENT event; MEVENT event;
int c; int c;
@ -35,6 +43,8 @@ int main() {
WINDOW* subwindow = derwin(stdscr,1,maxx-1,0,0); WINDOW* subwindow = derwin(stdscr,1,maxx-1,0,0);
wbkgd(subwindow,COLOR_PAIR(1));
keypad(subwindow,TRUE); keypad(subwindow,TRUE);
set_menu_sub(menu,subwindow); set_menu_sub(menu,subwindow);
@ -94,6 +104,20 @@ int curs_init() {
return 0; return 0;
} }
void color_init() {
if (has_colors() == FALSE) {
endwin();
printf("Your terminal does not support colors.\n");
exit(1);
}
start_color();
}
int curs_end(ITEM* item) { int curs_end(ITEM* item) {
endwin(); endwin();
printf("You selected %s\n",item_name(item)); printf("You selected %s\n",item_name(item));

Loading…
Cancel
Save