Added support for configurable font styles for syntax highlighting
AbandonedPublic

Authored by mdlubakowski on Jul 31 2019, 11:46 AM.

Details

Reviewers
None
Group Reviewers
KDevelop
Summary

Related to BUG: 395856, BUG: 410213

Problem:Everybody who uses KDevelop probably noticed that editor font styles (mainly color) for several types cannot be changed. This is because KDevelop makes use of KTextEditor, but at the same time enhances provided highlighting with its own module, which has hardcoded color values.
I think it is not good that modern IDE doesn't provide such a basic customization, so I decided to fix for myself, which ultimately grew into this patch.

What does this patch change: Adds new settings page to the Editor tree, which allows to customize font style for several previously hardcoded types like class names, namespace names, methods, enumerators and so on.
As for the code aspect, I created a new module ConfigurableSyntaxStyle, which acts as repository for all the styles and can be easily extended with new entries if needed.
I tried not to touch existing code too much, so the only changes in other modules are those that adapt highlighting to use the new styles model. This also means that color blending works the same way as it always did (Local/Global Colorization Intensity settings).

What else can be done:
Add more customization options (selected background color, selected text color etc.)
Integrate the settings with KTextEditor settings panel - I didn't find a way to do it from KDevelop code, so in the end I just added it as an additional page. But maybe it is possible - needs investigation.
Integrate "Semantic Highlighting Options" from "Language Support" page into new settings. It would probably be a good idea since these options affect highlighting.
Group options into categories.

If you have any suggestions, please leave a comment.

I'm attaching some screenshots so you can see how it looks:

Diff Detail

Repository
R32 KDevelop
Branch
configurable-syntax-styles
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 14602
Build 14620: arc lint + arc unit
mdlubakowski created this revision.Jul 31 2019, 11:46 AM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptJul 31 2019, 11:46 AM
mdlubakowski requested review of this revision.Jul 31 2019, 11:46 AM

This functionality would be great.

apol added a subscriber: apol.Aug 24 2019, 12:39 AM

Have you reflected on what users need changing or we're just adding this because it's possible?
I'm not opposing having this, but if something can be improved, I'd improve it for everyone first.

In D22854#517776, @apol wrote:

Have you reflected on what users need changing or we're just adding this because it's possible?
I'm not opposing having this, but if something can be improved, I'd improve it for everyone first.

Hello, thanks for response!
I'm not sure if you are referring to this patch as a whole, to the choice of syntax elements, or to the available style options, so let me just answer all three:
From what I saw, feature like this was asked about on several different occasions. If you try to google something along the lines: "how to change KDevelop syntax colors", "how to change class name color in KDevelop" etc. you can find people being confused why it isn't possible. Some examples: Bug 395856, Bug 410213, Gentoo forums, KDE forums, some other forums. In fact, this was one of the first things I tried to do when I started using KDevelop, only to find that it's impossible.
As for the choice of configurable elements, I simply included all of those which were previously hardcoded. I don't think there is a reason to exclude any of them.
About available style options: I think that ideally, this setting page should provide the exact same options that "Highlighting Text Styles" in in Editor > Fonts and Colors provides, for the sake of consistency. The best way to do this would obviously be to make one, universal settings window, but I dont think this can be easily done (if at all).

mdlubakowski abandoned this revision.Sep 17 2019, 7:07 AM

Scrapping this for now, since I have a few improvements on this, but it needs to be reworked. Ill make a PR with updated version on GitLab instance.