PyvesB / eclipse-planet-themes

:new_moon: Collection of light and dark Eclipse themes, inspired by planets of the Solar System.
https://marketplace.eclipse.org/content/planet-themes
Eclipse Public License 2.0
39 stars 5 forks source link

Support for CDT / Xilinx Vitis < 2023.1 #18

Closed Arryk closed 4 months ago

Arryk commented 4 months ago

Basic support for CDT with an initial port of the themes.

Notes:

I have successfully exported the plugin 0.3.0 and installed it on Xilinx Vitis 2021.1

PyvesB commented 4 months ago

I tried to create a color definition in Neptune to try to reuse color and prevent duplicating RGB raw values into IEclipsePreferences but this failed, if you know a way of doing it that'll make the tweaking easier

@vogella you're one of the experts when it comes to CSS, do you happen to know if this is possible? :)

vogella commented 4 months ago

I tried to create a color definition in Neptune to try to reuse color and prevent duplicating RGB raw values into IEclipsePreferences but this failed, if you know a way of doing it that'll make the tweaking easier

@vogella you're one of the experts when it comes to CSS, do you happen to know if this is possible? :)

I don't understand the question. You can define colors via extension point and re-use this definition in CSS. Was that the question?

Arryk commented 4 months ago

I tried to create a color definition in Neptune to try to reuse color and prevent duplicating RGB raw values into IEclipsePreferences but this failed, if you know a way of doing it that'll make the tweaking easier

@vogella you're one of the experts when it comes to CSS, do you happen to know if this is possible? :)

I don't understand the question. You can define colors via extension point and re-use this definition in CSS. Was that the question?

Hi @vogella

The goal here is to reuse ColorDefinition inside IEclipsePreference preferences: property. Image as an example:

image

The preference: property is string that equals a raw value of RGB, is there a way to replace that raw RGB value with a value inferred from ColorDefinition ?

For example:

IEclipsePreferences#org-eclipse-ui-editors:io-github-pyvesb-eclipse_planet_themes-moon {
  preferences:
    'AbstractTextEditor.Color.Background=#io-github-pyvesb-eclipse_planet_themes-BACKGROUND_COLOR'
    'AbstractTextEditor.Color.SelectionBackground=190,190,190'
    'currentLineColor=220,220,220'
    'searchResultIndicationColor=128,128,128';
}

but this doesn't seems to work, any way we can achieve this result ? Can we access a property like AbstractTextEditor.Color.Background and set it to #io-github-pyvesb-eclipse_planet_themes-BACKGROUND_COLOR

Hope this clarify

vogella commented 4 months ago

I don't think that will work. What will work is that you use the colors extension point to define a color. That will make the color also available in the colors and themes preference page so that the user can change it. This color can also be used in the CSS. I don't think that it would be possible to use this in the preference node at the moment, IIRC this copies the stuff as is.

But changing the CSS preference handler should be possible, maybe build in your use case. IIRC it is super simple at the moment https://github.com/eclipse-platform/eclipse.platform.ui/blob/master/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/preference/EclipsePreferencesHandler.java and https://github.com/eclipse-platform/eclipse.platform.ui/blob/master/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/EclipsePreferencesHelper.java look relevant.

Also the relevant tests are here https://github.com/eclipse-platform/eclipse.platform.ui/blob/master/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/properties/preference/EclipsePreferencesHandlerTest.java

Arryk commented 4 months ago

Thanks for the quick answer, this is beyond my comprehension of Java and Eclipse. It looks to me like a lot of work for not much. I suppose writing a Python or Julia script to automatically interpolates the CSS file directly would be easier and more elegant, but it is still a lot of work for not much results.

Arryk commented 4 months ago

Thanks for the contribution, I've given this a spin, and overall this looks great! I like how you did the indentation on the newly-added sections. 👍🏻

I've left a few comments inline, but overall nothing major, mostly things that I think can be removed. However, one thing we should probably add is the following section:

IEclipsePreferences#org-eclipse-ui-editors:org-eclipse-cdt-ui {
  preferences:
      "org.eclipse.cdt.ui.occurrenceIndicationColor=xxxxx"
      "org.eclipse.cdt.ui.writeOccurrenceIndicationColor=yyyyyy"
}

Without it, it can be very challenging to read text when occurrences are marked:

Screenshot 2024-06-25 224630

We can simply align on the same color values used for other occurrenceIndication properties. :)

Commit with fixes available. I added the write occurrences color but it didn't seems to work, can you test on your side ? Thanks

Arryk commented 4 months ago

I played a little bit with the Pluto theme in a real environment and couple of things don't feel right, custom types are not very readable whilst native types contrast is perfect

image

Typedefs being the same color as their field is not very readable, any idea what color to attribute to typedefs and custom types ?

image

when it comes to ENUM I already tweaked a little bit the color for the fields to improve in-code readability

PyvesB commented 4 months ago

I added the write occurrences color but it didn't seems to work, can you test on your side ?

They need to be put in a different preference section:

IEclipsePreferences#org-eclipse-ui-editors:org-eclipse-cdt-ui { ...

Typedefs being the same color as their field is not very readable, any idea what color to attribute to typedefs and custom types ?

Sorry, I've not written C in years, which bits are problematic in above screenshots?

Arryk commented 4 months ago

They need to be put in a different preference section:

Ok, after doing the fix it now works 👍

Sorry, I've not written C in years, which bits are problematic in above screenshots?

I have included some screenshots in my previous message, you can see that My_Struct struct1; Union and uint8_t are all similar color, in bigger project and struct this is not very readable, everything is yellow.

I can always play with the settings and modify it, just wanted to see if you have an opinion on the matter. Maybe this is looking as intended

PyvesB commented 4 months ago

For reference, here are how things look in the default CDT dark-theme:

Screenshot 2024-06-30 at 18 16 38

Overall, I've got no strong opinions on the matter, I'd just suggest not extending the colour palette too much. :)

Arryk commented 4 months ago

Okay, let's just go with the current state of things

PyvesB commented 4 months ago

Sounds good, we can always improve later on. This is great, thanks so much for your contribution!