Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libcurses Swap red/blue and yellow/cyan when working wit...
details: https://anonhg.NetBSD.org/src/rev/215874d2fedb
branches: trunk
changeset: 545282:215874d2fedb
user: jdc <jdc%NetBSD.org@localhost>
date: Sun Apr 06 07:22:13 2003 +0000
description:
Swap red/blue and yellow/cyan when working with Sb/Sf colour. Problem noticed
when working on PR 21000.
diffstat:
lib/libcurses/color.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 69 insertions(+), 2 deletions(-)
diffs (106 lines):
diff -r 326b37bc5250 -r 215874d2fedb lib/libcurses/color.c
--- a/lib/libcurses/color.c Sun Apr 06 07:19:53 2003 +0000
+++ b/lib/libcurses/color.c Sun Apr 06 07:22:13 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: color.c,v 1.23 2003/02/17 11:07:19 dsl Exp $ */
+/* $NetBSD: color.c,v 1.24 2003/04/06 07:22:13 jdc Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: color.c,v 1.23 2003/02/17 11:07:19 dsl Exp $");
+__RCSID("$NetBSD: color.c,v 1.24 2003/04/06 07:22:13 jdc Exp $");
#endif /* not lint */
#include "curses.h"
@@ -283,6 +283,9 @@
/*
* init_pair --
* Set pair foreground and background colors.
+ * Our default colour ordering is ANSI - 1 = red, 4 = blue, 3 = yellow,
+ * 6 = cyan. The older style (Sb/Sf) uses 1 = blue, 4 = red, 3 = cyan,
+ * 6 = yellow, so we swap them here and in pair_content().
*/
int
init_pair(short pair, short fore, short back)
@@ -300,6 +303,38 @@
if (back < -1 || back >= COLORS)
return (ERR);
+ /* Swap red/blue and yellow/cyan */
+ if (_cursesi_screen->color_type == COLOR_OTHER) {
+ switch (fore) {
+ case COLOR_RED:
+ fore = COLOR_BLUE;
+ break;
+ case COLOR_BLUE:
+ fore = COLOR_RED;
+ break;
+ case COLOR_YELLOW:
+ fore = COLOR_CYAN;
+ break;
+ case COLOR_CYAN:
+ fore = COLOR_YELLOW;
+ break;
+ }
+ switch (back) {
+ case COLOR_RED:
+ back = COLOR_BLUE;
+ break;
+ case COLOR_BLUE:
+ back = COLOR_RED;
+ break;
+ case COLOR_YELLOW:
+ back = COLOR_CYAN;
+ break;
+ case COLOR_CYAN:
+ back = COLOR_YELLOW;
+ break;
+ }
+ }
+
if ((_cursesi_screen->colour_pairs[pair].flags & __USED) &&
(fore != _cursesi_screen->colour_pairs[pair].fore ||
back != _cursesi_screen->colour_pairs[pair].back))
@@ -330,6 +365,38 @@
*forep = _cursesi_screen->colour_pairs[pair].fore;
*backp = _cursesi_screen->colour_pairs[pair].back;
+
+ /* Swap red/blue and yellow/cyan */
+ if (_cursesi_screen->color_type == COLOR_OTHER) {
+ switch (*forep) {
+ case COLOR_RED:
+ *forep = COLOR_BLUE;
+ break;
+ case COLOR_BLUE:
+ *forep = COLOR_RED;
+ break;
+ case COLOR_YELLOW:
+ *forep = COLOR_CYAN;
+ break;
+ case COLOR_CYAN:
+ *forep = COLOR_YELLOW;
+ break;
+ }
+ switch (*backp) {
+ case COLOR_RED:
+ *backp = COLOR_BLUE;
+ break;
+ case COLOR_BLUE:
+ *backp = COLOR_RED;
+ break;
+ case COLOR_YELLOW:
+ *backp = COLOR_CYAN;
+ break;
+ case COLOR_CYAN:
+ *backp = COLOR_YELLOW;
+ break;
+ }
+ }
return(OK);
}
Home |
Main Index |
Thread Index |
Old Index