diff --git a/platform/native/contiki-conf.h b/platform/native/contiki-conf.h index e3739e9be..71bda7a24 100644 --- a/platform/native/contiki-conf.h +++ b/platform/native/contiki-conf.h @@ -208,23 +208,33 @@ typedef unsigned short uip_stats_t; #define CTK_CONF_MENUS 0 #endif /* PLATFORM_BUILD */ -/* base background color for widgets */ -#define COLOR_BG COLOR_BLUE +/* CTK-specific color constants */ +#define CTK_COLOR_BLACK 0 +#define CTK_COLOR_RED 1 +#define CTK_COLOR_GREEN 2 +#define CTK_COLOR_YELLOW 3 +#define CTK_COLOR_BLUE 4 +#define CTK_COLOR_MAGENTA 5 +#define CTK_COLOR_CYAN 6 +#define CTK_COLOR_WHITE 7 -#define BORDERCOLOR COLOR_BLACK -#define SCREENCOLOR COLOR_BLACK -#define BACKGROUNDCOLOR COLOR_BLACK -#define WINDOWCOLOR_FOCUS COLOR_WHITE | COLOR_BG * 0x10 -#define WINDOWCOLOR COLOR_CYAN | COLOR_BG * 0x10 -#define DIALOGCOLOR COLOR_WHITE | COLOR_BG * 0x10 -#define WIDGETCOLOR_HLINK COLOR_CYAN | COLOR_BG * 0x10 -#define WIDGETCOLOR_FWIN COLOR_WHITE | COLOR_BG * 0x10 -#define WIDGETCOLOR COLOR_CYAN | COLOR_BG * 0x10 -#define WIDGETCOLOR_DIALOG COLOR_WHITE | COLOR_BG * 0x10 -#define WIDGETCOLOR_FOCUS COLOR_YELLOW | COLOR_BG * 0x10 -#define MENUCOLOR COLOR_WHITE | COLOR_BG * 0x10 -#define OPENMENUCOLOR COLOR_WHITE | COLOR_BG * 0x10 -#define ACTIVEMENUITEMCOLOR COLOR_YELLOW | COLOR_BG * 0x10 +/* base background color for widgets */ +#define COLOR_BG CTK_COLOR_BLUE + +#define BORDERCOLOR CTK_COLOR_BLACK +#define SCREENCOLOR CTK_COLOR_BLACK +#define BACKGROUNDCOLOR CTK_COLOR_BLACK +#define WINDOWCOLOR_FOCUS CTK_COLOR_WHITE | COLOR_BG * 0x10 +#define WINDOWCOLOR CTK_COLOR_CYAN | COLOR_BG * 0x10 +#define DIALOGCOLOR CTK_COLOR_WHITE | COLOR_BG * 0x10 +#define WIDGETCOLOR_HLINK CTK_COLOR_CYAN | COLOR_BG * 0x10 +#define WIDGETCOLOR_FWIN CTK_COLOR_WHITE | COLOR_BG * 0x10 +#define WIDGETCOLOR CTK_COLOR_CYAN | COLOR_BG * 0x10 +#define WIDGETCOLOR_DIALOG CTK_COLOR_WHITE | COLOR_BG * 0x10 +#define WIDGETCOLOR_FOCUS CTK_COLOR_YELLOW | COLOR_BG * 0x10 +#define MENUCOLOR CTK_COLOR_WHITE | COLOR_BG * 0x10 +#define OPENMENUCOLOR CTK_COLOR_WHITE | COLOR_BG * 0x10 +#define ACTIVEMENUITEMCOLOR CTK_COLOR_YELLOW | COLOR_BG * 0x10 typedef unsigned long clock_time_t; diff --git a/platform/native/ctk/ctk-curses.c b/platform/native/ctk/ctk-curses.c index 6cac2218e..df3572bde 100644 --- a/platform/native/ctk/ctk-curses.c +++ b/platform/native/ctk/ctk-curses.c @@ -66,6 +66,26 @@ static unsigned short xpos; static unsigned short ypos; static unsigned char button; +/* map CTK colors to curses colors */ +static unsigned char ctk_color_map[8] = { + COLOR_BLACK, + COLOR_RED, + COLOR_GREEN, + COLOR_YELLOW, + COLOR_BLUE, + COLOR_MAGENTA, + COLOR_CYAN, + COLOR_WHITE +}; + +static unsigned char map_color(unsigned char color) +{ + unsigned char c; + c = ctk_color_map[color & 0x0f]; + c |= ctk_color_map[(color >> 4) & 0x07] << 4; + return c; +} + /*-----------------------------------------------------------------------------------*/ static void ctrlhandler(int sig) @@ -212,8 +232,8 @@ clrscr(void) void bgcolor(unsigned char c) { + c = map_color(c); color = ((c << 4) | (color & 0xF0)); - /* Presume this to be one of the first calls. */ console_init(); } @@ -339,7 +359,7 @@ cputcxy(unsigned char x, unsigned char y, char c) void textcolor(unsigned char c) { - color = c; + color = map_color(c); setcolor(); } /*-----------------------------------------------------------------------------------*/ diff --git a/platform/native/ctk/ctk-curses.h b/platform/native/ctk/ctk-curses.h index 2661f7f47..98d432d5b 100644 --- a/platform/native/ctk/ctk-curses.h +++ b/platform/native/ctk/ctk-curses.h @@ -33,8 +33,6 @@ #ifndef __CTK_CONSOLE_H__ #define __CTK_CONSOLE_H__ -#include - #define cputc console_cputc #define cputs console_cputs