Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Dark theme support for Xtext editor(Change editor's colors according to Eclipse IDE's theme)
Dark theme support for Xtext editor [message #1818484] Tue, 17 December 2019 09:00 Go to next message
Emmanuel Chebbi is currently offline Emmanuel ChebbiFriend
Messages: 123
Registered: February 2018
Senior Member
Hi,

I'd like to automatically change the colors used by the editor when Eclipse IDE is in dark theme (similar to what is done by JDT).

According to this page [1] (see "Guide for plug-in developers to contribute to the default dark theme") we can contribute to the org.eclipse.e4.ui.css.swt.theme extension point to specify some preferences that should be used when the dark theme is activated, so we should be able to change the colors used by Xtext.

I hence created the following extension:
<extension
    point="org.eclipse.e4.ui.css.swt.theme">
    <stylesheet
          uri="css/dark-theme.css">
       <themeid
             refid="org.eclipse.e4.ui.css.theme.e4_dark">
       </themeid>
    </stylesheet>
</extension>

that links the following CSS file:
IEclipsePreferences#xtext-preferences-node-for-MyDsl:mydsl-ui-themes { /* pseudo attribute added to allow contributions without replacing this node, see Bug 466075 */
	
	preferences:
		'xtext.preferences.node.for.MyDsl.syntaxColorer.tokenStyles.MethodDefinition.color=255,255,0'
		'xtext.preferences.node.for.MyDsl.syntaxColorer.tokenStyles.MethodDefinition.style=1073741824'

}

Sadly it has no effect.

I believe that the CSS file is taken into account because if I change the extension to point to a non existing file an error is shown. I also belive that I used the right preferences node ("xtext.preferences.node.for.MyDsl" is just a placeholder here).

I don't know the internals of the CSS engine so I don't know if the issue comes from me, Xtext, the JFace editor or anything else. And before I spend hours digging into the debugger I'd like to know whether some of you tried (and succeeded?) to add such a dark theme to their Xtext editor.

[1] https://www.eclipse.org/community/eclipse_newsletter/2018/june/darktheme.php#guide-for-plug-in-developers-to-contribute-to-the-default-dark-theme
Re: Dark theme support for Xtext editor [message #1818627 is a reply to message #1818484] Fri, 20 December 2019 18:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Since no one else is replying....

I'm dark-theme-phobic so not the best person to answer, but I have observed changes that were impacting on normal theme.

My recollection is that Xtext was not handled in the initial wave of enthusiasm, but that since Xtext-based editors were so prolific, Xtext was handled a bit later. I would therefore expect that for boring Xtext-based editors, Xtext just works out of the box on dark theme once you correctly select dark theme. Attempting to play games with CSS would seem like the wrong way to go. I suggest searching Xtext Bugzillas / GItHub issues to see what bugs were raised and fixed and how.

Regards

Ed Willink
Re: Dark theme support for Xtext editor [message #1821998 is a reply to message #1818627] Tue, 25 February 2020 14:19 Go to previous messageGo to next message
Emmanuel Chebbi is currently offline Emmanuel ChebbiFriend
Messages: 123
Registered: February 2018
Senior Member
Hi Ed,

Thanks for the answer. I did not find any helping issues or Bugzilla but finally managed to solve the issue. I had created a related thread in the "Eclipse 4" forum and posted the answer there: Specify theme-specific preferences via CSS [1]

[1] https://www.eclipse.org/forums/index.php?t=msg&th=1101764&goto=1821997&#msg_1821997
Re: Dark theme support for Xtext editor [message #1822006 is a reply to message #1818627] Tue, 25 February 2020 15:23 Go to previous message
Emmanuel Chebbi is currently offline Emmanuel ChebbiFriend
Messages: 123
Registered: February 2018
Senior Member
EDIT: sorry, it was a double post

[Updated on: Tue, 25 February 2020 15:24]

Report message to a moderator

Previous Topic:EMF Compare and LazyLinkingResource proxy URLs
Next Topic:Xtext Hover Documentation [Duplicate - https://www.eclipse.org/forums/index.php/m/1822037/#msg_18220
Goto Forum:
  


Current Time: Sat Apr 20 00:40:04 GMT 2024

Powered by FUDForum. Page generated in 0.03130 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top