Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change highlight color of references in Search View in Eclipse CDT?

I want to change the highlight color of references showing in Eclipse's Search View after CDT find reference operation (right click on code -> References -> any). How can I do this?

Note: this is different from standard match highlight color.

Illustration: enter image description here

like image 644
Greg Kramida Avatar asked Nov 17 '15 19:11

Greg Kramida


2 Answers

I found out two easy solutions to this problem:

1) Create a new file and add those lines (extension of the file needs to be .epf):

file_export_version=3.0
/instance/org.eclipse.ui.workbench/org.eclipse.cdt.ui.ColoredLabels.match_highlight=128,0,128 

You might change the color value to match your theme

Then go to File -> Import -> General -> Preferences

Browse to the newly created file and click the Finish button

2) Go to [workspace-location]/.metadata/.plugins/org.eclipse.core.runtime/.settings

Edit org.eclipse.ui.workbench.prefs file and add the line

org.eclipse.cdt.ui.ColoredLabels.match_highlight=128,0,128
like image 78
GARCIN David Avatar answered Oct 14 '22 11:10

GARCIN David


It seems that these colours are not editable and are therefore hard coded in a way that (clearly!) does not work well with a dark theme.

This is the relevant part from the org.eclipse.cdt.ui/plugin.xml:

  <colorDefinition
        id="org.eclipse.cdt.ui.ColoredLabels.match_highlight"
        isEditable="false"
        label="%Dummy.label"
        value="206, 204, 247">
  </colorDefinition>

A small change to the plugin.xml allows the colour to be editable:

  <colorDefinition
        categoryId="org.eclipse.cdt.ui.presentation"
        id="org.eclipse.cdt.ui.ColoredLabels.match_highlight"
        isEditable="true"
        label="Match Highlight"
        value="206, 204, 247">
  </colorDefinition>

And then you can edit the background colour and fix your problem.

This is a known issue in CDT (Bug 468206), contributions welcome.

like image 41
Jonah Graham Avatar answered Oct 14 '22 11:10

Jonah Graham