2000-11-06 Miles Bader
* xterm.c (x_alloc_lighter_color): Boost FACTOR for dark colors.
(Vhighlight_color_dark_boost, Vhighlight_color_dark_boost_limit):
New variables.
(syms_of_xterm): Initialize new variables.
Include .
diff -uwBp src/xterm.c.\~1\~ src/xterm.c
--- src/xterm.c.~1~ Tue Oct 31 09:44:48 2000
+++ src/xterm.c Mon Nov 6 18:38:03 2000
@@ -29,6 +29,7 @@ Boston, MA 02111-1307, USA. */
#include
#include
+#include
#ifdef HAVE_X_WINDOWS
@@ -383,6 +384,10 @@ extern XrmDatabase x_load_resources P_ (
extern Lisp_Object x_icon_type P_ ((struct frame *));
+/* Parameters used by x_alloc_lighter_color. */
+Lisp_Object Vhighlight_color_dark_boost, Vhighlight_color_dark_boost_limit;
+
+
/* Enumeration for overriding/changing the face to use for drawing
glyphs in x_draw_glyphs. */
@@ -3511,6 +3516,46 @@ x_alloc_lighter_color (f, display, cmap,
color.pixel = *pixel;
x_query_color (f, &color);
+ if (NUMBERP (Vhighlight_color_dark_boost))
+ /* Boost FACTOR for dark colors. */
+ {
+ long bright, limit;
+
+ /* Use the maximum component brightness as the overall brightness
+ (this works quite well in practice). */
+ bright = color.red;
+ if (color.green > bright)
+ bright = color.green;
+ if (color.blue > bright)
+ bright = color.blue;
+
+ if (INTEGERP (Vhighlight_color_dark_boost_limit))
+ limit = XINT (Vhighlight_color_dark_boost_limit);
+ else
+ limit = 48000; /* "grey" */
+
+ /* We only boost colors that are darker than
+ Vhighlight_color_dark_boost_limit. */
+ if (bright < limit)
+ {
+ double boost = XFLOATINT (Vhighlight_color_dark_boost);
+
+ if (boost > 0)
+ {
+ /* How far below LIMIT this color is. */
+ double dimness = (double)limit / bright;
+
+ if (boost != 1.0)
+ dimness = pow (dimness, boost);
+
+ if (factor >= 1)
+ factor *= dimness;
+ else
+ factor /= dimness;
+ }
+ }
+ }
+
/* Change RGB values by specified FACTOR. Avoid overflow! */
xassert (factor >= 0);
new.red = min (0xffff, factor * color.red);
@@ -13887,6 +13932,31 @@ wide as that tab on the display.");
staticpro (&last_mouse_motion_frame);
last_mouse_motion_frame = Qnil;
+
+ /* Initialize parameters used by x_alloc_lighter_color. */
+
+ DEFVAR_LISP ("highlight-color-dark-boost",
+ &Vhighlight_color_dark_boost,
+ "How much to boost the brightness of 3d highlights for dark colors.
+Nominally, highlight colors for `3d' faces are calculated by brightening
+an object's color by a constant factor. If `highlight-color-dark-boost'
+is a floating point number between 0 and 1, colors darker than
+`highlight-color-dark-boost-limit' have their highlight factor
+increased: a value of 0 means no increase at all, and a value of 1
+means that all dark colors will have a highlight with a brightness
+equal to `highlight-color-dark-boost-limit'.
+
+Changing this value will not have an effect until a new frame is created.");
+ Vhighlight_color_dark_boost = make_float (0.5);
+
+ DEFVAR_LISP ("highlight-color-dark-boost-limit",
+ &Vhighlight_color_dark_boost_limit,
+ "The maximum brightness of colors that have their highlight brightness boosted.
+See `highlight-color-dark-boost'.");
+ /* The default value here is set so that the default
+ menu-bar/mode-line color (grey75) will not have its highlights
+ changed at all. */
+ Vhighlight_color_dark_boost_limit = 48000;
}
#endif /* not HAVE_X_WINDOWS */