[Aptitude-svn-commit] r3276 - in branches/aptitude-0.3/aptitude: . src/vscreen/config
Daniel Burrows
dburrows@costa.debian.org
Tue, 10 May 2005 13:06:26 +0000
Author: dburrows
Date: Tue May 10 13:06:24 2005
New Revision: 3276
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/vscreen/config/style.h
Log:
Add a routine to apply a style to a chtype.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Tue May 10 13:06:24 2005
@@ -1,5 +1,9 @@
2005-05-10 Daniel Burrows <dburrows@debian.org>
+ * src/vscreen/config/style.h:
+
+ Add an interface to apply a style to a chtype value.
+
* src/vscreen/config/colors.cc, src/vscreen/config/colors.h:
Add an interface to 'mix' colors.
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 Tue May 10 13:06:24 2005
@@ -24,6 +24,8 @@
#include <string>
+#include "colors.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;
@@ -139,6 +141,19 @@
rval^=flip_attrs;
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.
+ return (ch & A_CHARTEXT) |
+ mix_color(ch & A_COLOR, fg, bg) |
+ ((((ch & ~ (A_CHARTEXT | A_COLOR)) | set_attrs) & ~clear_attrs) ^ flip_attrs);
+ }
};
// To allow styles to be built functionally, the following