[Aptitude-svn-commit] r3275 - in branches/aptitude-0.3/aptitude: . src/vscreen/config

Daniel Burrows dburrows@costa.debian.org
Tue, 10 May 2005 13:05:01 +0000


Author: dburrows
Date: Tue May 10 13:04:58 2005
New Revision: 3275

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/vscreen/config/colors.cc
   branches/aptitude-0.3/aptitude/src/vscreen/config/colors.h
Log:
Add an interface to allow the easy 'mixing' of colors.


Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Tue May 10 13:04:58 2005
@@ -1,3 +1,9 @@
+2005-05-10  Daniel Burrows  <dburrows@debian.org>
+
+	* src/vscreen/config/colors.cc, src/vscreen/config/colors.h:
+
+	Add an interface to 'mix' colors.
+
 2005-05-08  Daniel Burrows  <dburrows@debian.org>
 
 	* src/vscreen/fragment.cc, src/vscreen/fragment.h:

Modified: branches/aptitude-0.3/aptitude/src/vscreen/config/colors.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/config/colors.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/config/colors.cc	Tue May 10 13:04:58 2005
@@ -50,7 +50,32 @@
   init_colors();
 
   if(!colors_avail)
-    return false;
+    return 0;
   else
-    return fg*COLORS+bg;
+    {
+      assert(fg>=0 && bg>=0 && fg<COLORS && bg<COLORS);
+
+      return fg*COLORS+bg;
+    }
+}
+
+int mix_color(short color, short fg, short bg)
+{
+  init_colors();
+
+  if(!colors_avail)
+    return 0;
+  else if(fg == -1 && bg == -1)
+    return color;
+  else
+    {
+      short old_fg=color/COLORS;
+      short old_bg=color%COLORS;
+
+      if(fg == -1)
+	return get_color_pair(old_fg, bg);
+      else if(bg == -1)
+	return get_color_pair(fg, old_bg);
+      else
+	return get_color_pair(fg, bg);
 }

Modified: branches/aptitude-0.3/aptitude/src/vscreen/config/colors.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/config/colors.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/config/colors.h	Tue May 10 13:04:58 2005
@@ -30,4 +30,13 @@
 /** \return a color pair for the given foreground and background. */
 int get_color_pair(short fg, short bg);
 
+/** \param color the starting color pair
+ *  \param fg the new foreground (-1 to use color)
+ *  \param bg the new background (-1 to use color)
+ *
+ *  \return a color pair created by mixing the given foreground
+ *  and background into color.
+ */
+int mix_color(short color, short fg, short bg);
+
 #endif