Module Name: src Committed By: roy Date: Tue Jan 3 12:39:44 UTC 2017
Modified Files: src/lib/libcurses: color.c Log Message: Now that we have the initialize_color capability, init_color can be made to work. From: rofl0r <ret...@gmx.net> To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/lib/libcurses/color.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libcurses/color.c diff -u src/lib/libcurses/color.c:1.38 src/lib/libcurses/color.c:1.39 --- src/lib/libcurses/color.c:1.38 Mon Oct 3 12:32:15 2011 +++ src/lib/libcurses/color.c Tue Jan 3 12:39:44 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: color.c,v 1.38 2011/10/03 12:32:15 roy Exp $ */ +/* $NetBSD: color.c,v 1.39 2017/01/03 12:39:44 roy Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: color.c,v 1.38 2011/10/03 12:32:15 roy Exp $"); +__RCSID("$NetBSD: color.c,v 1.39 2017/01/03 12:39:44 roy Exp $"); #endif /* not lint */ #include "curses.h" @@ -53,6 +53,9 @@ struct __pair __default_pair = {COLOR_WH static void __change_pair(short); +static int +init_color_value(short, short, short, short); + /* * has_colors -- * Check if terminal has colours. @@ -190,22 +193,23 @@ start_color(void) #endif /* Set up initial 8 colours */ +#define RGB_ON 680 /* Allow for bright colours */ if (COLORS >= COLOR_BLACK) - (void) init_color(COLOR_BLACK, 0, 0, 0); + (void) init_color_value(COLOR_BLACK, 0, 0, 0); if (COLORS >= COLOR_RED) - (void) init_color(COLOR_RED, 1000, 0, 0); + (void) init_color_value(COLOR_RED, RGB_ON, 0, 0); if (COLORS >= COLOR_GREEN) - (void) init_color(COLOR_GREEN, 0, 1000, 0); + (void) init_color_value(COLOR_GREEN, 0, RGB_ON, 0); if (COLORS >= COLOR_YELLOW) - (void) init_color(COLOR_YELLOW, 1000, 1000, 0); + (void) init_color_value(COLOR_YELLOW, RGB_ON, RGB_ON, 0); if (COLORS >= COLOR_BLUE) - (void) init_color(COLOR_BLUE, 0, 0, 1000); + (void) init_color_value(COLOR_BLUE, 0, 0, RGB_ON); if (COLORS >= COLOR_MAGENTA) - (void) init_color(COLOR_MAGENTA, 1000, 0, 1000); + (void) init_color_value(COLOR_MAGENTA, RGB_ON, 0, RGB_ON); if (COLORS >= COLOR_CYAN) - (void) init_color(COLOR_CYAN, 0, 1000, 1000); + (void) init_color_value(COLOR_CYAN, 0, RGB_ON, RGB_ON); if (COLORS >= COLOR_WHITE) - (void) init_color(COLOR_WHITE, 1000, 1000, 1000); + (void) init_color_value(COLOR_WHITE, RGB_ON, RGB_ON, RGB_ON); /* Initialise other colours */ for (i = 8; i < COLORS; i++) { @@ -381,8 +385,25 @@ pair_content(short pair, short *forep, s } /* + * init_color_Value -- + * Set colour red, green and blue values. + */ +static int +init_color_value(short color, short red, short green, short blue) +{ + if (color < 0 || color >= _cursesi_screen->COLORS) + return ERR; + + _cursesi_screen->colours[color].red = red; + _cursesi_screen->colours[color].green = green; + _cursesi_screen->colours[color].blue = blue; + return OK; +} + +/* * init_color -- * Set colour red, green and blue values. + * Change color on screen. */ int init_color(short color, short red, short green, short blue) @@ -391,15 +412,13 @@ init_color(short color, short red, short __CTRACE(__CTRACE_COLOR, "init_color: %d, %d, %d, %d\n", color, red, green, blue); #endif - if (color < 0 || color >= _cursesi_screen->COLORS) - return(ERR); - - _cursesi_screen->colours[color].red = red; - _cursesi_screen->colours[color].green = green; - _cursesi_screen->colours[color].blue = blue; - /* XXX Not yet implemented */ - return(ERR); - /* XXX: need to initialise Tek style (Ic) and support HLS */ + if (init_color_value(color, red, green, blue) == ERR) + return ERR; + if (!can_change || t_initialize_color(_cursesi_screen->term) == NULL) + return ERR; + tputs(tiparm(t_initialize_color(_cursesi_screen->term), + color, red, green, blue), 0, __cputchar); + return OK; } /*