Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 347493

Summary: Syntax highlighting and themeing
Product: [ECD] Orion Reporter: Simon Kaegi <simon_kaegi>
Component: EditorAssignee: Project Inbox <orion.editor-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: bokowski, eclipse.felipe, john.arthorne, karol, mamacdon, Mike_Wilson, Silenio_Quarti, susan
Version: 0.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Simon Kaegi CLA 2011-05-27 14:02:25 EDT
There was a question on the mailing list on how to provide custom styling for use with our syntax highlighting extension. We've had some general conversation about how we might do themeing for this case and this bug is to track the creation of an appropriate cut point.

As a general approach I'd like to avoid having a plugin directly contribute a stylesheet to the main page however I think as a starting point having a plugin provide styles for a fixed set of token categories would be workable. It would also be good to see what concepts we can borrow from Desktop Eclipse and TextMate themes.
Comment 1 Boris Bokowski CLA 2011-05-27 15:12:33 EDT
If I am not mistaken, the editor component already uses its own stylesheet. This stylesheet applies to the editor only, not the complete page. I believe that it is appropriate for a plugin to contribute such an editor-only stylesheet, so that the editor can be themed.
Comment 2 Simon Kaegi CLA 2011-05-27 15:28:40 EDT
We could think about it but I'm concerned this might allow a cleverly written stylesheet to do things it was not intended to do.
Comment 3 Felipe Heidrich CLA 2011-05-27 15:32:38 EDT
Notes:

- Currently the editor has one css that includes all styles
-- syntax highlight (keyword, etc)
-- rules styles (background color for the line numbering etc)
-- bracket matching color
-- current line highlight 
-- default editor styles (font, background, etc)


You can pass an array of css files to the editor, so it possible to split the
css information on several files. This can be useful if the users wants to
restyle the colors for the syntax highlight without changing, for example, the
colors for the line numbering ruler.

What I suspect you will need, and currently you won't have in the editor, is
the capability of changing the css files for the editor without recreating it.
Comment 4 Boris Bokowski CLA 2011-05-27 15:50:04 EDT
(In reply to comment #2)
> We could think about it but I'm concerned this might allow a cleverly written
> stylesheet to do things it was not intended to do.

Do you have any pointers to the relevant scare literature? What kind of bad things could a stylesheet do? Also, wouldn't we expect users to only install plugins from reputable sources? ;-)
Comment 5 Simon Kaegi CLA 2011-05-28 21:27:17 EDT
(In reply to comment #4)
> Do you have any pointers to the relevant scare literature? What kind of bad
> things could a stylesheet do? Also, wouldn't we expect users to only install
> plugins from reputable sources? ;-)

Until recently you could run JavaScript in CSS "expression"s and "behavior"s and I suspect a little research is needed. Perhaps it's fine but we need to be incredibly careful about letting a plugin execute code in the security context of the main application. I buy the reputable source argument only as far as we have some control of what that reputable source can do.
Comment 6 Mark Macdonald CLA 2011-09-19 17:28:26 EDT
Right now there is no way to contribute styles to the editor via extensions (or anywhere else in the UI, really, despite the fact that some services allow you to specify what CSS classes should be applied to UI elements).

Is there anything we can do wrt defining an acceptable CSS subset that is "safe" to use?

Some quick Googling suggests that expression support was limited to IE and is disabled in IE8+ when running in standards mode [1]. I tested with IE9 and found that setExpression still executed when the document mode was Quirks or IE7 Standards, but not IE8 Standards or above.

[1] http://msdn.microsoft.com/en-us/library/cc304082(v=vs.85).aspx#expressions
[2] http://msdn.microsoft.com/en-us/library/ms537634%28v=vs.85%29.aspx
Comment 7 John Arthorne CLA 2011-10-14 09:50:47 EDT
Since we won't have a story for contributing CSS from plugins for 0.3, I'm proposing we at least provide a reasonable default set of syntax highlighting themes in bug 360967. Currently it appears to be impossible to write a simple syntax highlighter other than the HTML one, because we hard-code the CSS themes for the HTML grammar in our editor.
Comment 8 Felipe Heidrich CLA 2011-11-24 12:21:12 EST
See https://bugs.eclipse.org/bugs/show_bug.cgi?id=363970#c9
https://bugs.eclipse.org/bugs/show_bug.cgi?id=334212#c2

We just added support to TextView to change the theme (setOptions changing stylesheets and themeClass).
Comment 9 John Arthorne CLA 2015-05-05 14:54:40 EDT
Closing as part of a mass clean up of inactive bugs. Please reopen if this problem still occurs or is relevant to you. For more details see:

https://dev.eclipse.org/mhonarc/lists/orion-dev/msg03444.html