Bug 532359 - [code mining] Use a font from FontRegistry to draw code mining
Summary: [code mining] Use a font from FontRegistry to draw code mining
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.8   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on: 532326 564099
Blocks:
  Show dependency tree
 
Reported: 2018-03-12 13:24 EDT by Angelo ZERR CLA
Modified: 2023-04-25 05:24 EDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Angelo ZERR CLA 2018-03-12 13:24:48 EDT
IMHO, line header codemining should be in italic. 

I think it's a good choice because in JDT Java Editor, mining and Java annotation (ex: "@Override") are renderered with same style. 

For the moment it's hard coded, but in the future mining renderer should be customized with preferences "Colors and Fonts".

I'm waiting for https://bugs.eclipse.org/bugs/show_bug.cgi?id=532326 to create a gerrit patch
Comment 1 Mickael Istria CLA 2018-03-12 13:45:09 EDT
I believe we need something more generic and configurable. The font (which font, the size, italic or not...) should be something that comes from the FontRegistry and that users could customize in color and font preference page.
Comment 2 Eclipse Genie CLA 2018-03-12 15:13:44 EDT
New Gerrit change created: https://git.eclipse.org/r/119257
Comment 3 Lars Vogel CLA 2018-07-03 04:48:18 EDT
AFAIK typically fonts are defined via the themes extension point. See http://blog.eclipse-tips.com/2008/08/adding-color-and-font-preferences.html

But I don't think we can use this in org.eclipse.jface.text as it would introduce as it would create a dependency to platform.ui. 

@Mickael, what is the correct process to define fonts in the eclipse.text repo?
Comment 4 Thomas Wolf CLA 2018-07-03 05:12:34 EDT
Isn't the font to be used something that is language-specific? Who says that minings should be displayed identically in JDT and in PDT editors, for example? Or in markup editors?
Comment 5 Lars Vogel CLA 2018-07-03 05:16:53 EDT
(In reply to Thomas Wolf from comment #4)
> Isn't the font to be used something that is language-specific? Who says that
> minings should be displayed identically in JDT and in PDT editors, for
> example? Or in markup editors?

Currently, it is the same for all and hard-coded. I believe this bug is about solving the hard-coded part.
Comment 6 Mickael Istria CLA 2018-07-03 07:02:37 EDT
(In reply to Lars Vogel from comment #3)
> But I don't think we can use this in org.eclipse.jface.text as it would
> introduce as it would create a dependency to platform.ui. 

org.eclipse.ui.workbench.texteditor which defines the code mining extension point and API already has extensions to org.eclipse.ui.themes. So no problem here.

> Isn't the font to be used something that is language-specific?

So far, there is no real user-story to support this.

> Who says that minings should be displayed identically in JDT and in PDT editors, for example? Or in markup editors?

I think it's an implementation choice. So far, I don't think you'll manage to convince current codeminings contributors to work on language-specific font for codeminings. I, for example, think about a totally opposite way: it's better to keep a single preference for consistency, and editors that don't want to be consistent with the IDE shouldn't use this extension point. And so far, there is no strong need for this feature so most will probably prefer working on more profitable tasks.
That said, if you feel like you need to contribute such customization in the code minings, that would be welcome. There is no political opposition against more customization, it's more about priority management and keeping things simple.
Comment 7 Lars Vogel CLA 2018-07-03 07:42:15 EDT
(In reply to Mickael Istria from comment #6)
> (In reply to Lars Vogel from comment #3)
> > But I don't think we can use this in org.eclipse.jface.text as it would
> > introduce as it would create a dependency to platform.ui. 
> 
> org.eclipse.ui.workbench.texteditor which defines the code mining extension
> point and API already has extensions to org.eclipse.ui.themes. So no problem
> here.

Nice. Gerrit upcoming shortly.
Comment 8 Eclipse Genie CLA 2018-07-03 08:27:02 EDT
New Gerrit change created: https://git.eclipse.org/r/125390
Comment 9 Lars Vogel CLA 2018-07-03 09:18:43 EDT
(In reply to Eclipse Genie from comment #8)
> New Gerrit change created: https://git.eclipse.org/r/125390

Patch does not yet react to changes in the default font. Any example how this can be done?  Without this, this patch does more harm than it helps as code minings will use fixed sizes even if the text font changes.
Comment 10 Angelo ZERR CLA 2018-07-03 09:35:53 EDT
> Patch does not yet react to changes in the default font.

It was one reason why I have not customized font:) 

> Without this, this patch does more harm than it helps as code minings will use fixed sizes even if the text font changes.

I suggest you to see and understand code from AbstractTextZoomHandler#execute. It should be very cool if you could manage this zoom feature.
Comment 11 Lars Vogel CLA 2018-07-03 11:08:50 EDT
(In reply to Angelo ZERR from comment #10)
> I suggest you to see and understand code from
> AbstractTextZoomHandler#execute. It should be very cool if you could manage
> this zoom feature.

The AbstractTextZoomHandler#execute will only adjust values which have a common base font and have either no font data set or the same as the referred base value. So if I set the code mining to org.eclipse.jface.textfont and never change it from the base font, it will also increase.

Mickael (as Mickael did the implementation of this handler), was there a particular design decision behind this logic? Why not increase all fonts with the same parent independent of their current value?
Comment 12 Mickael Istria CLA 2018-07-03 11:42:22 EDT
(In reply to Lars Vogel from comment #11)
> Why not increase all fonts
> with the same parent independent of their current value?

The initial idea was that if font were different (espacially size) then user probably don't need to change both fonts actually. So zooming in/out was assumed to be only desired on the current font and similar (ie same "family" with a common ancestor and same value).
But I'm not against a change in this if a better strategy is decided.
For example, a better approach could be instead of comparing th the FontData in AbstractTextZoomHandler, to look inside the FontData and compare the sizes. So 2 fonts with same size and different size would be linked.
Comment 13 Mickael Istria CLA 2018-07-03 15:04:44 EDT
If we are not able to use the FontRegistry right now, would it make sense to change the hardcoded font for codemining to italic as a 1st iteration?
Just like stage instructions in theater, italic is often used for non-payload content in several domains.
Comment 14 Lars Vogel CLA 2018-07-03 15:30:20 EDT
(In reply to Mickael Istria from comment #13)
> If we are not able to use the FontRegistry right now, would it make sense to
> change the hardcoded font for codemining to italic as a 1st iteration?
> Just like stage instructions in theater, italic is often used for
> non-payload content in several domains.

+1, lets merge Angelos https://git.eclipse.org/r/#/c/119257/
Comment 15 Eclipse Genie CLA 2020-06-08 14:41:20 EDT
New Gerrit change created: https://git.eclipse.org/r/164462
Comment 16 John Taylor CLA 2020-06-08 14:42:47 EDT
Regarding comment 12 - I believe the zooming behavior is fundamentally broken. For example, zooming a Java editor by default results in the Git commit message and the console (along with 14 other items in my current Eclipse instance) also zooming in, even though these things are tangentially related at best. Additionally, if one overrides the Java editor font setting, and then zooms, only the Java editor and the Java compare view will update, and one might be surprised, having observed the previous behavior, to find that nothing else has updated.

I realize that there is no way to use the font registry as it exists today to truly define what should and should not be modified, so, as it is, I propose that the behavior described above without overriding any fonts should be the behavior all the time. In other words, if one zooms a window somehow related to "Text Font", then all other fonts related to "Text Font" should zoom, regardless of any user overrides.

If we can accept this, then we can resolve this bug. I have prepared a patch that allows for individually setting the font and colors of the Headline and Inline code minings, and also adjusts the AbstractTextZoomHandler to behave as described. See gerrit in #15.
Comment 17 Mickael Istria CLA 2020-06-08 15:37:50 EDT
(In reply to John Taylor from comment #16)
> I realize that there is no way to use the font registry as it exists today
> to truly define what should and should not be modified, so, as it is, I
> propose that the behavior described above without overriding any fonts
> should be the behavior all the time. In other words, if one zooms a window
> somehow related to "Text Font", then all other fonts related to "Text Font"
> should zoom, regardless of any user overrides.

That can be slightly better, however, please open a dedicated bug with this proposal and mark it as "see also" or "depends on" for this current bug.
Comment 18 Stuart Sharpe CLA 2023-04-25 05:24:51 EDT
Hi, I just came across this bug after trying to figure out how to change the font for code minings. I see that the dependent bugs are all resolved now, is there any chance of getting this merged?

Thanks