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. diff -up src/xterm.c.\~1\~ src/xterm.c --- src/xterm.c.~1~ Tue Oct 31 09:44:48 2000 +++ src/xterm.c Tue Nov 7 18:36:41 2000 @@ -383,6 +383,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. */ @@ -3517,6 +3521,58 @@ x_alloc_lighter_color (f, display, cmap, new.green = min (0xffff, factor * color.green); new.blue = min (0xffff, factor * color.blue); + if (NUMBERP (Vhighlight_color_dark_boost)) + /* Calculate an additive component to boost dark colors more. */ + { + 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); + if (limit > 0xFFFF) + /* Limit LIMIT to the maximum color component value. */ + limit = 0xFFFF; + } + else + limit = 48000; /* "grey" */ + + /* We only boost colors that are darker than + Vhighlight_color_dark_boost_limit. */ + if (bright > 0 && bright < limit) + { + double boost = XFLOATINT (Vhighlight_color_dark_boost); + + if (boost > 0) + { + /* How far below LIMIT this color is (0 - 1, 1 being darker). */ + double dimness = 1 - (double)bright / limit; + /* The additive adjustment. */ + int min_delta = delta * dimness * boost; + + if (factor < 1) + { + new.red = max (0, new.red - min_delta); + new.green = max (0, new.green - min_delta); + new.blue = max (0, new.blue - min_delta); + } + else + { + new.red = min (0xffff, min_delta + new.red); + new.green = min (0xffff, min_delta + new.green); + new.blue = min (0xffff, min_delta + new.blue); + } + } + } + } + /* Try to allocate the color. */ success_p = x_alloc_nearest_color (f, cmap, &new); if (success_p) @@ -13887,7 +13943,34 @@ 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.\n\ +Nominally, highlight colors for `3d' faces are calculated by brightening\n\ +an object's color by a constant factor. If `highlight-color-dark-boost'\n\ +is a floating point number between 0 and 1, colors darker than\n\ +`highlight-color-dark-boost-limit' have their highlight factor\n\ +increased: a value of 0 means no increase at all, and greater values\n\ +yield correspondingly greater increases.\n\ +\n\ +Changing this value will not have an effect until a new frame is created."); + Vhighlight_color_dark_boost = make_float (0.7); + + DEFVAR_LISP ("highlight-color-dark-boost-limit", + &Vhighlight_color_dark_boost_limit, + "Brightness beyond which a color won't have its highlight brightness boosted.\n\ +See `highlight-color-dark-boost'.\n\ +\n\ +The `brightness' of a color, for this purpose, is defined to be the\n\ +maximum of the color's red, green, or blue components, as returned by\n\ +`color-values'."); + /* 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 */ -