State of codehighlighting.cpp

David Nolden david.nolden.kdevelop at art-master.de
Wed Apr 15 17:19:06 UTC 2009


Am Mittwoch 15 April 2009 19:02:28 schrieb Milian Wolff:
> Hi devels!
>
> Since I'm a user of a dark color scheme I want to get support for custom
> color schemes fixed in KDevelop. I took a look at codehighlighting.cpp and
> found some "issues" which I'd like to fix / change:
>
> 1. why uint instead of qcolor all over the place? There are tons of (imo
> unneccessary) "casts" due to that. I'd like to move everything to QColor.
Not all over the place, only in the places where the interpolation plays a 
role, and that's already the reason: uint's can be interpolated easily. You 
can only do that with QColor if you first convert it back to uint, so why not 
just keep it as uint? It doesn't matter..

> 2. there's lots of missing documentation / explanation in that file. I
> myself have never had to do color interpolation or mixing, and am a bit
> lost on how exactly the interpolate function works. Could someone
> elaborate? Or maybe give me a link to a explanation, imo this should be a
> common problem which got solved pretty often.
Interpolating colors is like interpolating anything else, linearly transform 
from one color into the next(Although I'm right now thinking whether this is 
actually correct ;-) )
> 3. Couldn't the whole process be simplified somehow? For example by setting
> a few defaults for white background / black foreground. Then for custom
> kate color schemes we adapt our defaults according to a algorithm of our
> choice.
>
> I'm currently writing a little test-app for different color agorithms, if
> you know any good ones, please let me know!
>
> I'll also implement the current algorithm to see how it fares.
What do you mean by "color algorithms"? All the code in there does is 
generating a predefined set of colors, that differ as much as possible from 
each other, using the color wheel(try the HSV color model in gimp to see it 
illustrated). There's not more you can do.

Once those colors are chosen, they are damped/blended by the user-configured 
value with the normal foregrond color, to make it less annoying.

There is one problem: See codehighlighting.cpp:127, I haven't found time to 
find out how to correctly extract the text-editor foreground color. That would 
be the first thing you have to do to make it work with dark color schemes. 
Actually, I think when that works, the problem with the auto-generated colors 
would be solved, so the only remaining problematic colors would be the 
hardcoded ones.

To solve that one, I think the proper solution would be getting the kate 
editor background color, and then automatically manipulating all colors so 
they have some minimum contrast to that background. I've done something 
similar in kdelibs/kate/completion/expandingtree/expandingdelegate.cpp, where 
I just invert the color if it doesn't have enough contrast to the background. 
As a first try, you could just copy the code from there, and do the same 
thing. The only problem is that some colors might look ugly when they are 
inverted. It would be better keeping the same color tone, just making it 
darker or lighter.

Greetings, David





More information about the KDevelop-devel mailing list