From b0a440deae93b0def316096fc4c80cdc48dbb51b Mon Sep 17 00:00:00 2001 From: Rockingcool Date: Tue, 21 Mar 2023 08:09:21 -0500 Subject: [PATCH] Started working on color support --- test.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/test.c b/test.c index e96b1ee..8936224 100644 --- a/test.c +++ b/test.c @@ -3,13 +3,21 @@ #include int curs_init(); +void color_init(); int curs_end(ITEM* item); int main() { 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); MEVENT event; int c; @@ -35,6 +43,8 @@ int main() { WINDOW* subwindow = derwin(stdscr,1,maxx-1,0,0); + wbkgd(subwindow,COLOR_PAIR(1)); + keypad(subwindow,TRUE); set_menu_sub(menu,subwindow); @@ -94,6 +104,20 @@ int curs_init() { 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) { endwin(); printf("You selected %s\n",item_name(item));