Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libcurses Now that we have the initialize_color capability,
details: https://anonhg.NetBSD.org/src/rev/1836f5543150
branches: trunk
changeset: 350073:1836f5543150
user: roy <roy%NetBSD.org@localhost>
date: Tue Jan 03 12:39:44 2017 +0000
description:
Now that we have the initialize_color capability,
init_color can be made to work.
From: rofl0r <retnyg%gmx.net@localhost>
diffstat:
lib/libcurses/color.c | 57 ++++++++++++++++++++++++++++++++++-----------------
1 files changed, 38 insertions(+), 19 deletions(-)
diffs (109 lines):
diff -r 07b642170196 -r 1836f5543150 lib/libcurses/color.c
--- a/lib/libcurses/color.c Tue Jan 03 12:37:08 2017 +0000
+++ b/lib/libcurses/color.c Tue Jan 03 12:39:44 2017 +0000
@@ -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 @@
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 @@
#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 @@
}
/*
+ * 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 @@
__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;
}
/*
Home |
Main Index |
Thread Index |
Old Index