[Aptitude-svn-commit] r3335 - in branches/aptitude-0.3/aptitude: . src/vscreen/config
Daniel Burrows
dburrows@costa.debian.org
Mon, 06 Jun 2005 22:40:43 +0000
Author: dburrows
Date: Mon Jun 6 22:40:41 2005
New Revision: 3335
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
branches/aptitude-0.3/aptitude/src/vscreen/config/style.h
Log:
Finally fix style and attribute compositing.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Mon Jun 6 22:40:41 2005
@@ -1,5 +1,12 @@
2005-06-06 Daniel Burrows <dburrows@debian.org>
+ * src/vscreen/config/colors.cc, src/vscreen/config/colors.h, src/vscreen/config/style.h:
+
+ Further fixes to how styles and colors are applied to characters.
+ mix_color now operates on attribute values and returns an
+ attribute value, and the appropriate bits of code have been
+ updated to reflect this change.
+
* src/vscreen/vscreen.cc:
Remove some uses of the NOP style_attrs_on(0).
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 Mon Jun 6 22:40:41 2005
@@ -28,6 +28,9 @@
static void init_colors()
{
+ if(colors_initted)
+ return;
+
colors_initted=true;
if(COLOR_PAIRS<COLORS*COLORS || use_default_colors() == ERR)
@@ -66,17 +69,17 @@
if(!colors_avail)
return 0;
else if(fg == -1 && bg == -1)
- return color;
+ return color & A_COLOR;
else
{
short old_fg=color/COLORS;
short old_bg=color%COLORS;
if(fg == -1)
- return get_color_pair(old_fg, bg);
+ return COLOR_PAIR(get_color_pair(old_fg, bg));
else if(bg == -1)
- return get_color_pair(fg, old_bg);
+ return COLOR_PAIR(get_color_pair(fg, old_bg));
else
- return get_color_pair(fg, bg);
+ return COLOR_PAIR(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 Mon Jun 6 22:40:41 2005
@@ -30,7 +30,7 @@
/** \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 color attributes containing the starting color value
* \param fg the new foreground (-1 to use color)
* \param bg the new background (-1 to use color)
*
Modified: branches/aptitude-0.3/aptitude/src/vscreen/config/style.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/config/style.h (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/config/style.h Mon Jun 6 22:40:41 2005
@@ -26,6 +26,8 @@
#include "colors.h"
+#include <assert.h>
+
/** A "style" is a setting to be applied to a display element (widget,
* text, etc). This means color (foreground and background) and
* attributes. A style may contain settings for any or all of these;
@@ -153,20 +155,18 @@
rval|=set_attrs;
rval&=~clear_attrs;
rval^=flip_attrs;
- rval|=COLOR_PAIR(mix_color(0, fg, bg));
+ rval|=mix_color(0, fg, bg);
return rval;
}
/** \return the given character with its attributes updated with ours. */
chtype apply_to(chtype ch) const
{
- // DANGER DANGER DANGER
- //
- // A_COLOR is a nonstandard and undocumented ncurses extension.
- // This will go away when wide chars are used, as they have a
- // well-defined protocol for adjusting color content.
+ // Relies somewhat on the bitwise representation of attributes;
+ // the multicharacter-capable stuff needed for utf8 will make this
+ // go away (for better or for worse..)
return (ch & A_CHARTEXT) |
- mix_color(ch & A_COLOR, fg, bg) |
+ mix_color(ch, fg, bg) |
((((ch & ~ (A_CHARTEXT | A_COLOR)) | set_attrs) & ~clear_attrs) ^ flip_attrs);
}
};